API Rest testing FastAPI + SQLAchmey + Docker

Overview

Transactions API Rest

Implement and design a simple REST API

Description

We need to a simple API that allow us to register users' transactions and have an overview of how are they using their money. To do so, we want you to implement a REST API that:

  1. Can create users by receiving: name, email and age.

Example:

{"name": "Jane Doe", "email": "[email protected]", "age": 23}
  1. List all users and also and see the details of a specific user.

  2. Can save users' transactions. Each transaction has: reference (unique), account, date, amount, type and category.

Example:

{"reference": "000051", "account": "S00099", "date": "2020-01-13", "amount": "-51.13", "type": "outflow", "category": "groceries"}

Constraints:

  • A transaction reference is unique.
  • There are only two type of transactions: inflow and outflow.
  • All outflow transactions amounts are negative decimal numbers.
  • All inflow transactions amounts are positive decimal numbers.
  • We expect to receive transactions in bulk as well.
  • The transactions we receive could be already in our system, thus we need to avoid duplicating them in our database.

Goals

  • Given an user id, we want to be able to see a summary by account that shows the balance of the account, total inflow and total outflows. It should be possible to specify a date range, if no date range is given all transactions should be considered.

Input:

[
 {"reference": "000051", "account": "C00099", "date": "2020-01-03", "amount": "-51.13", "type": "outflow", "category": "groceries"},
 {"reference": "000052", "account": "C00099", "date": "2020-01-10", "amount": "2500.72", "type": "inflow", category": "salary"},
 {"reference": "000052", "account": "C00099", "date": "2020-01-10", "amount": "-150.72", "type": "outflow", category": "transfer"},
 {"reference": "000054", "account": "C00099", "date": "2020-01-13", "amount": "-560.00", "type": "outflow", "category": "rent"},
 {"reference": "000689", "account": "S00012", "date": "2020-01-10", "amount": "150.72", "type": "inflow", "category": "savings"},
]

Output:

[
 {"account": "C00099", "balance": "1738.87", "total_inflow": "2500.72", "total_outflow": "-761.85"},
 {"account": "S00012", "balance": "150.72", "total_inflow": "150.72", "total_outflow": "0.00"},
]

  • Given an user id, we want to be able to see a summary by category that shows the sum of amounts per transaction category:

Input:

[
 {"reference": "000051", "account": "C00099", "date": "2020-01-03", "amount": "-51.13", "type": "outflow", "category": "groceries"},
 {"reference": "000052", "account": "C00099", "date": "2020-01-10", "amount": "2500.72", "type": "inflow", category": "salary"},
 {"reference": "000052", "account": "C00099", "date": "2020-01-10", "amount": "-150.72", "type": "outflow", category": "transfer"},
 {"reference": "000054", "account": "C00099", "date": "2020-01-13", "amount": "-560.00", "type": "outflow", "category": "rent"},
 {"reference": "000689", "account": "S00012", "date": "2020-01-10", "amount": "150.72", "type": "inflow", "category": "savings"},
]

Output:

{"inflow": {"salary": "2500.72", "savings": "150.72"}, "outflow": {"groceries": "-51.13", "rent": "-560.00", "transfer": "-150.72"}}

Run

docker-compose up -d --build

Check the API with http://127.0.0.1:8000/_check

Documentation

http://127.0.0.1:8000/docs

Tests

docker-compose exec api pytest -vvv .
Owner
TxeMac
Backend developer.
TxeMac
Automated Security Testing For REST API's

Astra REST API penetration testing is complex due to continuous changes in existing APIs and newly added APIs. Astra can be used by security engineers

Flipkart Incubator 2.1k Dec 31, 2022
Show, Edit and Tell: A Framework for Editing Image Captions, CVPR 2020

Show, Edit and Tell: A Framework for Editing Image Captions | arXiv This contains the source code for Show, Edit and Tell: A Framework for Editing Ima

Fawaz Sammani 76 Nov 25, 2022
Data App Performance Tests

Data App Performance Tests My hypothesis is that The different architectures of

Marc Skov Madsen 6 Dec 14, 2022
Testinfra test your infrastructures

Testinfra test your infrastructure Latest documentation: https://testinfra.readthedocs.io/en/latest About With Testinfra you can write unit tests in P

pytest-dev 2.1k Jan 07, 2023
A Python Selenium library inspired by the Testing Library

Selenium Testing Library Slenium Testing Library (STL) is a Python library for Selenium inspired by Testing-Library. Dependencies Python 3.6, 3.7, 3.8

Anže Pečar 12 Dec 26, 2022
Pymox - open source mock object framework for Python

Pymox is an open source mock object framework for Python. First Steps Installation Tutorial Documentation http://pymox.readthedocs.io/en/latest/index.

Ivan Rocha 7 Feb 02, 2022
This package is a python library with tools for the Molecular Simulation - Software Gromos.

This package is a python library with tools for the Molecular Simulation - Software Gromos. It allows you to easily set up, manage and analyze simulations in python.

14 Sep 28, 2022
Avocado is a set of tools and libraries to help with automated testing.

Welcome to Avocado Avocado is a set of tools and libraries to help with automated testing. One can call it a test framework with benefits. Native test

Ana Guerrero Lopez 1 Nov 19, 2021
Whatsapp messages bulk sender using Python Selenium.

Whatsapp Sender Whatsapp Sender automates sending of messages via Whatsapp Web. The tool allows you to send whatsapp messages in bulk. This program re

Yap Yee Qiang 3 Jan 23, 2022
Getting the most out of your hobby servo

ServoProject by Adam Bäckström Getting the most out of your hobby servo Theory The control system of a regular hobby servo looks something like this:

209 Dec 20, 2022
Automated Penetration Testing Framework

Automated Penetration Testing Framework

OWASP 2.1k Jan 01, 2023
PoC getting concret intel with chardet and charset-normalizer

aiohttp with charset-normalizer Context aiohttp.TCPConnector(limit=16) alpine linux nginx 1.21 python 3.9 aiohttp dev-master chardet 4.0.0 (aiohttp-ch

TAHRI Ahmed R. 2 Nov 30, 2022
Subprocesses for Humans 2.0.

Delegator.py — Subprocesses for Humans 2.0 Delegator.py is a simple library for dealing with subprocesses, inspired by both envoy and pexpect (in fact

Amit Tripathi 1.6k Jan 04, 2023
Ward is a modern test framework for Python with a focus on productivity and readability.

Ward is a modern test framework for Python with a focus on productivity and readability.

Darren Burns 1k Dec 31, 2022
A testing system for catching visual regressions in Web applications.

Huxley Watches you browse, takes screenshots, tells you when they change Huxley is a test-like system for catching visual regressions in Web applicati

Facebook Archive 4.1k Nov 30, 2022
Set your Dynaconf environment to testing when running pytest

pytest-dynaconf Set your Dynaconf environment to testing when running pytest. Installation You can install "pytest-dynaconf" via pip from PyPI: $ pip

David Baumgold 3 Mar 11, 2022
The async ready version of the AniManga library created by centipede000.

Async-Animanga An Async/Aiohttp compatible library. Async-Animanga is an async ready web scraping library that returns Manga information from animepla

3 Sep 22, 2022
A complete test automation tool

Golem - Test Automation Golem is a test framework and a complete tool for browser automation. Tests can be written with code in Python, codeless using

486 Dec 30, 2022
pytest plugin for distributed testing and loop-on-failures testing modes.

xdist: pytest distributed testing plugin The pytest-xdist plugin extends pytest with some unique test execution modes: test run parallelization: if yo

pytest-dev 1.1k Dec 30, 2022
WEB PENETRATION TESTING TOOL 💥

N-WEB ADVANCE WEB PENETRATION TESTING TOOL Features 🎭 Admin Panel Finder Admin Scanner Dork Generator Advance Dork Finder Extract Links No Redirect H

56 Dec 23, 2022