def testGiveAccess(self): # self.createPanePlot() Access.give_access(self.account_id_one, self.account_id_two, PermissionsTest.FILE_NAME) # Then check retrieval. shared_doc = Document.select_shared_files(self.account_id_two)[0] # User 2 has none result = LR.get_user_regressions(self.account_id_two) self.assertEqual(shared_doc.file_name, PermissionsTest.FILE_NAME) self.assertEqual(shared_doc.account_id, self.account_id_one) self.assertEqual(result, [])
def testClearRegress(self): generateTestFileRegrssion(self.account_id) headers_x = [ {'file_name': "test1.csv", 'header_name': 'a', 'owner_id': self.account_id}, ] headers_y = [ {'file_name': "test1.csv", 'header_name': 'b', 'owner_id': self.account_id}, ] inputData = self.createPlotData(headers_x, headers_y) self.client.post('/api/compute', data=json.dumps(inputData), content_type='application/json') self.client.post('/api/compute/clear') after_delete_get = LR.get_user_regressions(self.account_id) self.assertEqual(after_delete_get, [])
def testGetUserRegreess(self): generateTestFileRegrssion(self.account_id) headers_x = [ {'file_name': "test1.csv", 'header_name': 'a', 'owner_id': self.account_id}, ] headers_y = [ {'file_name': "test1.csv", 'header_name': 'b', 'owner_id': self.account_id}, ] inputData = self.createPlotData(headers_x, headers_y) self.client.post('/api/compute', data=json.dumps(inputData), content_type='application/json') results = LR.get_user_regressions(self.account_id)[0] plot_results = results['plot'] self.assertEqual(results['title'], 'REGRESSION DATA') self.assertEqual(plot_results['x_points'], [1,2,3,4])
def testRemoveUserRegress(self): generateTestFileRegrssion(self.account_id) headers_x = [ {'file_name': "test1.csv", 'header_name': 'a', 'owner_id': self.account_id}, ] headers_y = [ {'file_name': "test1.csv", 'header_name': 'b', 'owner_id': self.account_id}, ] inputData = self.createPlotData(headers_x, headers_y) self.client.post('/api/compute', data=json.dumps(inputData), content_type='application/json') delete_input = { 'type': 'regression', 'id': self.account_id } delete_request = self.client.post('/api/compute/delete', data=json.dumps(delete_input), content_type='application/json') resp = json.loads(delete_request.content) self.assertEqual(resp, {"foo": "bar"}) after_delete_get = LR.get_user_regressions(self.account_id) self.assertEqual(after_delete_get, [])