Exemplo n.º 1
0
def test_serialize_union_type(fx_point, fx_offset, fx_circle_type,
                              fx_rectangle_type):
    circle = fx_circle_type(fx_point, fx_offset)
    s = {
        '_type': 'shape', '_tag': 'circle',
        'origin': serialize_record_type(fx_point),
        'radius': serialize_unboxed_type(fx_offset)
    }
    assert serialize_union_type(circle) == s
    rectangle = fx_rectangle_type(fx_point, fx_point)
    s = {
        '_type': 'shape', '_tag': 'rectangle',
        'upper_left': serialize_record_type(fx_point),
        'lower_right': serialize_record_type(fx_point),
    }
    assert serialize_union_type(rectangle) == s
Exemplo n.º 2
0
def test_serialize_unboxed_type(fx_offset, fx_token_type):
    assert serialize_unboxed_type(fx_offset) == fx_offset.value
    token = uuid.uuid4()
    assert serialize_unboxed_type(fx_token_type(token)) == str(token)
Exemplo n.º 3
0
 def __nirum_serialize__(self):
     return serialize_unboxed_type(self)
Exemplo n.º 4
0
 def __nirum_serialize__(self) -> typing.Mapping[str, typing.Any]:
     return serialize_unboxed_type(self)