def test_order(persons): assert Person.order('age', asc=True).records() == sorted(Person.all(), key=lambda p: p.age) assert Person.order('age', desc=True).records() == sorted(Person.all(), key=lambda p: -p.age)
def test_limit_and_offset(persons): assert len(list(Person.limit(2))) == 2 assert len(list(Person.offset(4).limit(2))) == 1 records = Person.order('age').offset(1).limit(2).records() assert len(records) == 2 assert records[0].name == 'Henry' assert records[1].name == 'Henry'