From 7c91861bb0636edff048a9fa0a0f6c2708efc274 Mon Sep 17 00:00:00 2001 From: Jaden Diefenbaugh <blakcap@users.noreply.github.com> Date: Wed, 19 Apr 2017 15:27:13 +0200 Subject: [PATCH] fixed django tests to reflect report model changes --- beat/web/reports/tests.py | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/beat/web/reports/tests.py b/beat/web/reports/tests.py index e9edac72e..b21349ff6 100644 --- a/beat/web/reports/tests.py +++ b/beat/web/reports/tests.py @@ -860,7 +860,7 @@ class ReportCreationTestCase(ReportTestCase): self.experiment_analyzer1.fullname(), ], "content": {}, - "analyzer": self.analyzer1.fullname() + "analyzer": None } self.client.login(username=self.johndoe.username, password=self.password) @@ -888,7 +888,7 @@ class ReportCreationTestCase(ReportTestCase): self.experiment_two_analyzers.fullname(), ], "content": {}, - "analyzer": self.analyzer1.fullname() + "analyzer": None } self.client.login(username=self.johndoe.username, password=self.password) @@ -909,21 +909,19 @@ class ReportCreationTestCase(ReportTestCase): self.experiment_analyzer2.fullname(), ], "content": {}, - "analyzer": self.analyzer1.fullname() + "analyzer": None } self.client.login(username=self.johndoe.username, password=self.password) response = self.client.post(self.url, data, format='json') - self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertTrue(len(response.content) > 0) def test_logged_in_user__one_experiment__two_analyzers(self): expected_answer = { - 'common_analyzers': [ - self.analyzer1.fullname(), - self.analyzer2.fullname(), - ] + 'name': 'johndoe/report_new', + 'url': '/api/v1/reports/johndoe/report_new/' } data = { @@ -934,13 +932,13 @@ class ReportCreationTestCase(ReportTestCase): self.experiment_two_analyzers.fullname(), ], "content": {}, - "analyzer": self.analyzer1.fullname() + "analyzer": None } self.client.login(username=self.johndoe.username, password=self.password) response = self.client.post(self.url, data, format='json') - self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(json.loads(response.content), expected_answer) @@ -1026,7 +1024,7 @@ class LockedReportRetrievalTestCase(ReportTestCase): self.experiment_analyzer1.fullname(), ], "content": {}, - "analyzer": self.report.analyzer.fullname() + "analyzer": None } self.client.login(username=self.johndoe.username, password=self.password) @@ -1072,7 +1070,7 @@ class PublishedReportRetrievalTestCase(ReportTestCase): self.experiment_analyzer1.fullname(), ], "content": {}, - "analyzer": self.report.analyzer.fullname() + "analyzer": None } response = self.client.get(self.url, format='json') @@ -1095,7 +1093,7 @@ class PublishedReportRetrievalTestCase(ReportTestCase): self.experiment_analyzer1.fullname(), ], "content": {}, - "analyzer": self.report.analyzer.fullname() + "analyzer": None } self.client.login(username=self.johndoe.username, password=self.password) @@ -1120,7 +1118,7 @@ class PublishedReportRetrievalTestCase(ReportTestCase): self.experiment_analyzer1.fullname(), ], "content": {}, - "analyzer": self.report.analyzer.fullname() + "analyzer": None } self.client.login(username=self.jackdoe.username, password=self.password) @@ -1769,8 +1767,8 @@ class EditableReportAddExperimentsTestCase(ReportTestCase): self.client.login(username=self.johndoe.username, password=self.password) response = self.client.post(self.url, data, format='json') - self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) - self.assertTrue(len(response.content) > 0) + self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) + self.assertTrue('content' not in response) def test_logged_in_user__one_experiment__two_analyzers(self): expected_answer = { @@ -1789,8 +1787,8 @@ class EditableReportAddExperimentsTestCase(ReportTestCase): self.client.login(username=self.johndoe.username, password=self.password) response = self.client.post(self.url, data, format='json') - self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) - self.assertEqual(json.loads(response.content), expected_answer) + self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) + self.assertTrue('content' not in response) def test_logged_in_user__compatible_experiment_addition(self): data = { @@ -1812,6 +1810,7 @@ class EditableReportAddExperimentsTestCase(ReportTestCase): response = self.client.post(self.url, data, format='json') self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) + self.assertTrue('content' not in response) def test_logged_in_user__incompatible_experiment_addition(self): @@ -1839,8 +1838,8 @@ class EditableReportAddExperimentsTestCase(ReportTestCase): } response = self.client.post(self.url, data, format='json') - self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(json.loads(response.content), expected_answer) + self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) + self.assertTrue('content' not in response) def test_with_unknown_experiments(self): -- GitLab