diff options
author | Yulqen <246857+yulqen@users.noreply.github.com> | 2024-09-10 15:58:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-10 15:58:55 +0100 |
commit | dcfe6d87098bbe064d2db268f0972865c3d412bf (patch) | |
tree | 2b82df07a5290f80f25e9780596cbce0f128454f /engagements/tests/test_models.py | |
parent | 7ddc22b821f405546786977225e7b194a19b2b77 (diff) | |
parent | 15b2dc965bfe2271d73476fcf9ff636c60113908 (diff) |
Merge pull request #106 from defencedigital/postgres-migration
Adds new Engagement Strategy stuff
Diffstat (limited to 'engagements/tests/test_models.py')
-rw-r--r-- | engagements/tests/test_models.py | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/engagements/tests/test_models.py b/engagements/tests/test_models.py index 08c5169..70ae31a 100644 --- a/engagements/tests/test_models.py +++ b/engagements/tests/test_models.py @@ -1,30 +1,45 @@ import pytest -from django.test import TestCase +from engagements.models import EngagementStrategy, RegulatoryCycle from engagements.utils import populate_database +pytestmark = pytest.mark.django_db -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 + +@pytest.fixture +def data(): + return populate_database() + + +def test_check_all_dcs(data): + dscs = data.get("sub_instruments") + assert dscs[0].title == "DSC 1 - Title 1" + + +def test_effort_by_type(data): + e = 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 + + +@pytest.mark.skip(reason="Not implemented until I get my head round effort calculations") +def test_total_effort_for_engagement(data): + e = data["engagements"][0] + assert e.total_effort() == 5.25 + + +def test_regulatory_cycle_model(regulatory_cycles): + rc = RegulatoryCycle.objects.first() + rc2023 = RegulatoryCycle.objects.get(start_date="2023-01-01") + assert str(rc) == "Regulatory Cycle: 2024" + assert str(rc2023) == "Regulatory Cycle: 2023" + + +def test_engagement_strategy_model(engagement_strategy): + es1 = EngagementStrategy.objects.first() + assert es1.organisation.name == "MOD" + assert str(es1) == "Engagement Strategy (2022-2024) - MOD" |