# Path: tests/entities.py
# A = TypeVar('A')
# class DataClassWithDecimal(DataClassJsonMixin):
# class DataClassWithNewType(DataClassJsonMixin):
# class DataClassWithNestedNewType(DataClassJsonMixin):
# class DataClassWithList(DataClassJsonMixin):
# class DataClassWithListDefaultFactory(DataClassJsonMixin):
# class DataClassWithListStr(DataClassJsonMixin):
# class DataClassWithDict(DataClassJsonMixin):
# class DataClassWithDictInt(DataClassJsonMixin):
# class DataClassWithDictDefaultFactory(DataClassJsonMixin):
# class DataClassWithSet(DataClassJsonMixin):
# class DataClassWithTuple(DataClassJsonMixin):
# class DataClassWithFrozenSet(DataClassJsonMixin):
# class DataClassWithDeque(DataClassJsonMixin):
# class DataClassWithOptional(DataClassJsonMixin):
# class DataClassWithOptionalStr(DataClassJsonMixin):
# class DataClassWithOptionalNested(DataClassJsonMixin):
# class DataClassWithUnionIntNone(DataClassJsonMixin):
# class DataClassWithDataClass(DataClassJsonMixin):
# class DataClassX(DataClassJsonMixin):
# class DataClassXs(DataClassJsonMixin):
# class DataClassIntImmutableDefault(DataClassJsonMixin):
# class DataClassBoolImmutableDefault(DataClassJsonMixin):
# class DataClassMutableDefaultList(DataClassJsonMixin):
# class DataClassMutableDefaultDict(DataClassJsonMixin):
# class MyCollection(Collection[A]):
# class DataClassWithMyCollection(DataClassJsonMixin):
# class DataClassJsonDecorator:
# class DataClassWithConfigManual:
# class DataClassWithConfigHelper:
# class DataClassWithConfigDecorator:
# class DataClassWithUuid:
# class DataClassDefaultListStr:
# class DataClassChild:
# class DataClassDefaultOptionalList:
# class DataClassList:
# class DataClassOptional:
# class DataClassWithOptionalDatetime:
# class DataClassWithOptionalDecimal:
# class DataClassWithOptionalUuid:
# class DataClassWithNestedAny:
# class DataClassWithNestedOptionalAny:
# class DataClassWithNestedOptional:
# class DataClassWithNestedDictWithTupleKeys:
#     def __init__(self, xs: Collection[A]) -> None:
#     def __contains__(self, item):
#     def __iter__(self):
#     def __len__(self):
#     def __eq__(self, other):


import sys
import pytest
from datetime import datetime, timezone
from decimal import Decimal
from uuid import UUID
from tests.entities import (DataClassBoolImmutableDefault,
                            DataClassIntImmutableDefault,
                            DataClassJsonDecorator,
                            DataClassWithConfigDecorator,
                            DataClassWithConfigHelper,
                            DataClassWithConfigManual, DataClassWithDataClass,
                            DataClassWithDecimal, DataClassWithList,
                            DataClassWithNestedNewType, DataClassWithNewType,
                            DataClassWithOptional,
                            DataClassWithOptionalDatetime,
                            DataClassWithOptionalDecimal,
                            DataClassWithOptionalNested,
                            DataClassWithOptionalUuid, DataClassWithUuid, UUIDWrapper,
                            UUIDWrapperWrapper)
        d_new_type = DataClassWithNewType(id_value)

        assert DataClassWithNewType.schema().dumps(
            d_new_type) == f'{{"id": "{raw_value}"}}'

    def test_dumps_nested_new_type(self):
        raw_value = 'd1d61dd7-c036-47d3-a6ed-91cc2e885fc8'
        id_value = UUIDWrapperWrapper(UUIDWrapper(UUID(raw_value)))

        d_new_type = DataClassWithNestedNewType(id_value)

        assert DataClassWithNestedNewType.schema().dumps(
            d_new_type) == f'{{"id": "{raw_value}"}}'

    def test_loads_infer_missing(self):
        assert (DataClassWithOptional
                .schema(infer_missing=True)
                .loads('[{}]', many=True) == [DataClassWithOptional(None)])

    def test_loads_infer_missing_nested(self):
        assert (DataClassWithOptionalNested
                .schema(infer_missing=True)
                .loads('[{}]', many=True) == [
                    DataClassWithOptionalNested(None)])


class TestOverride:
    def test_override(self):
        dc = DataClassWithConfigManual(5.0)
        assert dc.to_json() == '{"id": 5.0}'

