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)]
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
def test_getattr(self): schema = Schema() field = Field() schema.field = field assert schema.field is field