def test_api(self): request = self.factory.get(self.api_url, {}) request.user = self.user response = api(request, self.user.username, self.xform.id_string) self.assertEqual(response.status_code, 200) d = dict_for_mongo_without_userform_id( self.xform.instances.all()[0].parsed_instance) find_d = json.loads(response.content)[0] self.assertEqual(find_d, d)
def test_api(self): request = self.factory.get(self.api_url, {}) request.user = self.user response = api(request, self.user.username, self.xform.id_string) self.assertEqual(response.status_code, 200) data = self.xform.instances.all()[0].json find_d = json.loads(response.content)[0] # ensure all strings are unicode data = json.loads(json.dumps(data)) self.assertEqual(find_d, data)
def test_api_column_select(self): # query string query = '{"transport/available_transportation_types_to_referral_facil'\ 'ity":"none"}' columns = '["transport/available_transportation_types_to_referral_fac'\ 'ility"]' data = {'query': query, 'fields': columns} request = self.factory.get(self.api_url, data) request.user = self.user response = api(request, self.user.username, self.xform.id_string) self.assertEqual(response.status_code, 200) find_d = json.loads(response.content)[0] self.assertTrue( 'transport/available_transportation_types_to_referral_facility' in find_d) self.assertFalse('_attachments' in find_d)