예제 #1
0
 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}]
예제 #2
0
 def test_to_basic_empty(self):
     field = ListField(IntField(), default=None, key='asdf')
     assert field.to_basic(MockConfig(), []) == []
예제 #3
0
 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)
예제 #4
0
 def test_to_basic_none(self):
     field = ListField(IntField(), default=None, key='asdf')
     assert field.to_basic(MockConfig(), None) is None
예제 #5
0
 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]