Skip to content

Commit

Permalink
test and validator
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsung-Ju Lii committed Aug 23, 2023
1 parent 762a7d7 commit a1c24ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def test_creation(

{%- if cookiecutter.orm == "beanie" %}
instance = await DummyModel.find(DummyModel.name == test_name).first_or_none()
assert instance.name == test_name
assert instance is not None and instance.name == test_name
{%- else %}
instances = await dao.filter(name=test_name)
assert instances[0].name == test_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ class DummyModelDTO(BaseModel):
id: int
{%- else %}
id: str
{%- endif %}
name: str

{%- if cookiecutter.db_info.name == "mongodb" %}
@field_validator("id", mode="before")
@classmethod
def parse_object_id(cls, document_id: ObjectId) -> str:
Expand All @@ -31,7 +34,6 @@ def parse_object_id(cls, document_id: ObjectId) -> str:
"""
return str(document_id)
{%- endif %}
name: str


{%- if cookiecutter.pydanticv1 == "True" %}
Expand Down

0 comments on commit a1c24ba

Please sign in to comment.