예제 #1
0
 def test_iter(self):
     schema = Schema()
     subfield = Field()
     topfield = Field()
     schema.sub.field = subfield
     schema.field = topfield
     items = sorted(list(schema.__iter__()), key=lambda x: x[0])
     assert items == [('field', topfield), ('sub', schema.sub)]
예제 #2
0
    def test_setattr_field(self):
        field = Field()
        field.__setkey__ = MagicMock()
        schema = Schema()
        schema.field = field

        assert field.__setkey__.called_once_with(schema, 'field')
        assert schema._fields['field'] is field
예제 #3
0
    def test_getattr(self):
        schema = Schema()
        field = Field()
        schema.field = field

        assert schema.field is field