diff --git a/poetry.lock b/poetry.lock index 58a4099..aad6447 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1241,6 +1241,20 @@ pytest = ">=4.0,<8.0" docker-compose-v1 = ["docker-compose (>=1.27.3,<2.0)"] tests = ["pytest-pycodestyle (>=2.0.0,<3.0)", "pytest-pylint (>=0.14.1,<1.0)", "requests (>=2.22.0,<3.0)"] +[[package]] +name = "pytest-random-order" +version = "1.1.0" +description = "Randomise the order in which pytest tests are run with some control over the randomness" +optional = false +python-versions = ">=3.5.0" +files = [ + {file = "pytest-random-order-1.1.0.tar.gz", hash = "sha256:dbe6debb9353a7af984cc9eddbeb3577dd4dbbcc1529a79e3d21f68ed9b45605"}, + {file = "pytest_random_order-1.1.0-py3-none-any.whl", hash = "sha256:6cb1e59ab0f798bb0c3488c11ae0c70d7d3340306a466d28b28ccd8ef8c20b7e"}, +] + +[package.dependencies] +pytest = ">=3.0.0" + [[package]] name = "python-dateutil" version = "2.8.2" @@ -1863,4 +1877,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "583d7e8dd47c8b78203e6bc37f0e67d9afa536def1eb0a5931ea3598684ded68" +content-hash = "2c73550210721fa23300fe5871429d80117eab0f4836a67450f1d13778987ef4" diff --git a/pyproject.toml b/pyproject.toml index be5947f..9f57aac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,7 @@ poethepoet = "^0.21.1" pytest = "^7.4.0" pytest-asyncio = "^0.21.1" pytest-docker = "^2.0.0" +pytest-random-order = "^1.1.0" [tool.poetry.group.fastapi.dependencies] fastapi = {extras = ["all"], version = "^0.100.1"} @@ -107,7 +108,7 @@ black = "black ." black-check = "black . --check" mypy = "mypy ." ruff = "ruff check ." -test = "python -m pytest tests" +test = "python -m pytest tests --random-order" static-checks.sequence = ["ruff", "black-check", "mypy"] static-checks.ignore_fail = "return_non_zero" diff --git a/tests/test_service.py b/tests/test_service.py index d6273b6..c83dfb2 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -38,6 +38,9 @@ async def test_create(self, *, person_service: PersonService) -> None: p = Person(**result) assert isinstance(p.id, ObjectId) + delete_result = await person_service.delete_by_id(p.id) + assert delete_result.deleted_count == 1 + @pytest.mark.asyncio async def test_insert_one(self, *, person_service: PersonService) -> None: pd = PersonData(name="Jack", lucky_number=6) @@ -53,3 +56,6 @@ async def test_insert_one(self, *, person_service: PersonService) -> None: p = Person(**result) assert isinstance(p.id, ObjectId) + + delete_result = await person_service.delete_by_id(p.id) + assert delete_result.deleted_count == 1