def test_general_bulk_unauthorized(self): from ratchet.views import general_bulk post_data = { 'admintoken': 'invalid', 'data': json.dumps({ "code": "S0034-89102009000400003", "journal": "0034-8910", "issue": "0034-891020090004", "abstract.y2011.m10.d01": 100, "abstract.y2011.m10.d02": 100, "abstract.y2011.m10.d03": 100, "abstract.y2012.m11.d01": 10, "abstract.y2012.m11.a02": 10, "abstract.y2012.m11.a03": 10, "abstract.y2012.m10.total": 300, "abstract.y2012.m11.total": 30, "abstract.y2012.total": 330, "abstract.total": 330, "total": 330, "type": "article" }) } request = testing.DummyRequest(post=post_data, db=self.collection) with self.assertRaises(httpexceptions.HTTPUnauthorized): general_bulk(request)
def test_general_bulk(self): from ratchet.views import general_bulk post_data = { 'data': json.dumps({ "code": "S0034-89102009000400003", "journal": "0034-8910", "issue": "0034-891020090004", "abstract.y2011.m10.d01": 100, "abstract.y2011.m10.d02": 100, "abstract.y2011.m10.d03": 100, "abstract.y2012.m11.d01": 10, "abstract.y2012.m11.a02": 10, "abstract.y2012.m11.a03": 10, "abstract.y2012.m10.total": 300, "abstract.y2012.m11.total": 30, "abstract.y2012.total": 330, "abstract.total": 330, "total": 330, "type": "article" }) } request = testing.DummyRequest(post=post_data, db=self.collection) with self.assertRaises(httpexceptions.HTTPCreated): general_bulk(request) self.assertEqual( self.collection.find_one()['abstract']['y2011']['m10']['d01'], 100 )