From 8d2bb08c91dc9ab0623a5c60fa5d8f4c5c9f6e4e Mon Sep 17 00:00:00 2001 From: Anton Bagrianov Date: Thu, 16 Nov 2023 19:57:42 +0400 Subject: [PATCH] Fix tests --- Makefile | 4 ++-- poetry.lock | 20 ++++++++++++++++++- pyproject.toml | 1 + tests/{ => integrations}/__init__.py | 0 tests/integrations/test_main.py | 2 ++ .../test_app/__init__.py} | 0 tests/units/test_app/test_main.py | 5 +++++ 7 files changed, 29 insertions(+), 3 deletions(-) rename tests/{ => integrations}/__init__.py (100%) create mode 100644 tests/integrations/test_main.py rename tests/{conftest.py => units/test_app/__init__.py} (100%) create mode 100644 tests/units/test_app/test_main.py diff --git a/Makefile b/Makefile index 0c92c8c..e88b2e9 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ help: ## Display this help screen .PHONY: help install: ## Install project dependencies - poetry install --no-interaction --no-ansi + poetry install --no-interaction --no-ansi --no-root .PHONY: install format: ## Format the source code @@ -42,7 +42,7 @@ compose-down: ## Stop the development Django server with docker-compose tests-units: ## Run unit tests poetry run coverage run -m pytest -s ./tests/units - poetry run coverage report --precision=2 -m + poetry run coverage report --precision=2 --fail-under=75 .PHONY: tests-units tests-integrations: ## Run integration tests diff --git a/poetry.lock b/poetry.lock index 7d8c3bf..4b014b2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -449,6 +449,24 @@ pluggy = ">=0.12,<2.0" [package.extras] testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +[[package]] +name = "pytest-asyncio" +version = "0.21.1" +description = "Pytest support for asyncio" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-asyncio-0.21.1.tar.gz", hash = "sha256:40a7eae6dded22c7b604986855ea48400ab15b069ae38116e8c01238e9eeb64d"}, + {file = "pytest_asyncio-0.21.1-py3-none-any.whl", hash = "sha256:8666c1c8ac02631d7c51ba282e0c69a8a452b211ffedf2599099845da5c5c37b"}, +] + +[package.dependencies] +pytest = ">=7.0.0" + +[package.extras] +docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] +testing = ["coverage (>=6.2)", "flaky (>=3.5.0)", "hypothesis (>=5.7.1)", "mypy (>=0.931)", "pytest-trio (>=0.7.0)"] + [[package]] name = "pytest-cov" version = "4.1.0" @@ -583,4 +601,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.12.0" -content-hash = "1fc3d68ffac246726795fa47ab4f3e05125b36d40055b69ae9f97d053b466fee" +content-hash = "2efc1d70a70f0d157d137d1db9fa733c4fbd3298cba6b7066a29b06c1f5f53c2" diff --git a/pyproject.toml b/pyproject.toml index 25c4b6e..ef8f134 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ mypy = "1.7.0" bandit = {extras = ["toml"], version = "1.7.5"} pytest-cov = "^4.1.0" coverage = "^7.3.2" +pytest-asyncio = "^0.21.1" [tool.black] line-length = 100 diff --git a/tests/__init__.py b/tests/integrations/__init__.py similarity index 100% rename from tests/__init__.py rename to tests/integrations/__init__.py diff --git a/tests/integrations/test_main.py b/tests/integrations/test_main.py new file mode 100644 index 0000000..cee3998 --- /dev/null +++ b/tests/integrations/test_main.py @@ -0,0 +1,2 @@ +def test_integration_app() -> None: + assert True diff --git a/tests/conftest.py b/tests/units/test_app/__init__.py similarity index 100% rename from tests/conftest.py rename to tests/units/test_app/__init__.py diff --git a/tests/units/test_app/test_main.py b/tests/units/test_app/test_main.py new file mode 100644 index 0000000..adff095 --- /dev/null +++ b/tests/units/test_app/test_main.py @@ -0,0 +1,5 @@ +from app.main import main + + +def test_main() -> None: + main()