diff options
author | Matthew Lemon <y@yulqen.org> | 2024-09-09 12:34:03 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-09-09 12:39:52 +0100 |
commit | e57e4a03bbe67d3801656ceb5c2f8249dba6456d (patch) | |
tree | acb2b7efb8c4f6e1d6e8f08e3a429f2930137d57 /engagements/tests/test_models.py | |
parent | 9da1c87f0dfd5c4519334a50afc83853a32d6a88 (diff) |
Converted to pytest-style test
Diffstat (limited to '')
-rw-r--r-- | engagements/tests/test_models.py | 52 |
1 files changed, 27 insertions, 25 deletions
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 |