"""Unit tests for the TombstoneIdentityTenant.""" from typing import Any import pytest from pdp.fastapi.schemas.identity import TombstoneIdentityTenant @pytest.mark.parametrize( "payload, expect_exception, expected", [ pytest.param({}, True, None, id="An empty payload raises an error"), pytest.param( { "identity_uuid": "TOMBSTONE:c8a9b94e-8966-4302-8615-407c4d736f87:1733337378", # noqa: E501 "tenant_type": "company_brand", "tenant_uuid": "TOMBSTONE:9b36a627-4be9-4762-b790-5628676f5f90", "roles": [], "is_tombstone": True, }, True, None, id="An object that is missing the expires_at should fail.", ), pytest.param( { "identity_uuid": "TOMBSTONE:c8a9b94e-8966-4302-8615-407c4d736f87:1733337378", # noqa: E501 "tenant_type": "company_brand", "tenant_uuid": "TOMBSTONE:9b36a627-4be9-4762-b790-5628676f5f90", "roles": [], "expires_at": 266025600, }, True, None, id="An object that is missing the is_tombstone should fail.", ), pytest.param( { "identity_uuid": "TOMBSTONE:c8a9b94e-8966-4302-8615-407c4d736f87:1733337378", # noqa: E501 "tenant_type": "company_brand", "tenant_uuid": "TOMBSTONE:9b36a627-4be9-4762-b790-5628676f5f90", "roles": [], "expires_at": 266025600, "is_tombstone": True, }, False, { "identity_uuid": "TOMBSTONE:c8a9b94e-8966-4302-8615-407c4d736f87:1733337378", # noqa: E501 "tenant_type": "company_brand", "tenant_uuid": "TOMBSTONE:9b36a627-4be9-4762-b790-5628676f5f90", "roles": [], "expires_at": 266025600, "is_tombstone": True, }, id="An object with all the tombstone and identity tenant fields is OK.", ), ], ) def test_tombstone_identity_tenant_validate( payload: Any, expect_exception: bool, expected: Any ) -> None: """Test TombstoneIdentityTenant model validation.""" if expect_exception: with pytest.raises(ValueError): TombstoneIdentityTenant.model_validate(payload) else: assert TombstoneIdentityTenant.model_validate( payload ) == TombstoneIdentityTenant(**expected)