def testClearHistograms(self): generateTestFile(self.account_id) headers = [ {'file_name': "test1.csv", 'header_name': 'a', 'owner_id': self.account_id}, {'file_name': "test1.csv", 'header_name': 'b', 'owner_id': self.account_id}, ] new = self.sampleData(headers, title=self.title) createResp = self.client.post('/api/compute', data=json.dumps(new), content_type='application/json') self.client.post('/api/compute/clear') get_histogram = hg.get_user_histograms(self.account_id) self.assertEqual(get_histogram, [])
def testGetUserHistograms(self): generateTestFile(self.account_id) headers = [ {'file_name': "test1.csv", 'header_name': 'a', 'owner_id': self.account_id}, ] new = self.sampleData(headers, title=self.title) resp = self.client.post('/api/compute', data=json.dumps(new), content_type='application/json') resultData = hg.get_user_histograms(self.account_id)[0] self.assertEqual(resultData['title'], 'HISTOGRAM TEST TITLE') self.assertEqual(resultData['values'], [4,0,0]) self.assertEqual(resultData['edges'], [1,2,3,4])
def testRemoveUserHistogram(self): # Create histograms generateTestFile(self.account_id) headers = [ {'file_name': "test1.csv", 'header_name': 'a', 'owner_id': self.account_id}, {'file_name': "test1.csv", 'header_name': 'b', 'owner_id': self.account_id}, ] new = self.sampleData(headers, title=self.title) createResp = self.client.post('/api/compute', data=json.dumps(new), content_type='application/json') deleteData = { 'type': 'histogram', 'id': self.account_id } deleteResp = self.client.post('/api/compute/delete', data=json.dumps(deleteData), content_type='application/json') delete_response = json.loads(deleteResp.content) self.assertEqual(delete_response, {"foo": "bar"}) # Then check if it is any list. get_histogram = hg.get_user_histograms(self.account_id) self.assertEqual(get_histogram, [])