# Path: tests/entities.py
# A = TypeVar('A')
# class DataClassWithDecimal(DataClassJsonMixin):
# class DataClassWithNewType(DataClassJsonMixin):
# class DataClassWithNestedNewType(DataClassJsonMixin):
# class DataClassWithList(DataClassJsonMixin):
# class DataClassWithListDefaultFactory(DataClassJsonMixin):
# class DataClassWithListStr(DataClassJsonMixin):
# class DataClassWithDict(DataClassJsonMixin):
# class DataClassWithDictInt(DataClassJsonMixin):
# class DataClassWithDictDefaultFactory(DataClassJsonMixin):
# class DataClassWithSet(DataClassJsonMixin):
# class DataClassWithTuple(DataClassJsonMixin):
# class DataClassWithFrozenSet(DataClassJsonMixin):
# class DataClassWithDeque(DataClassJsonMixin):
# class DataClassWithOptional(DataClassJsonMixin):
# class DataClassWithOptionalStr(DataClassJsonMixin):
# class DataClassWithOptionalNested(DataClassJsonMixin):
# class DataClassWithUnionIntNone(DataClassJsonMixin):
# class DataClassWithDataClass(DataClassJsonMixin):
# class DataClassX(DataClassJsonMixin):
# class DataClassXs(DataClassJsonMixin):
# class DataClassIntImmutableDefault(DataClassJsonMixin):
# class DataClassBoolImmutableDefault(DataClassJsonMixin):
# class DataClassMutableDefaultList(DataClassJsonMixin):
# class DataClassMutableDefaultDict(DataClassJsonMixin):
# class MyCollection(Collection[A]):
# class DataClassWithMyCollection(DataClassJsonMixin):
# class DataClassJsonDecorator:
# class DataClassWithConfigManual:
# class DataClassWithConfigHelper:
# class DataClassWithConfigDecorator:
# class DataClassWithUuid:
# class DataClassDefaultListStr:
# class DataClassChild:
# class DataClassDefaultOptionalList:
# class DataClassList:
# class DataClassOptional:
# class DataClassWithOptionalDatetime:
# class DataClassWithOptionalDecimal:
# class DataClassWithOptionalUuid:
# class DataClassWithNestedAny:
# class DataClassWithNestedOptionalAny:
# class DataClassWithNestedOptional:
# class DataClassWithNestedDictWithTupleKeys:
#     def __init__(self, xs: Collection[A]) -> None:
#     def __contains__(self, item):
#     def __iter__(self):
#     def __len__(self):
#     def __eq__(self, other):


# Path: tests/test_api.py
import sys
import pytest
from datetime import datetime, timezone
from decimal import Decimal
from uuid import UUID
from tests.entities import (DataClassBoolImmutableDefault,
                            DataClassIntImmutableDefault,
                            DataClassJsonDecorator,
                            DataClassWithConfigDecorator,
                            DataClassWithConfigHelper,
                            DataClassWithConfigManual, DataClassWithDataClass,
                            DataClassWithDecimal, DataClassWithList,
                            DataClassWithNestedNewType, DataClassWithNewType,
                            DataClassWithOptional,
                            DataClassWithOptionalDatetime,
                            DataClassWithOptionalDecimal,
                            DataClassWithOptionalNested,
                            DataClassWithOptionalUuid, DataClassWithUuid, UUIDWrapper,
                            UUIDWrapperWrapper)

        d_new_type = DataClassWithNewType(id_value)

        assert DataClassWithNewType.schema().dumps(
            d_new_type) == f'{{"id": "{raw_value}"}}'

    def test_dumps_nested_new_type(self):
        raw_value = 'd1d61dd7-c036-47d3-a6ed-91cc2e885fc8'
        id_value = UUIDWrapperWrapper(UUIDWrapper(UUID(raw_value)))

        d_new_type = DataClassWithNestedNewType(id_value)

        assert DataClassWithNestedNewType.schema().dumps(
            d_new_type) == f'{{"id": "{raw_value}"}}'

    def test_loads_infer_missing(self):
        assert (DataClassWithOptional
                .schema(infer_missing=True)
                .loads('[{}]', many=True) == [DataClassWithOptional(None)])

    def test_loads_infer_missing_nested(self):
        assert (DataClassWithOptionalNested
                .schema(infer_missing=True)
                .loads('[{}]', many=True) == [
                    DataClassWithOptionalNested(None)])


class TestOverride:
    def test_override(self):
        dc = DataClassWithConfigManual(5.0)
        assert dc.to_json() == '{"id": 5.0}'

        assert DataClassWithConfigManual.schema().dumps(dc) == '{"id": 5}'