diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..04d2bc2 --- /dev/null +++ b/Makefile @@ -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)" diff --git a/logs/webservice-logs.txt b/logs/webservice-logs.txt new file mode 100644 index 0000000..9015c85 --- /dev/null +++ b/logs/webservice-logs.txt @@ -0,0 +1,2 @@ +2023-11-28 23:44:35,708 - INFO - App started. +2023-11-28 23:45:03,936 - INFO - App started. diff --git a/poetry.lock b/poetry.lock index f9f64dc..79364bc 100644 --- a/poetry.lock +++ b/poetry.lock @@ -103,6 +103,17 @@ urllib3 = [ [package.extras] crt = ["awscrt (==0.19.17)"] +[[package]] +name = "certifi" +version = "2023.11.17" +description = "Python package for providing Mozilla's CA Bundle." +optional = false +python-versions = ">=3.6" +files = [ + {file = "certifi-2023.11.17-py3-none-any.whl", hash = "sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474"}, + {file = "certifi-2023.11.17.tar.gz", hash = "sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1"}, +] + [[package]] name = "cfgv" version = "3.4.0" @@ -301,6 +312,51 @@ files = [ {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, ] +[[package]] +name = "httpcore" +version = "1.0.2" +description = "A minimal low-level HTTP client." +optional = false +python-versions = ">=3.8" +files = [ + {file = "httpcore-1.0.2-py3-none-any.whl", hash = "sha256:096cc05bca73b8e459a1fc3dcf585148f63e534eae4339559c9b8a8d6399acc7"}, + {file = "httpcore-1.0.2.tar.gz", hash = "sha256:9fc092e4799b26174648e54b74ed5f683132a464e95643b226e00c2ed2fa6535"}, +] + +[package.dependencies] +certifi = "*" +h11 = ">=0.13,<0.15" + +[package.extras] +asyncio = ["anyio (>=4.0,<5.0)"] +http2 = ["h2 (>=3,<5)"] +socks = ["socksio (==1.*)"] +trio = ["trio (>=0.22.0,<0.23.0)"] + +[[package]] +name = "httpx" +version = "0.25.2" +description = "The next generation HTTP client." +optional = false +python-versions = ">=3.8" +files = [ + {file = "httpx-0.25.2-py3-none-any.whl", hash = "sha256:a05d3d052d9b2dfce0e3896636467f8a5342fb2b902c819428e1ac65413ca118"}, + {file = "httpx-0.25.2.tar.gz", hash = "sha256:8b8fcaa0c8ea7b05edd69a094e63a2094c4efcb48129fb757361bc423c0ad9e8"}, +] + +[package.dependencies] +anyio = "*" +certifi = "*" +httpcore = "==1.*" +idna = "*" +sniffio = "*" + +[package.extras] +brotli = ["brotli", "brotlicffi"] +cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"] +http2 = ["h2 (>=3,<5)"] +socks = ["socksio (==1.*)"] + [[package]] name = "identify" version = "2.5.32" @@ -1196,4 +1252,4 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "77484f083bcaa85b97a7abfe6ca785ca20f65dc24023244003949de74d0b1806" +content-hash = "053c766af4299993b7e64b457a98ae199e1b43e2db8a8f9a63abd1c477fbbab7" diff --git a/pyproject.toml b/pyproject.toml index 23d08b2..771be4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] diff --git a/src/tests/__init__.py b/src/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/tests/test_main.py b/src/tests/test_main.py new file mode 100644 index 0000000..78194bc --- /dev/null +++ b/src/tests/test_main.py @@ -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 diff --git a/src/tests/utils.py b/src/tests/utils.py new file mode 100644 index 0000000..767f688 --- /dev/null +++ b/src/tests/utils.py @@ -0,0 +1,5 @@ +from fastapi.testclient import TestClient + +from src.main import app + +client = TestClient(app)