From 6f4ea7ef9018e2e1df396f16aa4080dcee3ef6df Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 26 Aug 2020 13:40:13 +0100 Subject: started the rebuild --- ctrack/organisations/tests/test_models.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ctrack/organisations/tests') diff --git a/ctrack/organisations/tests/test_models.py b/ctrack/organisations/tests/test_models.py index c6314af..8287e97 100644 --- a/ctrack/organisations/tests/test_models.py +++ b/ctrack/organisations/tests/test_models.py @@ -2,6 +2,7 @@ import pytest from slugify import slugify from ctrack.organisations.models import IncidentReport, Organisation +from ctrack.caf.models import EssentialService pytestmark = pytest.mark.django_db @@ -21,3 +22,8 @@ def test_update_organisation(org_with_people): def test_new_address(addr): # The address "has" an organisation assert addr.organisation.name + + +def test_essential_service(): + es = EssentialService() + assert es -- cgit v1.2.3 From bc556144060dcbbf1d89279b9c5f3d54fa271b6b Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 26 Aug 2020 15:00:09 +0100 Subject: first passing test - making essential service an object --- ctrack/organisations/tests/test_models.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'ctrack/organisations/tests') diff --git a/ctrack/organisations/tests/test_models.py b/ctrack/organisations/tests/test_models.py index 8287e97..09d4f12 100644 --- a/ctrack/organisations/tests/test_models.py +++ b/ctrack/organisations/tests/test_models.py @@ -1,8 +1,14 @@ +import random + import pytest + from slugify import slugify from ctrack.organisations.models import IncidentReport, Organisation +from ctrack.caf.models import CAF, Grading +from ctrack.caf.tests.factories import ApplicableSystemFactory from ctrack.caf.models import EssentialService +from ctrack.core.utils import fnames pytestmark = pytest.mark.django_db @@ -24,6 +30,22 @@ def test_new_address(addr): assert addr.organisation.name -def test_essential_service(): - es = EssentialService() - assert es +def test_essential_service(org): + q1 = Grading.objects.create(descriptor="Q1", description="baws", type="QUALITY") + c1 = Grading.objects.create( + descriptor="C1", description="baws_c", type="CONFIDENCE" + ) + caf = CAF.objects.create( + quality_grading=q1, + confidence_grading=c1, + triage_review_date=None, + triage_review_inspector=None, + ) + ass = ApplicableSystemFactory.create( + name=random.choice(fnames), organisation=org, caf=caf, + ) + es = EssentialService.objects.create( + name="Test ES", description="Test ES Description", organisation=org + ) + es.systems.add(ass) + assert es.systems.first().organisation.name == org.name -- cgit v1.2.3 From 36759e44bc59747256332809097342a32ab6db19 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 26 Aug 2020 15:23:37 +0100 Subject: further asserts added to the test --- ctrack/organisations/tests/test_models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'ctrack/organisations/tests') diff --git a/ctrack/organisations/tests/test_models.py b/ctrack/organisations/tests/test_models.py index 09d4f12..103ead4 100644 --- a/ctrack/organisations/tests/test_models.py +++ b/ctrack/organisations/tests/test_models.py @@ -44,8 +44,14 @@ def test_essential_service(org): ass = ApplicableSystemFactory.create( name=random.choice(fnames), organisation=org, caf=caf, ) + ass2 = ApplicableSystemFactory.create( + name=random.choice(fnames), organisation=org, caf=caf, + ) es = EssentialService.objects.create( name="Test ES", description="Test ES Description", organisation=org ) - es.systems.add(ass) + es.systems.add(ass, ass2) assert es.systems.first().organisation.name == org.name + assert es.name == "Test ES" + assert es.systems.count() == 2 + assert ass.name in [s.name for s in org.systems()] -- cgit v1.2.3 From c27cfbc3cb2eb15eed0e1012f5bb8a537d6d9d5e Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Fri, 28 Aug 2020 11:46:15 +0100 Subject: fixed a failing new test (essential service) --- ctrack/organisations/tests/test_models.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'ctrack/organisations/tests') diff --git a/ctrack/organisations/tests/test_models.py b/ctrack/organisations/tests/test_models.py index 103ead4..108d0ce 100644 --- a/ctrack/organisations/tests/test_models.py +++ b/ctrack/organisations/tests/test_models.py @@ -37,21 +37,18 @@ def test_essential_service(org): ) caf = CAF.objects.create( quality_grading=q1, + organisation=org, confidence_grading=c1, triage_review_date=None, triage_review_inspector=None, ) - ass = ApplicableSystemFactory.create( - name=random.choice(fnames), organisation=org, caf=caf, - ) - ass2 = ApplicableSystemFactory.create( - name=random.choice(fnames), organisation=org, caf=caf, - ) + ass = ApplicableSystemFactory.create(name=random.choice(fnames), caf=caf,) + ass2 = ApplicableSystemFactory.create(name=random.choice(fnames), caf=caf,) es = EssentialService.objects.create( name="Test ES", description="Test ES Description", organisation=org ) es.systems.add(ass, ass2) - assert es.systems.first().organisation.name == org.name + assert es.organisation.name == org.name assert es.name == "Test ES" assert es.systems.count() == 2 assert ass.name in [s.name for s in org.systems()] -- cgit v1.2.3