def test_articles_offset_exceeded_gt(self): from ratchet.views import articles, general_post post_data = {'code': 'S0104-77602014000100002', 'page': 'html', 'type': 'article', 'access_date': '2014-12-25'} request = testing.DummyRequest(post=post_data, db=self.collection) try: general_post(request) except: pass post_data = {'code': 'S0100-07602014000100002', 'page': 'abstract', 'type': 'article', 'access_date': '2014-12-25'} request = testing.DummyRequest(post=post_data, db=self.collection) try: general_post(request) except: pass request = testing.DummyRequest(params={'offset': 3}, db=self.collection) with self.assertRaises(httpexceptions.HTTPBadRequest): response = articles(request)
def test_articles(self): from ratchet.views import articles, general_post post_data = {'code': 'S0104-77602014000100002', 'page': 'html', 'type': 'article', 'access_date': '2014-12-25'} request = testing.DummyRequest(post=post_data, db=self.collection) try: general_post(request) except: pass post_data = {'code': 'S0100-07602014000100002', 'page': 'abstract', 'type': 'article', 'access_date': '2014-12-25'} request = testing.DummyRequest(post=post_data, db=self.collection) try: general_post(request) except: pass request = testing.DummyRequest(db=self.collection) response = articles(request) self.assertEqual(len(response['objects']), 2)