diff options
author | Matthew Lemon <matt@matthewlemon.com> | 2020-09-02 12:04:19 +0100 |
---|---|---|
committer | Matthew Lemon <matt@matthewlemon.com> | 2020-09-02 12:04:19 +0100 |
commit | edd91cb77191b386af95dfaca0b2706c7ee143b9 (patch) | |
tree | b94edf8e069911d0aea4e1acfc23a72a180cb2cf /ctrack/organisations/tests | |
parent | 15c89a78c097dc00ad7b8ca3314581ed3b058187 (diff) | |
parent | c406d3da83d20d65c2fc4da7d5d4d5db0f6ad115 (diff) |
Merge branch 'db_rewrite' into master
Diffstat (limited to '')
-rw-r--r-- | ctrack/organisations/tests/test_models.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ctrack/organisations/tests/test_models.py b/ctrack/organisations/tests/test_models.py index c6314af..108d0ce 100644 --- a/ctrack/organisations/tests/test_models.py +++ b/ctrack/organisations/tests/test_models.py @@ -1,7 +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 @@ -21,3 +28,27 @@ 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(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, + organisation=org, + confidence_grading=c1, + triage_review_date=None, + triage_review_inspector=None, + ) + 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.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()] |