Skip to content

Commit

Permalink
fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
giancarloromeo committed Oct 10, 2024
1 parent cafb49f commit c141118
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions services/invitations/tests/unit/test_invitations.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
def test_all_invitation_fields_have_short_and_unique_aliases():
# all have short alias
all_alias = []
for field in _ContentWithShortNames.__fields__.values():
for field in _ContentWithShortNames.model_fields.values():
assert field.alias
assert field.alias not in all_alias
all_alias.append(field.alias)
Expand All @@ -38,7 +38,7 @@ def test_import_and_export_invitation_alias_by_alias(
invitation_data: InvitationInputs,
):
expected_content = InvitationContent(
**invitation_data.dict(),
**invitation_data.model_dump(),
created=datetime.now(tz=timezone.utc),
)
raw_data = _ContentWithShortNames.serialize(expected_content)
Expand All @@ -51,13 +51,13 @@ def test_export_by_alias_produces_smaller_strings(
invitation_data: InvitationInputs,
):
content = InvitationContent(
**invitation_data.dict(),
**invitation_data.model_dump(),
created=datetime.now(tz=timezone.utc),
)
raw_data = _ContentWithShortNames.serialize(content)

# export by alias produces smaller strings
assert len(raw_data) < len(content.json())
assert len(raw_data) < len(content.model_dump_json())


def test_create_and_decrypt_invitation(
Expand Down Expand Up @@ -85,9 +85,9 @@ def test_create_and_decrypt_invitation(
assert isinstance(invitation, InvitationContent)
assert invitation.product is not None

expected = invitation_data.dict(exclude_none=True)
expected = invitation_data.model_dump(exclude_none=True)
expected.setdefault("product", default_product)
assert invitation.dict(exclude={"created"}, exclude_none=True) == expected
assert invitation.model_dump(exclude={"created"}, exclude_none=True) == expected


#
Expand Down Expand Up @@ -116,9 +116,9 @@ def test_valid_invitation_code(
default_product=default_product,
)

expected = invitation_data.dict(exclude_none=True)
expected = invitation_data.model_dump(exclude_none=True)
expected.setdefault("product", default_product)
assert invitation.dict(exclude={"created"}, exclude_none=True) == expected
assert invitation.model_dump(exclude={"created"}, exclude_none=True) == expected


def test_invalid_invitation_encoding(
Expand Down Expand Up @@ -176,7 +176,7 @@ class OtherModel(BaseModel):

secret = secret_key.encode()
other_code = _fernet_encrypt_as_urlsafe_code(
data=OtherModel().json().encode(), secret_key=secret
data=OtherModel().model_dump_json().encode(), secret_key=secret
)

with pytest.raises(ValidationError):
Expand Down

0 comments on commit c141118

Please sign in to comment.