def test_serializer_factory_get_literal_serializer(): from typing import Literal from jsondataclass.serializers import LiteralSerializer factory = SerializerFactory() assert isinstance(factory.get_serializer(Literal[True]), LiteralSerializer)
def test_serializer_factory_get_dataclass_serializer(): @dataclass class Data: foo: int bar: str factory = SerializerFactory() assert isinstance(factory.get_serializer(Data), DataClassSerializer)
def test_serializer_factory_get_enum_serializer(): class Foo(Enum): A = 1 B = 2 factory = SerializerFactory() assert isinstance(factory.get_serializer(Enum), EnumSerializer) assert isinstance(factory.get_serializer(Foo), EnumSerializer)
def test_serializer_factory_get_union_serializer(): factory = SerializerFactory() assert isinstance(factory.get_serializer(Union[int, str]), UnionSerializer)
def test_serializer_factory_get_optional_serializer(): factory = SerializerFactory() assert isinstance(factory.get_serializer(Optional[int]), OptionalSerializer)
def test_serializer_factory_get_dict_serializer(): factory = SerializerFactory() assert isinstance(factory.get_serializer(dict), DictSerializer) assert isinstance(factory.get_serializer(Dict), DictSerializer) assert isinstance(factory.get_serializer(Dict[str, int]), DictSerializer)
def test_serializer_factory_get_tuple_serializer(): factory = SerializerFactory() assert isinstance(factory.get_serializer(tuple), TupleSerializer) assert isinstance(factory.get_serializer(Tuple), TupleSerializer) assert isinstance(factory.get_serializer(Tuple[int, ...]), TupleSerializer)
def test_serializer_factory_get_list_serializer(): factory = SerializerFactory() assert isinstance(factory.get_serializer(list), ListSerializer) assert isinstance(factory.get_serializer(List), ListSerializer) assert isinstance(factory.get_serializer(List[int]), ListSerializer)
def test_serializer_factory_get_string_serializer(): factory = SerializerFactory() assert isinstance(factory.get_serializer(str), StringSerializer)
def test_serializer_factory_get_default_serializer(): factory = SerializerFactory() assert isinstance(factory.get_serializer(int), DefaultSerializer)
def test_serializer_factory_get_serializer_class(): factory = SerializerFactory() assert factory.get_serializer_class(int) is DefaultSerializer
def test_serializer_factory_create_serializer(): factory = SerializerFactory() assert isinstance(factory.create_serializer(DefaultSerializer), DefaultSerializer)
def test_serializer_factory_get_decimal_serializer(): factory = SerializerFactory() assert isinstance(factory.get_serializer(Decimal), DecimalSerializer)
def test_serializer_factory_get_timestamp_serializer(): factory = SerializerFactory() assert isinstance(factory.get_serializer(datetime.timestamp), TimestampSerializer)
def test_serializer_factory_get_time_serializer(): factory = SerializerFactory() assert isinstance(factory.get_serializer(time), TimeSerializer)
def test_serializer_factory_get_date_serializer(): factory = SerializerFactory() assert isinstance(factory.get_serializer(date), DateSerializer)