예제 #1
0
 def test_fields_append(self):
     doc = Document(collection='test')
     assert doc.fields == []
     doc.name = Field(default=lambda: 'alpha')
     doc.age = Field(default=lambda: 'bravo')
     assert doc.fields == ['name', 'age']
     assert doc.name == 'alpha'
     assert doc.age == 'bravo'
예제 #2
0
 def test_update(self):
     original = Document(collection='test')
     original.name = Field(value='named test')
     original.age = Field(value=12)
     cpy = original.copy()
     cpy.clear()
     cpy.update(name='bibou', age=30)
     assert cpy.name == 'bibou'
     assert original.name == 'named test'
     assert original.age == 12
     assert cpy.age == 30