def test_set_missing_field(self): SimpleModel({'i1':2,'_id':'timon'}).save() ob = SimpleModel.get_id('timon') ob.int2 = 15 ob.save() ob = SimpleModel.get_id('timon') self.failUnlessEqual(ob.int2, 15)
def test_remove_field(self): self.o2._id = "nala" self.o2.int1 = 2 self.o2.int2 = 3 self.o2.save() item = SimpleModel.get_id("nala") self.failUnlessEqual( item.int2, 3) item.int2 = None item.save() result = SimpleModel.get_id("nala") self.failUnlessEqual( result.int2, None)
def test_update_object(self): #make sure that we replace objects when they are updated self.o1._id = "mustafa" self.o1.int1 = 1 self.o1.int2 = 2 self.o1.save() ob = SimpleModel.get_id("mustafa") ob.int2 = 3 ob.save() ob = SimpleModel.get_id("mustafa") self.failUnlessEqual(3, ob.int2)
def test_missing_fields(self): obj1 = SimpleModel({'_id':'simba','i1':2}) obj1.save() ob = SimpleModel.get_id('simba') self.failUnlessEqual(ob.int2, None)