コード例 #1
0
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)
コード例 #2
0
def test_serializer_factory_get_dataclass_serializer():
    @dataclass
    class Data:
        foo: int
        bar: str

    factory = SerializerFactory()
    assert isinstance(factory.get_serializer(Data), DataClassSerializer)
コード例 #3
0
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)
コード例 #4
0
def test_serializer_factory_get_union_serializer():
    factory = SerializerFactory()
    assert isinstance(factory.get_serializer(Union[int, str]), UnionSerializer)
コード例 #5
0
def test_serializer_factory_get_optional_serializer():
    factory = SerializerFactory()
    assert isinstance(factory.get_serializer(Optional[int]),
                      OptionalSerializer)
コード例 #6
0
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)
コード例 #7
0
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)
コード例 #8
0
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)
コード例 #9
0
def test_serializer_factory_get_string_serializer():
    factory = SerializerFactory()
    assert isinstance(factory.get_serializer(str), StringSerializer)
コード例 #10
0
def test_serializer_factory_get_default_serializer():
    factory = SerializerFactory()
    assert isinstance(factory.get_serializer(int), DefaultSerializer)
コード例 #11
0
def test_serializer_factory_get_serializer_class():
    factory = SerializerFactory()
    assert factory.get_serializer_class(int) is DefaultSerializer
コード例 #12
0
def test_serializer_factory_create_serializer():
    factory = SerializerFactory()
    assert isinstance(factory.create_serializer(DefaultSerializer),
                      DefaultSerializer)
コード例 #13
0
def test_serializer_factory_get_decimal_serializer():
    factory = SerializerFactory()
    assert isinstance(factory.get_serializer(Decimal), DecimalSerializer)
コード例 #14
0
def test_serializer_factory_get_timestamp_serializer():
    factory = SerializerFactory()
    assert isinstance(factory.get_serializer(datetime.timestamp),
                      TimestampSerializer)
コード例 #15
0
def test_serializer_factory_get_time_serializer():
    factory = SerializerFactory()
    assert isinstance(factory.get_serializer(time), TimeSerializer)
コード例 #16
0
def test_serializer_factory_get_date_serializer():
    factory = SerializerFactory()
    assert isinstance(factory.get_serializer(date), DateSerializer)