Skip to content

Commit

Permalink
add main scaffolding and app dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mauudev committed Feb 12, 2024
1 parent 64fd4dd commit 2503a62
Show file tree
Hide file tree
Showing 11 changed files with 1,847 additions and 0 deletions.
5 changes: 5 additions & 0 deletions infra/clean_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

docker container prune -f
docker network prune -f
docker volume prune -f
22 changes: 22 additions & 0 deletions infra/db_scripts/pg_many_db
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e
set -u

function create_user_and_database() {
local database=$1
echo " Creating user and database '$database'"
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE USER $database;
CREATE DATABASE $database;
GRANT ALL PRIVILEGES ON DATABASE $database TO $database;
EOSQL
}

if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then
echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES"
for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do
create_user_and_database $db
done
echo "Multiple databases created"
fi
27 changes: 27 additions & 0 deletions infra/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3.9"

services:
app_database:
container_name: app_database
hostname: app_database
restart: always
image: postgres:15.3
environment:
POSTGRES_MULTIPLE_DATABASES: test_items_db, items_db
POSTGRES_USER: admin
POSTGRES_PASSWORD: admin
volumes:
- postgres_data:/var/lib/postgresql/data
- ./db_scripts/pg_many_db:/docker-entrypoint-initdb.d/initdb.sh
ports:
- 1010:5432
networks:
- test_db

volumes:
postgres_data:

networks:
test_db:
name: test_db
driver: bridge
1,724 changes: 1,724 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[tool.poetry]
name = "tox-testing-env"
version = "0.1.0"
description = ""
authors = ["mauudev <[email protected]>"]
readme = "README.md"
packages = [
{ include = "src" },
]

[tool.poetry.dependencies]
python = "^3.10"
fastapi = "^0.109.2"
pydantic = "^2.6.1"
uvicorn = {extras = ["standard"], version = "^0.27.1"}
sqlalchemy = "^2.0.25"
python-dotenv = "^1.0.1"
asyncpg = "^0.29.0"
psycopg2-binary = "^2.9.9"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.group.dev.dependencies]
isort = "^5.13.2"
black = "^24.1.1"
httpx = "^0.26.0"

[tool.poetry.group.test.dependencies]
pytest = "^8.0.0"
pytest-asyncio = "^0.23.5"
pytest-cov = "^4.1.0"
tox = "^4.12.1"
tox-docker = "^4.1.0"
trio = "^0.24.0"
anyio = "^4.2.0"

[tool.pytest.ini_options]
asyncio_mode = "auto"
24 changes: 24 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
annotated-types==0.6.0 ; python_version >= "3.10" and python_version < "4.0"
anyio==4.2.0 ; python_version >= "3.10" and python_version < "4.0"
async-timeout==4.0.3 ; python_version >= "3.10" and python_version < "3.12.0"
asyncpg==0.29.0 ; python_version >= "3.10" and python_version < "4.0"
click==8.1.7 ; python_version >= "3.10" and python_version < "4.0"
colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and (sys_platform == "win32" or platform_system == "Windows")
exceptiongroup==1.2.0 ; python_version >= "3.10" and python_version < "3.11"
fastapi==0.109.2 ; python_version >= "3.10" and python_version < "4.0"
greenlet==3.0.3 ; python_version >= "3.10" and python_version < "4.0" and (platform_machine == "aarch64" or platform_machine == "ppc64le" or platform_machine == "x86_64" or platform_machine == "amd64" or platform_machine == "AMD64" or platform_machine == "win32" or platform_machine == "WIN32")
h11==0.14.0 ; python_version >= "3.10" and python_version < "4.0"
httptools==0.6.1 ; python_version >= "3.10" and python_version < "4.0"
idna==3.6 ; python_version >= "3.10" and python_version < "4.0"
pydantic-core==2.16.2 ; python_version >= "3.10" and python_version < "4.0"
pydantic==2.6.1 ; python_version >= "3.10" and python_version < "4.0"
python-dotenv==1.0.1 ; python_version >= "3.10" and python_version < "4.0"
pyyaml==6.0.1 ; python_version >= "3.10" and python_version < "4.0"
sniffio==1.3.0 ; python_version >= "3.10" and python_version < "4.0"
sqlalchemy==2.0.25 ; python_version >= "3.10" and python_version < "4.0"
starlette==0.36.3 ; python_version >= "3.10" and python_version < "4.0"
typing-extensions==4.9.0 ; python_version >= "3.10" and python_version < "4.0"
uvicorn[standard]==0.27.1 ; python_version >= "3.10" and python_version < "4.0"
uvloop==0.19.0 ; (sys_platform != "win32" and sys_platform != "cygwin") and platform_python_implementation != "PyPy" and python_version >= "3.10" and python_version < "4.0"
watchfiles==0.21.0 ; python_version >= "3.10" and python_version < "4.0"
websockets==12.0 ; python_version >= "3.10" and python_version < "4.0"
3 changes: 3 additions & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from dotenv import load_dotenv

load_dotenv()
Empty file added src/api/__init__.py
Empty file.
Empty file added src/models/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions src/use_cases/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .create_item import RegisterItem, RegisterItemCommand
from .get_item import GetItem, GetItemCommand
Empty file added tests/__init__.py
Empty file.

0 comments on commit 2503a62

Please sign in to comment.