def test_to_basic_schema(self): schema = Schema() schema.x = IntField(default=1) schema.y = IntField(default=2) field = ListField(schema) assert field.to_basic(MockConfig(), [schema()]) == [{'x': 1, 'y': 2}]
def test_to_basic_empty(self): field = ListField(IntField(), default=None, key='asdf') assert field.to_basic(MockConfig(), []) == []
def test_to_basic_any(self): field = ListField() value = field.to_basic(MockConfig(), [1, 2, 3]) assert value == [1, 2, 3] assert isinstance(value, list)
def test_to_basic_none(self): field = ListField(IntField(), default=None, key='asdf') assert field.to_basic(MockConfig(), None) is None
def test_to_basic(self): field = ListField(IntField(), required=True) wrap = ListProxy(MockConfig(), ListField(IntField()), [1, 2, '3']) assert field.to_basic(MockConfig(), wrap) == [1, 2, 3]