From 2e2fba89a64904c4e40efa948110db7729fa2af0 Mon Sep 17 00:00:00 2001 From: Srijan Choudhary Date: Sat, 3 May 2014 01:14:33 +0530 Subject: [PATCH] Add some tests --- isso/tests/test_comments.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/isso/tests/test_comments.py b/isso/tests/test_comments.py index 6ba8ec5..17a8b79 100644 --- a/isso/tests/test_comments.py +++ b/isso/tests/test_comments.py @@ -138,6 +138,40 @@ class TestComments(unittest.TestCase): self.assertEqual(self.get('/?uri=%2Fpath%2Fspam%2F&id=123').status_code, 404) self.assertEqual(self.get('/?uri=?uri=%foo%2F').status_code, 404) + def testGetLimited(self): + + for i in range(20): + self.post('/new?uri=test', data=json.dumps({'text': '...'})) + + r = self.get('/?uri=test&limit=10') + self.assertEqual(r.status_code, 200) + + rv = loads(r.data) + self.assertEqual(len(rv['replies']), 10) + + def testGetNested(self): + + self.post('/new?uri=test', data=json.dumps({'text': '...'})) + self.post('/new?uri=test', data=json.dumps({'text': '...', 'parent': 1})) + + r = self.get('/?uri=test&parent=1') + self.assertEqual(r.status_code, 200) + + rv = loads(r.data) + self.assertEqual(len(rv['replies']), 1) + + def testGetLimitedNested(self): + + self.post('/new?uri=test', data=json.dumps({'text': '...'})) + for i in range(20): + self.post('/new?uri=test', data=json.dumps({'text': '...', 'parent': 1})) + + r = self.get('/?uri=test&parent=1&limit=10') + self.assertEqual(r.status_code, 200) + + rv = loads(r.data) + self.assertEqual(len(rv['replies']), 10) + def testUpdate(self): self.post('/new?uri=%2Fpath%2F', data=json.dumps({'text': 'Lorem ipsum ...'}))