| 291 | self.assertEqual([comment["id"] for comment in rv["replies"]], [5, 4, 3, 2, 1]) |
| 292 | |
| 293 | def testGetSortedByUpvotes(self): |
| 294 | for i in range(5): |
| 295 | self.post("/new?uri=test", data=json.dumps({"text": "..."})) |
| 296 | |
| 297 | # update the likes for some comments |
| 298 | self.app.db.execute("UPDATE comments SET likes = id WHERE id IN (2, 4)") |
| 299 | |
| 300 | r = self.get("/?uri=test&sort=upvotes") |
| 301 | self.assertEqual(r.status_code, 200) |
| 302 | |
| 303 | rv = loads(r.data) |
| 304 | # assert order of comments is by upvotes |
| 305 | self.assertEqual([comment["id"] for comment in rv["replies"]], [4, 2, 1, 3, 5]) |
| 306 | |
| 307 | def testGetSortedByNewestWithNested(self): |
| 308 | self.post("/new?uri=test", data=json.dumps({"text": "..."})) |