def test_get_all(self): for name in ['pumba','zazu','rafiki']: m = PersonModel(name=name, age=(10+len(name))) m.save() people = sorted(PersonModel.get_all(),key=attrgetter('age')) self.failUnlessEqual( people[0].name, 'zazu') self.failUnlessEqual( people[0].age, 14) self.failUnlessEqual( people[1].name, 'pumba') self.failUnlessEqual( people[1].age, 15) self.failUnlessEqual( people[2].name, 'rafiki') self.failUnlessEqual( people[2].age, 16) people = list(PersonModel.get_all(limit=2)) self.failUnlessEqual( len(people), 2)
def test_other_method(self): o = PersonModel(_id=3, name="Skinner", age=50) o.save() g = PersonModel.get_id(3) self.failUnlessEqual(50, g.age)
def test_simple_save(self): o1 = PersonModel(_id=0, name="Remy", age=2) o1.save() people = self._read_log() self.failUnlessEqual(2, people[0].age)