# 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.feature_flags.models import FeatureFlag, FeatureFlagOwner, Flag, FlagOwner


class TestModelRoundTrip:
    def test_flag_round_trip(self):
        data = load_fixture("flag.json")
        instance = Flag.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = Flag.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_flag_minimal_payload(self):
        data = {
            "object": "feature_flag",
            "id": "flag_01EHZNVPK3SFK441A1RGBFSHRT",
            "slug": "advanced-analytics",
            "name": "Advanced Analytics",
            "description": None,
            "owner": None,
            "tags": ["reports"],
            "enabled": True,
            "default_value": False,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = Flag.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["slug"] == data["slug"]
        assert serialized["name"] == data["name"]
        assert serialized["description"] == data["description"]
        assert serialized["owner"] == data["owner"]
        assert serialized["tags"] == data["tags"]
        assert serialized["enabled"] == data["enabled"]
        assert serialized["default_value"] == data["default_value"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_flag_preserves_nullable_fields(self):
        data = {
            "object": "feature_flag",
            "id": "flag_01EHZNVPK3SFK441A1RGBFSHRT",
            "slug": "advanced-analytics",
            "name": "Advanced Analytics",
            "description": None,
            "owner": None,
            "tags": ["reports"],
            "enabled": True,
            "default_value": False,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = Flag.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["description"] is None
        assert serialized["owner"] is None

    def test_flag_owner_round_trip(self):
        data = load_fixture("flag_owner.json")
        instance = FlagOwner.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = FlagOwner.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_flag_owner_minimal_payload(self):
        data = {"email": "jane@example.com", "first_name": None, "last_name": None}
        instance = FlagOwner.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["email"] == data["email"]
        assert serialized["first_name"] == data["first_name"]
        assert serialized["last_name"] == data["last_name"]

    def test_flag_owner_preserves_nullable_fields(self):
        data = {"email": "jane@example.com", "first_name": None, "last_name": None}
        instance = FlagOwner.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["first_name"] is None
        assert serialized["last_name"] is None

    def test_feature_flag_round_trip(self):
        data = load_fixture("feature_flag.json")
        instance = FeatureFlag.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = FeatureFlag.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_feature_flag_minimal_payload(self):
        data = {
            "object": "feature_flag",
            "id": "flag_01EHZNVPK3SFK441A1RGBFSHRT",
            "slug": "advanced-analytics",
            "name": "Advanced Analytics",
            "description": None,
            "owner": None,
            "tags": ["reports"],
            "enabled": False,
            "default_value": False,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = FeatureFlag.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["object"] == data["object"]
        assert serialized["id"] == data["id"]
        assert serialized["slug"] == data["slug"]
        assert serialized["name"] == data["name"]
        assert serialized["description"] == data["description"]
        assert serialized["owner"] == data["owner"]
        assert serialized["tags"] == data["tags"]
        assert serialized["enabled"] == data["enabled"]
        assert serialized["default_value"] == data["default_value"]
        assert serialized["created_at"] == data["created_at"]
        assert serialized["updated_at"] == data["updated_at"]

    def test_feature_flag_preserves_nullable_fields(self):
        data = {
            "object": "feature_flag",
            "id": "flag_01EHZNVPK3SFK441A1RGBFSHRT",
            "slug": "advanced-analytics",
            "name": "Advanced Analytics",
            "description": None,
            "owner": None,
            "tags": ["reports"],
            "enabled": False,
            "default_value": False,
            "created_at": "2026-01-15T12:00:00.000Z",
            "updated_at": "2026-01-15T12:00:00.000Z",
        }
        instance = FeatureFlag.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["description"] is None
        assert serialized["owner"] is None

    def test_feature_flag_owner_round_trip(self):
        data = load_fixture("feature_flag_owner.json")
        instance = FeatureFlagOwner.from_dict(data)
        serialized = instance.to_dict()
        assert serialized == data
        restored = FeatureFlagOwner.from_dict(serialized)
        assert restored.to_dict() == serialized

    def test_feature_flag_owner_minimal_payload(self):
        data = {"email": "jane@example.com", "first_name": None, "last_name": None}
        instance = FeatureFlagOwner.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["email"] == data["email"]
        assert serialized["first_name"] == data["first_name"]
        assert serialized["last_name"] == data["last_name"]

    def test_feature_flag_owner_preserves_nullable_fields(self):
        data = {"email": "jane@example.com", "first_name": None, "last_name": None}
        instance = FeatureFlagOwner.from_dict(data)
        serialized = instance.to_dict()
        assert serialized["first_name"] is None
        assert serialized["last_name"] is None
