diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-01 10:38:26 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-10-01 10:38:26 +0100 |
commit | 9b9643aa058f92b696e4c6a87a2247699b7099b3 (patch) | |
tree | e26fa662a93c56669ec2f1174f1e9c7faf68b87f /ctrack | |
parent | aafd30c1eea5a4b97b9afd99d8c55832031ce60f (diff) |
test for model function to get cafs from an applicable system
Diffstat (limited to 'ctrack')
-rw-r--r-- | ctrack/caf/models.py | 3 | ||||
-rw-r--r-- | ctrack/caf/templates/caf/applicablesystem_detail.html | 21 | ||||
-rw-r--r-- | ctrack/caf/tests/test_models.py | 10 | ||||
-rw-r--r-- | ctrack/conftest.py | 18 | ||||
-rw-r--r-- | ctrack/core/utils.py | 1 |
5 files changed, 51 insertions, 2 deletions
diff --git a/ctrack/caf/models.py b/ctrack/caf/models.py index 0027b23..3044877 100644 --- a/ctrack/caf/models.py +++ b/ctrack/caf/models.py @@ -94,6 +94,9 @@ class ApplicableSystem(models.Model): else: return org_set[0] + def get_cafs(self): + return self.caf_set.all() + def __str__(self): return self.name diff --git a/ctrack/caf/templates/caf/applicablesystem_detail.html b/ctrack/caf/templates/caf/applicablesystem_detail.html index 6aae323..719488e 100644 --- a/ctrack/caf/templates/caf/applicablesystem_detail.html +++ b/ctrack/caf/templates/caf/applicablesystem_detail.html @@ -7,7 +7,7 @@ <div class="container mt-3"> <div class="row"> - <div class="col-sm-6 pl-0 my-2"> + <div class="col-sm-12 pl-0 my-2"> <div class="row"> <h4>{{ object.name }}</h4> </div> @@ -21,7 +21,7 @@ <p>{{ object.function }}</p> </div> <div class="row"> - <div class="col-sm-6 pl-0 my-2"> + <div class="col-sm-12 pl-0 my-2"> <p>Supports Essential Services:</p> <ul class="list-group list-group-flush"> {% for s in object.essentialservice_set.all %} @@ -30,6 +30,23 @@ </ul> </div> </div> + <div class="row"> + <div class="col-sm-12 pl-0 my-2"> + <p>Described in CAFs:</p> + <table class="table table-sm"> + <thead> + <tr> + <th>CAF</th> + <th>Status</th> + </tr> + </thead> + <tbody> + <tr> + </tr> + </tbody> + </table> + </div> + </div> </div> </div> </div> diff --git a/ctrack/caf/tests/test_models.py b/ctrack/caf/tests/test_models.py new file mode 100644 index 0000000..ba54051 --- /dev/null +++ b/ctrack/caf/tests/test_models.py @@ -0,0 +1,10 @@ +import pytest + +pytestmark = pytest.mark.django_db + + +def test_can_get_cafs_from_applicable_system(caf): + version = caf.version + test_system = caf.systems.all().first() + cafs = test_system.get_cafs() + assert version in [c.version for c in cafs] diff --git a/ctrack/conftest.py b/ctrack/conftest.py index bca55ef..2296070 100644 --- a/ctrack/conftest.py +++ b/ctrack/conftest.py @@ -7,6 +7,9 @@ from django.test import RequestFactory from selenium import webdriver from selenium.webdriver.firefox.options import Options +from ctrack.caf.models import CAF +from ctrack.caf.tests.factories import GradingFactory +from ctrack.core.utils import _create_caf_app_service from ctrack.organisations.models import ( Address, AddressType, @@ -147,6 +150,21 @@ def request_factory() -> RequestFactory: @pytest.fixture +def caf(org) -> CAF: + # Quality gradings + q_descriptors = ["Q1", "Q2", "Q3", "Q4", "Q5"] + for g in q_descriptors: + GradingFactory.create(descriptor=g, type="QUALITY") + + # Confidence gradings + c_descriptors = ["C1", "C2", "C3", "C4", "C5"] + for g in c_descriptors: + GradingFactory.create(descriptor=g, type="CONFIDENCE") + caf = _create_caf_app_service(c_descriptors, org, q_descriptors) + return caf + + +@pytest.fixture def browser(request): "Provide selenium webdriver instance." os.environ["PATH"] += os.pathsep + os.getcwd() diff --git a/ctrack/core/utils.py b/ctrack/core/utils.py index af01549..3c54245 100644 --- a/ctrack/core/utils.py +++ b/ctrack/core/utils.py @@ -71,6 +71,7 @@ def _create_caf_app_service(c_descriptors, org, q_descriptors): triage_review_inspector=None, ) caf.systems.add(as1, as2) + return caf def populate_db(**kwargs): |