Fakultas Ilmu Komputer UI

Commit eff3a8df authored by Dave Nathanael's avatar Dave Nathanael
Browse files

[REFACTOR] Extract logs URL constant out on test cases

parent 17ed0537
......@@ -20,6 +20,7 @@ class AccountViewTest(APITestCase):
def setUpTestData(cls):
cls.BASE_URL = "/accounts/"
cls.PROFILE_URL = cls.BASE_URL + "me/"
cls.LOGS_URL = "/logs/"
cls.user_1 = UserFactory(username="user_1", password="justpass")
cls.user_2 = UserFactory(username="user_2", password="justpass")
......@@ -121,7 +122,7 @@ class AccountViewTest(APITestCase):
# Have account creation log for the new officer
new_officer_id = Account.objects.filter(email=_account_id)[0].id
response = self.client.get("/logs/")
response = self.client.get(self.LOGS_URL)
response_string = response.rendered_content.decode("utf-8")
self.assertIn('"object_id":"{}"'.format(new_officer_id), response_string)
......@@ -171,7 +172,7 @@ class AccountViewTest(APITestCase):
)
# Have account update log
response = self.client.get("/logs/")
response = self.client.get(self.LOGS_URL)
response_string = response.rendered_content.decode("utf-8")
self.assertIn('"object_id":"{}"'.format(self.officer.id), response_string)
......@@ -197,7 +198,7 @@ class AccountViewTest(APITestCase):
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
# Have account deletion log
response = self.client.get("/logs/")
response = self.client.get(self.LOGS_URL)
response_string = response.rendered_content.decode("utf-8")
self.assertIn('"object_id":"{}"'.format(self.officer.id), response_string)
......
......@@ -28,6 +28,7 @@ class MonitoringCaseViewTest(APITestCase):
@classmethod
def setUpTestData(cls):
cls.BASE_URL = "/cases/monitoring-cases/"
cls.LOGS_URL = "/logs/"
cls.user = UserFactory(username="user_1", password="justpass")
cls.token, _ = Token.objects.get_or_create(user=cls.user)
......@@ -104,7 +105,7 @@ class MonitoringCaseViewTest(APITestCase):
self.assertEqual(case_current_all_count, case_prev_all_count + 1)
# Have monitoring case creation log
logs_response = self.client.get("/logs/")
logs_response = self.client.get(self.LOGS_URL)
response_string = logs_response.rendered_content.decode("utf-8")
self.assertIn(
......@@ -126,7 +127,7 @@ class MonitoringCaseViewTest(APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
# Have monitoring case update log
response = self.client.get("/logs/")
response = self.client.get(self.LOGS_URL)
response_string = response.rendered_content.decode("utf-8")
self.assertIn('"object_id":"{}"'.format(self.case_1.id), response_string)
......@@ -143,7 +144,7 @@ class MonitoringCaseViewTest(APITestCase):
)
# Have monitoring case deletion log
response = self.client.get("/logs/")
response = self.client.get(self.LOGS_URL)
response_string = response.rendered_content.decode("utf-8")
self.assertIn('"object_id":"{}"'.format(self.case_1.id), response_string)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment