Skip to content

Commit

Permalink
Refactor test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
bkis committed Dec 27, 2023
1 parent 5b6236d commit 909a698
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions Tekst-API/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,16 @@ async def test_client(test_app, config) -> AsyncClient:
yield client


@pytest.fixture
async def reset_db(get_db_client_override, config):
for collection in ("texts", "nodes", "resources", "units", "users"):
await get_db_client_override[config.db_name][collection].delete_many({})


@pytest.fixture(autouse=True)
async def run_before_and_after_tests(reset_db):
async def run_before_and_after_each_test_case(get_db_client_override, config):
"""Fixture to execute asserts before and after a test is run"""
# before test
# ...
yield # test
# after test
### before test case
# clear DB collections
for collection in ("texts", "nodes", "resources", "units", "users"):
await get_db_client_override[config.db_name][collection].delete_many({})
### run test case
yield # test case running now
### after test cae
# ...


Expand Down

0 comments on commit 909a698

Please sign in to comment.