Skip to content

Commit

Permalink
fix all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
usefulalgorithm committed Oct 21, 2023
1 parent b5f288f commit cfef8de
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,19 @@ async def filter(
if name is None:
return []
return await DummyModel.find(DummyModel.name == name).to_list()

async def delete_dummy_model_by_name(
self,
name: str,
) -> Optional[DummyModel]:
"""
Delete a dummy model by name.
:param name: name of dummy instance.
:return: option of a dummy model.
"""
res = await DummyModel.find_one(DummyModel.name == name)
if res is None:
return res
await res.delete()
return res
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
"""{{cookiecutter.project_name}} models."""

{%- if cookiecutter.add_dummy == "True" %}
from {{cookiecutter.project_name}}.db.models.dummy_model import DummyModel
{%- endif %}


def load_all_models(): # type: ignore
"""Load all models from this folder.""" # noqa: DAR201
return [
{%- if cookiecutter.add_dummy == "True" %}
DummyModel, # type: ignore
{%- endif %}
]
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ async def test_creation(
instances = await dao.filter(name=test_name)
assert instances[0].name == test_name

{%- if cookiecutter.orm == "beanie" %}
# Clean up the object we just inserted
await dao.delete_dummy_model_by_name(name=test_name)
{%- endif %}


@pytest.mark.anyio
async def test_getting(
Expand Down

0 comments on commit cfef8de

Please sign in to comment.