Skip to content

Commit

Permalink
tests: test model_dump
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk committed May 24, 2024
1 parent 61399c0 commit 493c352
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ def test_minimal_user(minimal_user_payload):
== "https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646"
)

assert (
obj.model_dump(
exclude_none=True, exclude_unset=True, by_alias=True, mode="json"
)
== minimal_user_payload
)


def test_full_user(full_user_payload):
obj = User.model_validate(full_user_payload)
Expand Down Expand Up @@ -149,6 +156,13 @@ def test_full_user(full_user_payload):
== "https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646"
)

assert (
obj.model_dump(
exclude_none=True, exclude_unset=True, by_alias=True, mode="json"
)
== full_user_payload
)


@pytest.mark.skip
def test_enterprise_user(full_enterprise_payload): ...
Expand Down Expand Up @@ -183,6 +197,13 @@ def test_group(group_payload):
== "https://example.com/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a"
)

assert (
obj.model_dump(
exclude_none=True, exclude_unset=True, by_alias=True, mode="json"
)
== group_payload
)


def test_service_provider_configuration(service_provider_configuration_payload):
obj = ServiceProviderConfiguration.model_validate(
Expand Down Expand Up @@ -240,6 +261,13 @@ def test_service_provider_configuration(service_provider_configuration_payload):
)
assert obj.meta.version == 'W\\/"3694e05e9dff594"'

assert (
obj.model_dump(
exclude_none=True, exclude_unset=True, by_alias=True, mode="json"
)
== service_provider_configuration_payload
)


def test_resource_type(resource_type_payload):
obj = ResourceType.model_validate(resource_type_payload[0])
Expand All @@ -257,6 +285,13 @@ def test_resource_type(resource_type_payload):
assert obj.meta.location == "https://example.com/v2/ResourceTypes/User"
assert obj.meta.resourceType == "ResourceType"

assert (
obj.model_dump(
exclude_none=True, exclude_unset=True, by_alias=True, mode="json"
)
== resource_type_payload[0]
)

obj = ResourceType.model_validate(resource_type_payload[1])
assert obj.schemas == ["urn:ietf:params:scim:schemas:core:2.0:ResourceType"]
assert obj.id == "Group"
Expand All @@ -267,10 +302,30 @@ def test_resource_type(resource_type_payload):
assert obj.meta.location == "https://example.com/v2/ResourceTypes/Group"
assert obj.meta.resourceType == "ResourceType"

assert (
obj.model_dump(
exclude_none=True, exclude_unset=True, by_alias=True, mode="json"
)
== resource_type_payload[1]
)


def test_schema(resource_schema_payload):
obj = Schema.model_validate(resource_schema_payload[0])
assert (
obj.model_dump(
exclude_none=True, exclude_unset=True, by_alias=True, mode="json"
)
== resource_schema_payload[0]
)

obj = Schema.model_validate(resource_schema_payload[1])
assert (
obj.model_dump(
exclude_none=True, exclude_unset=True, by_alias=True, mode="json"
)
== resource_schema_payload[1]
)

assert obj.id == "urn:ietf:params:scim:schemas:core:2.0:Group"
assert obj.name == "Group"
Expand Down Expand Up @@ -334,3 +389,9 @@ def test_schema(resource_schema_payload):
obj.meta.location == "/v2/Schemas/urn:ietf:params:scim:schemas:core:2.0:Group"
)
obj = Schema.model_validate(resource_schema_payload[2])
assert (
obj.model_dump(
exclude_none=True, exclude_unset=True, by_alias=True, mode="json"
)
== resource_schema_payload[2]
)

0 comments on commit 493c352

Please sign in to comment.