Skip to content

Commit

Permalink
Add make and testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
tonybenoy committed Nov 28, 2023
1 parent 36b01cf commit 1cc4b85
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 1 deletion.
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
sync-new-env:
@while IFS='=' read -r key value; do \
if [ -n "$$key" ]; then \
if ! grep -q "^$$key=" .env; then \
echo "$$key=$$value" >> .env; \
fi; \
fi; \
done < .env-copy

alembic-autogenerate:
@read -p "Enter migration message: " message; \
alembic revision --autogenerate -m "$$message"

alembic-upgrade:
alembic upgrade head

init:
@make sync-new-env
@poetry install
@docker-compose build
@docker-compose up -d
@sleep 5
@make alembic-upgrade
@docker-compose exec minio sh -c "mc mb minio/$$(grep S3_BUCKET .env | cut -d '=' -f2)"
2 changes: 2 additions & 0 deletions logs/webservice-logs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2023-11-28 23:44:35,708 - INFO - App started.
2023-11-28 23:45:03,936 - INFO - App started.
58 changes: 57 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ruff = "^0.1.6"
pre-commit = "^3.5.0"
pytest = "^7.4.3"
sqlalchemy-stubs = "^0.4"
httpx = "^0.25.2"

[build-system]
requires = ["poetry-core"]
Expand Down
Empty file added src/tests/__init__.py
Empty file.
14 changes: 14 additions & 0 deletions src/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from src.tests.utils import client


def test_read_main():
response = client.get("/test")
assert response.status_code == 200
response_json = response.json()
assert response_json["result"] == "success"


def test_index():
response = client.get("/")
assert response.status_code == 200
assert b"awesome" in response.content
5 changes: 5 additions & 0 deletions src/tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from fastapi.testclient import TestClient

from src.main import app

client = TestClient(app)

0 comments on commit 1cc4b85

Please sign in to comment.