summaryrefslogtreecommitdiffstats
path: root/engagements/tests/test_models.py
diff options
context:
space:
mode:
authorYulqen <246857+yulqen@users.noreply.github.com>2024-04-23 11:22:21 +0100
committerGitHub <noreply@github.com>2024-04-23 11:22:21 +0100
commitceca6fa956b21c43263e53c328d619c4ede21914 (patch)
treea48384210cdc168e3bd3ccff6d6d516eeed9e748 /engagements/tests/test_models.py
parent8b084e9fe7a5f3a04c32daf9a24f7f2cf67300f9 (diff)
parent0f951dcf029d4af284467543a3afdf5bf6581a20 (diff)
Merge pull request #22 from defencedigital/pyswitch
switched to Django
Diffstat (limited to '')
-rw-r--r--engagements/tests/test_models.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/engagements/tests/test_models.py b/engagements/tests/test_models.py
new file mode 100644
index 0000000..08c5169
--- /dev/null
+++ b/engagements/tests/test_models.py
@@ -0,0 +1,30 @@
+import pytest
+from django.test import TestCase
+
+from engagements.utils import populate_database
+
+
+class TestModels(TestCase):
+ @classmethod
+ def setUpTestData(cls):
+ cls.data = populate_database()
+
+ @pytest.mark.django_db
+ def test_check_all_dcs(self):
+ dscs = self.data.get("sub_instruments")
+ self.assertEqual(dscs[0].title, "DSC 1 - Title 1")
+
+ @pytest.mark.django_db
+ def test_effort_by_type(self):
+ e = self.data["engagements"][0]
+ total_planning = sum([x.effort_total_planned_hours() for x in e.effort.filter(effort_type="PLANNING")])
+ total_travel = sum([x.effort_total_planned_hours() for x in e.effort.filter(effort_type="TRAVEL")])
+ total_regulation = sum([x.effort_total_planned_hours() for x in e.effort.filter(effort_type="REGULATION")])
+ assert total_planning == 4.25
+ assert total_regulation == 0
+ assert total_travel == 1
+
+ # TODO finish this test!
+ def test_total_effort_for_engagement(self):
+ e = self.data["engagements"][0]
+ assert e.total_effort() == 5.25