Exemplo n.º 1
0
def test_make_array__default():
    arr = make_array(int, has_default=True, default=[1])
    assert arr == {
        'type': 'array',
        'items': type_to_schema(int),
        'default': [1]
    }
Exemplo n.º 2
0
def test_make_array__max():
    arr = make_array(int, maximum_size=10)
    assert arr == {
        'type': 'array',
        'items': type_to_schema(int),
        'maxItems': 10
    }
Exemplo n.º 3
0
def test_type_to_schema__with_spec__list():
    class MyTypeWithSpec(TypeWithSpec):
        def get_spec(self) -> ArgList:
            return [Field('field', int, False)]

        def is_list(self):
            return True

        def list_size(self):
            return 1

    assert type_to_schema(MyTypeWithSpec(), False) == make_array(int, 1, 1)
Exemplo n.º 4
0
def test_make_array():
    arr = make_array(int)
    assert arr == {'type': 'array', 'items': type_to_schema(int)}