A test/psuedo API to use as sample data or test data.
CI/CD Pipeline:
SonarCloud:
A test/psuedo API to use as sample data or test data. Inspired by FakeResponse.com. Documentation can be found at devsetgo.com/projects/test-api.
Copy the repository
git clone https://github.com/devsetgo/test-api.git
python-3 -m venv env
source env/bin/activate
cd app
Notes:
from src folder: ./scripts/install.sh
Production: pip3 install -r requirements.txt
Development: pip3 install -r requirements/dev.txt
Setup: Copy .env_sample to .env and set configuration as desired.
$ cp .env_example .env
.env_sample file
# # This is used to determin if .env or other external config is used. True is for a .env file and false for docker enviroment
# # option: dotenv, docker
USE_ENV='dotenv'
# Application information
TITLE="Test API"
DESCRIPTION="Test APIs for tools and other examples"
APP_VERSION='One'
OWNER='Your Name'
WEBSITE='https://your.domain.com/support'
# Demo settings
CREATE_SAMPLE_DATA=true
NUMBER_TASKS=10
NUMBER_USERS=10
NUMBER_GROUPS=10
# Cofigurations
HOST_DOMAIN='https://your.domain.com'
#prd for production or 'dev' for development
RELEASE_ENV='dev'
# Turn HTTPS Middleware on (True) or off (False)
HTTPS_ON=false
# Turn on Prometheus endpoint
PROMETHEUS_ON=true
# data base URI
SQLALCHEMY_DATABASE_URI='sqlite:///sqlite_db/api.db'
# Loguru settings
LOGURU_RETENTION='10 days'
LOGURU_ROTATION='100 MB'
# Values NOTSET, DEBUG, INFO, WARNING, ERROR, CRITICAL
LOGURU_LOGGING_LEVEL='INFO'
# Workers - Set to 1 for CPUs x 2 + 1
WORKERS=4
# Leave intact for license
CREATED_BY='Mike Ryan'
LICENSE_TYPE='MIT'
LICENSE_LINK='https://github.com/devsetgo/test-api/blob/master/LICENSE'
Start the app
FROM SCR
Development"
./scripts/dev_run.sh
Production:
./scripts/prd_run.sh
UVICORN
Development:
uvicorn main:app --port 5000 --reload
python3 main.py (running Uvicorn from Code - no reload)
Production:
uvicorn main:app --port 5000 --workers 2
python3 main.py (running Uvicorn from code)
gunicorn -c gunicorn_cfg.py main:app
# Note: gunicorn is the config for the dockerfile
Docker
Docker: docker pull mikeryan56/test-api:latest
By commands
SchemaThesis
st run --workers 10 --fixups fast_api --request-timeout 21000 --max-response-time 21000 --max-failures 2 --hypothesis-deadline 2000 --junit-xml junit.xml http://127.0.0.1:5000/openapi.json
st run --workers 6 --fixups fast_api --request-timeout 21000 --max-response-time 21000 --max-failures 2 --junit-xml junit.xml http://127.0.0.1:5000/openapi.json
./scripts/tests.sh
python3 -m pytest
Create coverage badge
coverage-badge -o coverage.svg -f
As a Script from src directory
./scripts/tests.sh
Pre-Commit & Hooks
- Follow install instructionsL: [https://pre-commit.com/#install](https://pre-commit.com/#install)
- pre-commit install
- pre-commit run -a
default
groups
textblob
todos
users
tools
silly users
health
Application
[ ] Extend Tools API
[x] Better organization
[ ] Work on Connection Pool for SQLite and Postgres for scaling
Docker
Tutorials/Documentation