def test_article_invalid_issn(self): from ratchet.views import article request = testing.DummyRequest(db=self.collection) request.matchdict.update(dict(code='xxx')) with self.assertRaises(httpexceptions.HTTPBadRequest): article(request)
def test_article(self): from ratchet.views import article, general_post post_data = {'code': 'S0104-77602014000100002', '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) request.matchdict.update(dict(code='S0104-77602014000100002')) response = article(request) self.assertEqual(response['code'], 'S0104-77602014000100002') self.assertEqual(response['total'], 1)