# Path: tests/entities.py
# class DataClassWithDataClass(DataClassJsonMixin):
#     dc_with_list: DataClassWithList
# 
# class DataClassWithList(DataClassJsonMixin):
#     xs: List[int]
# 
# class DataClassWithNestedDictWithTupleKeys:
#     a: Dict[Tuple[int], int]
# 
# class DataClassX(DataClassJsonMixin):
#     x: int
# 
# class DataClassXs(DataClassJsonMixin):
#     xs: List[DataClassX]


from tests.entities import (DataClassWithDataClass,
                            DataClassWithList,
                            DataClassWithNestedDictWithTupleKeys,
                            DataClassX,
                            DataClassXs)


class TestEncoder:
    def test_nested_dataclass(self):
        assert (DataClassWithDataClass(DataClassWithList([1])).to_json() ==
                '{"dc_with_list": {"xs": [1]}}')

    def test_nested_list_of_dataclasses(self):
        assert (DataClassXs([DataClassX(0), DataClassX(1)]).to_json() ==
                '{"xs": [{"x": 0}, {"x": 1}]}')


class TestDecoder:
    def test_nested_dataclass(self):
        assert (DataClassWithDataClass.from_json(
            '{"dc_with_list": {"xs": [1]}}') ==

# Path: tests/entities.py
# class DataClassWithDataClass(DataClassJsonMixin):
#     dc_with_list: DataClassWithList
# 
# class DataClassWithList(DataClassJsonMixin):
#     xs: List[int]
# 
# class DataClassWithNestedDictWithTupleKeys:
#     a: Dict[Tuple[int], int]
# 
# class DataClassX(DataClassJsonMixin):
#     x: int
# 
# class DataClassXs(DataClassJsonMixin):
#     xs: List[DataClassX]


# Path: tests/test_nested.py
from tests.entities import (DataClassWithDataClass,
                            DataClassWithList,
                            DataClassWithNestedDictWithTupleKeys,
                            DataClassX,
                            DataClassXs)



class TestEncoder:
    def test_nested_dataclass(self):
        assert (DataClassWithDataClass(DataClassWithList([1])).to_json() ==
                '{"dc_with_list": {"xs": [1]}}')

    def test_nested_list_of_dataclasses(self):
        assert (DataClassXs([DataClassX(0), DataClassX(1)]).to_json() ==
                '{"xs": [{"x": 0}, {"x": 1}]}')


class TestDecoder:
    def test_nested_dataclass(self):
        assert (DataClassWithDataClass.from_json(
            '{"dc_with_list": {"xs": [1]}}') ==

                DataClassWithDataClass(DataClassWithList([1])))