From 9da1c87f0dfd5c4519334a50afc83853a32d6a88 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Mon, 9 Sep 2024 11:36:58 +0100 Subject: Skips test for now --- engagements/tests/test_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engagements/tests/test_models.py') diff --git a/engagements/tests/test_models.py b/engagements/tests/test_models.py index 08c5169..f5afbb8 100644 --- a/engagements/tests/test_models.py +++ b/engagements/tests/test_models.py @@ -24,7 +24,7 @@ class TestModels(TestCase): assert total_regulation == 0 assert total_travel == 1 - # TODO finish this test! + @pytest.mark.skip(reason="Not implemented until I get my head round effort calculations") def test_total_effort_for_engagement(self): e = self.data["engagements"][0] assert e.total_effort() == 5.25 -- cgit v1.2.3 From e57e4a03bbe67d3801656ceb5c2f8249dba6456d Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Mon, 9 Sep 2024 12:34:03 +0100 Subject: Converted to pytest-style test --- engagements/tests/test_models.py | 52 +++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'engagements/tests/test_models.py') diff --git a/engagements/tests/test_models.py b/engagements/tests/test_models.py index f5afbb8..73738db 100644 --- a/engagements/tests/test_models.py +++ b/engagements/tests/test_models.py @@ -1,30 +1,32 @@ 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 - - @pytest.mark.skip(reason="Not implemented until I get my head round effort calculations") - def test_total_effort_for_engagement(self): - e = self.data["engagements"][0] - assert e.total_effort() == 5.25 +@pytest.fixture +@pytest.mark.django_db +def data(): + return populate_database() + + +@pytest.mark.django_db +def test_check_all_dcs(data): + dscs = data.get("sub_instruments") + assert dscs[0].title == "DSC 1 - Title 1" + + +@pytest.mark.django_db +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 -- cgit v1.2.3 From 86c02670efcb1a219acff44fd8b5b723ac30bfa0 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 10 Sep 2024 11:13:15 +0100 Subject: Removes marks on fixtures to handle deprecation warning --- engagements/tests/test_models.py | 1 - 1 file changed, 1 deletion(-) (limited to 'engagements/tests/test_models.py') diff --git a/engagements/tests/test_models.py b/engagements/tests/test_models.py index 73738db..9b15307 100644 --- a/engagements/tests/test_models.py +++ b/engagements/tests/test_models.py @@ -4,7 +4,6 @@ from engagements.utils import populate_database @pytest.fixture -@pytest.mark.django_db def data(): return populate_database() -- cgit v1.2.3 From f96b5ba4052c28d2bd2c03cefba3a2e828dd059d Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 10 Sep 2024 11:14:43 +0100 Subject: Finish the job of the last commit --- engagements/tests/test_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engagements/tests/test_models.py') diff --git a/engagements/tests/test_models.py b/engagements/tests/test_models.py index 9b15307..3b84ead 100644 --- a/engagements/tests/test_models.py +++ b/engagements/tests/test_models.py @@ -2,19 +2,19 @@ import pytest from engagements.utils import populate_database +pytestmark = pytest.mark.django_db + @pytest.fixture def data(): return populate_database() -@pytest.mark.django_db def test_check_all_dcs(data): dscs = data.get("sub_instruments") assert dscs[0].title == "DSC 1 - Title 1" -@pytest.mark.django_db 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")]) -- cgit v1.2.3 From 5fb0621c53967bf24f4411f579712223e96b296a Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 10 Sep 2024 12:11:12 +0100 Subject: Adds RegulatoryCycle model --- engagements/tests/test_models.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engagements/tests/test_models.py') diff --git a/engagements/tests/test_models.py b/engagements/tests/test_models.py index 3b84ead..d7aa458 100644 --- a/engagements/tests/test_models.py +++ b/engagements/tests/test_models.py @@ -1,6 +1,7 @@ import pytest from engagements.utils import populate_database +from engagements.models import RegulatoryCycle pytestmark = pytest.mark.django_db @@ -29,3 +30,14 @@ def test_effort_by_type(data): 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(data): +# assert EngagementStrategy.objects.first() -- cgit v1.2.3 From c4fd33fce3dbef280657c150a7658462c80da877 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 10 Sep 2024 12:34:49 +0100 Subject: wip: implementing EngagementStrategy --- engagements/tests/test_models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engagements/tests/test_models.py') diff --git a/engagements/tests/test_models.py b/engagements/tests/test_models.py index d7aa458..426d728 100644 --- a/engagements/tests/test_models.py +++ b/engagements/tests/test_models.py @@ -1,7 +1,7 @@ import pytest from engagements.utils import populate_database -from engagements.models import RegulatoryCycle +from engagements.models import RegulatoryCycle, EngagementStrategy pytestmark = pytest.mark.django_db @@ -39,5 +39,5 @@ def test_regulatory_cycle_model(regulatory_cycles): assert str(rc2023) == "Regulatory Cycle: 2023" -# def test_engagement_strategy_model(data): -# assert EngagementStrategy.objects.first() +def test_engagement_strategy_model(engagement_strategy): + assert EngagementStrategy.objects.first() -- cgit v1.2.3 From 15eceda8c762c3e3890f2c160d1c89c36a7b398b Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 10 Sep 2024 14:08:35 +0100 Subject: ES basically done --- engagements/tests/test_models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engagements/tests/test_models.py') diff --git a/engagements/tests/test_models.py b/engagements/tests/test_models.py index 426d728..70ae31a 100644 --- a/engagements/tests/test_models.py +++ b/engagements/tests/test_models.py @@ -1,7 +1,7 @@ import pytest +from engagements.models import EngagementStrategy, RegulatoryCycle from engagements.utils import populate_database -from engagements.models import RegulatoryCycle, EngagementStrategy pytestmark = pytest.mark.django_db @@ -40,4 +40,6 @@ def test_regulatory_cycle_model(regulatory_cycles): def test_engagement_strategy_model(engagement_strategy): - assert EngagementStrategy.objects.first() + es1 = EngagementStrategy.objects.first() + assert es1.organisation.name == "MOD" + assert str(es1) == "Engagement Strategy (2022-2024) - MOD" -- cgit v1.2.3