# This file is auto-generated by oagen. Do not edit.

"""Model round-trip tests: from_dict(to_dict()) preserves data."""

from tests.generated_helpers import load_fixture

from workos.agents.models import (
    AgentAdminLinkClaimAttemptToExternalUserRequestUser,
    AgentCredentialValidation,
    AgentRegistration,
    AgentRegistrationAgentIdentity,
    AgentRegistrationClaim,
    AgentRegistrationClaimClaimCompletion,
    ClaimViewResponse,
    ClaimViewResponseOrganization,
)


class TestModelRoundTrip:
    def test_agent_registration_round_trip(self):
        data = load_fixture("agent_registration.json")
        instance = AgentRegistration.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AgentRegistration.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_agent_registration_minimal_payload(self):
        data = {
            "id": "agent_reg_01EHWNCE74X7JSDV0X3SZ3KJNY",
            "agent_identity": {
                "id": "agent_identity_01EHWNCE74X7JSDV0X3SZ3KJNY",
                "userland_user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            },
            "organization_id": "org_01EHQMYV6MBK39QC5PZXHY59C3",
            "status": "verified",
            "kind": "service_auth",
            "claim": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AgentRegistration.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["id"] == data["id"]
        assert serialized["agent_identity"] == data["agent_identity"]
        assert serialized["organization_id"] == data["organization_id"]
        assert serialized["status"] == data["status"]
        assert serialized["kind"] == data["kind"]
        assert serialized["claim"] == data["claim"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_agent_registration_preserves_nullable_fields(self):
        data = {
            "id": "agent_reg_01EHWNCE74X7JSDV0X3SZ3KJNY",
            "agent_identity": {
                "id": "agent_identity_01EHWNCE74X7JSDV0X3SZ3KJNY",
                "userland_user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            },
            "organization_id": "org_01EHQMYV6MBK39QC5PZXHY59C3",
            "status": "verified",
            "kind": "service_auth",
            "claim": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AgentRegistration.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["claim"] is None

    def test_agent_registration_round_trips_unknown_enum_values(self):
        data = {
            "id": "agent_reg_01EHWNCE74X7JSDV0X3SZ3KJNY",
            "agent_identity": {
                "id": "agent_identity_01EHWNCE74X7JSDV0X3SZ3KJNY",
                "userland_user_id": "user_01E4ZCR3C56J083X43JQXF3JK5",
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
            },
            "organization_id": "org_01EHQMYV6MBK39QC5PZXHY59C3",
            "status": "unexpected_agent_registration_status",
            "kind": "service_auth",
            "claim": {
                "id": "agent_reg_claim_01EHWNCE74X7JSDV0X3SZ3KJNY",
                "claim_completion": {
                    "id": "agent_reg_claim_attempt_01EHWNCE74X7JSDV0X3SZ3KJNY",
                    "created_at": "2026-01-15T12:00:00.000Z",
                    "updated_at": "2026-01-15T12:00:00.000Z",
                    "expires_at": "2026-01-15T12:00:00.000Z",
                    "claimed_at": "2026-01-15T12:00:00.000Z",
                },
                "created_at": "2026-01-15T12:00:00.000Z",
                "updated_at": "2026-01-15T12:00:00.000Z",
                "expires_at": "2026-01-15T12:00:00.000Z",
            },
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AgentRegistration.from_dict(data)
        assert instance.to_dict() == data

    def test_agent_credential_validation_round_trip(self):
        data = load_fixture("agent_credential_validation.json")
        instance = AgentCredentialValidation.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AgentCredentialValidation.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_agent_credential_validation_minimal_payload(self):
        data = {"valid": True, "registration_id": None, "expires_at": None}
        instance = AgentCredentialValidation.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["valid"] == data["valid"]
        assert serialized["registration_id"] == data["registration_id"]
        assert serialized["expires_at"] == data["expires_at"]

    def test_agent_credential_validation_preserves_nullable_fields(self):
        data = {"valid": True, "registration_id": None, "expires_at": None}
        instance = AgentCredentialValidation.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["registration_id"] is None
        assert serialized["expires_at"] is None

    def test_claim_view_response_round_trip(self):
        data = load_fixture("claim_view_response.json")
        instance = ClaimViewResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = ClaimViewResponse.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_claim_view_response_minimal_payload(self):
        data = {
            "id": "agent_reg_01EHWNCE74X7JSDV0X3SZ3KJNY",
            "status": "unverified",
            "user_code": "BCDF-GHJK",
            "organizations": [
                {"id": "org_01EHWNCE74X7JSDV0X3SZ3KJNY", "name": "Acme Corp"}
            ],
        }
        instance = ClaimViewResponse.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["id"] == data["id"]
        assert serialized["status"] == data["status"]
        assert serialized["user_code"] == data["user_code"]
        assert serialized["organizations"] == data["organizations"]

    def test_claim_view_response_round_trips_unknown_enum_values(self):
        data = {
            "id": "agent_reg_01EHWNCE74X7JSDV0X3SZ3KJNY",
            "status": "unexpected_claim_view_response_status",
            "user_code": "BCDF-GHJK",
            "organizations": [
                {"id": "org_01EHWNCE74X7JSDV0X3SZ3KJNY", "name": "Acme Corp"}
            ],
        }
        instance = ClaimViewResponse.from_dict(data)
        assert instance.to_dict() == data

    def test_claim_view_response_organization_round_trip(self):
        data = load_fixture("claim_view_response_organization.json")
        instance = ClaimViewResponseOrganization.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = ClaimViewResponseOrganization.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_claim_view_response_organization_minimal_payload(self):
        data = {"id": "org_01EHWNCE74X7JSDV0X3SZ3KJNY", "name": "Acme Corp"}
        instance = ClaimViewResponseOrganization.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["id"] == data["id"]
        assert serialized["name"] == data["name"]

    def test_agent_registration_agent_identity_round_trip(self):
        data = load_fixture("agent_registration_agent_identity.json")
        instance = AgentRegistrationAgentIdentity.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AgentRegistrationAgentIdentity.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_agent_registration_agent_identity_minimal_payload(self):
        data = {
            "id": "agent_identity_01EHWNCE74X7JSDV0X3SZ3KJNY",
            "userland_user_id": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AgentRegistrationAgentIdentity.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["id"] == data["id"]
        assert serialized["userland_user_id"] == data["userland_user_id"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_agent_registration_agent_identity_preserves_nullable_fields(self):
        data = {
            "id": "agent_identity_01EHWNCE74X7JSDV0X3SZ3KJNY",
            "userland_user_id": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AgentRegistrationAgentIdentity.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["userland_user_id"] is None

    def test_agent_registration_claim_round_trip(self):
        data = load_fixture("agent_registration_claim.json")
        instance = AgentRegistrationClaim.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AgentRegistrationClaim.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_agent_registration_claim_minimal_payload(self):
        data = {
            "id": "agent_reg_claim_01EHWNCE74X7JSDV0X3SZ3KJNY",
            "claim_completion": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "expires_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AgentRegistrationClaim.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["id"] == data["id"]
        assert serialized["claim_completion"] == data["claim_completion"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]
        assert serialized["expires_at"] == data["expires_at"]

    def test_agent_registration_claim_preserves_nullable_fields(self):
        data = {
            "id": "agent_reg_claim_01EHWNCE74X7JSDV0X3SZ3KJNY",
            "claim_completion": None,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "expires_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AgentRegistrationClaim.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["claim_completion"] is None

    def test_agent_admin_link_claim_attempt_to_external_user_request_user_round_trip(
        self,
    ):
        data = load_fixture(
            "agent_admin_link_claim_attempt_to_external_user_request_user.json"
        )
        instance = AgentAdminLinkClaimAttemptToExternalUserRequestUser.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AgentAdminLinkClaimAttemptToExternalUserRequestUser.from_dict(
            serialized
        )
        assert restored.to_dict() == serialized

    def test_agent_admin_link_claim_attempt_to_external_user_request_user_minimal_payload(
        self,
    ):
        data = {"email": "alice@example.com", "external_id": "user_abc123"}
        instance = AgentAdminLinkClaimAttemptToExternalUserRequestUser.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["email"] == data["email"]
        assert serialized["external_id"] == data["external_id"]

    def test_agent_registration_claim_claim_completion_round_trip(self):
        data = load_fixture("agent_registration_claim_claim_completion.json")
        instance = AgentRegistrationClaimClaimCompletion.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = AgentRegistrationClaimClaimCompletion.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_agent_registration_claim_claim_completion_minimal_payload(self):
        data = {
            "id": "agent_reg_claim_attempt_01EHWNCE74X7JSDV0X3SZ3KJNY",
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
            "expires_at": "2026-01-15T12:00:00.000Z",
            "claimed_at": "2026-01-15T12:00:00.000Z",
        }
        instance = AgentRegistrationClaimClaimCompletion.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["id"] == data["id"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]
        assert serialized["expires_at"] == data["expires_at"]
        assert serialized["claimed_at"] == data["claimed_at"]
