Fakultas Ilmu Komputer UI

Commit 2639b42e authored by Dave Nathanael's avatar Dave Nathanael
Browse files

[GREEN] Add missing test for string representation and property on Cases

parent 9cd8e9b3
Pipeline #41457 passed with stages
in 8 minutes and 9 seconds
......@@ -44,6 +44,11 @@ class CaseSubjectViewTest(APITestCase):
)
self.assertEqual(case_subject_str, str(self.case_subject_1))
def test_history_string_representation(self):
history = CaseSubjectHistory.objects.all().first()
history_str = f"[History] {history.revision_id} | {history.object_id}"
self.assertEqual(history_str, str(history))
def test_list_case_subjects_success(self):
url = self.BASE_URL
......
......@@ -56,6 +56,19 @@ class InvestigationCaseViewTest(APITestCase):
)
self.assertEqual(case_subject_str, str(self.case))
def test_history_string_representation(self):
history = InvestigationCaseHistory.objects.all().first()
history_str = f"[History] {history.revision_id} | {history.object_id}"
self.assertEqual(history_str, str(history))
def test_history_have_back_reference_to_reference_case(self):
history = InvestigationCaseHistory.objects.filter(object_id=self.case.id).first()
self.assertEqual(self.reference_case.id, history.reference_case.id)
def test_history_have_back_reference_to_case_subject(self):
history = InvestigationCaseHistory.objects.filter(object_id=self.case.id).first()
self.assertEqual(self.case_subject.id, history.case_subject.id)
def test_list_investigation_cases_success(self):
url = self.BASE_URL
......
......@@ -8,7 +8,7 @@ from rest_framework.authtoken.models import Token
from rest_framework.test import APITestCase, APIClient
from apps.accounts.tests.factories.accounts import AccountFactory, UserFactory
from apps.cases.models import MonitoringCase
from apps.cases.models import MonitoringCase, MonitoringCaseHistory
from apps.cases.tests.factories.case_subjects import CaseSubjectFactory
from apps.cases.tests.factories.cases import (
InvestigationCaseFactory,
......@@ -64,6 +64,15 @@ class MonitoringCaseViewTest(APITestCase):
)
self.assertEqual(case_subject_str, str(self.case_1))
def test_history_string_representation(self):
history = MonitoringCaseHistory.objects.all().first()
history_str = f"[History] {history.revision_id} | {history.object_id}"
self.assertEqual(history_str, str(history))
def test_history_have_back_reference_to_investigation_case(self):
history = MonitoringCaseHistory.objects.filter(object_id=self.case_1.id).first()
self.assertEqual(self.positive_investigation_case.id, history.investigation_case.id)
def test_list_monitoring_cases_success(self):
url = self.BASE_URL
......
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