MCPcopy
hub / github.com/isso-comments/isso / testGetSortedByUpvotes

Method testGetSortedByUpvotes

isso/tests/test_comments.py:293–305  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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": "..."}))

Callers

nothing calls this directly

Calls 4

loadsFunction · 0.90
dumpsMethod · 0.80
executeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected