def test_paginating_locations(self): names = [] for i in range(12): names.append("Location #%s" % i) for n in names: Location.create(self.db, **{"name": n}) page1 = Location.paged(self.db, 1, 10) page2 = Location.paged(self.db, 2, 10) assert_equal(names[0:10], map(lambda e: e.name.encode("ascii"), page1)) assert_equal(names[10:12], map(lambda e: e.name.encode("ascii"), page2))
def show_locations(): return jsonify(map(lambda location: location.serialize(), Location.paged(db(), page_number(request))))