Ejemplo n.º 1
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
Ejemplo n.º 2
0
 def test_copy(self):
     doc = Document(collection='test', _id='abcdef')
     doc.name = Field(value='named test', default=lambda: 'tested')
     cpy = doc.copy()
     assert doc != cpy
     assert doc.name == cpy.name
     cpy.name = None
     assert cpy.name == 'tested'
     assert doc.name == 'named test'
     assert cpy._id is None
     assert cpy.collection == doc.collection
     assert doc.raw_attr('name') != cpy.raw_attr('name')