From c032ef215a5a622dedd3d02336711e85da0239c3 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 5 Sep 2019 16:04:14 +0100 Subject: [PATCH] Return org_type in list of all organisations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will let us do some filtering of this list in the admin. It’s better to do it there because it means the admin can use the same cached response from Redis each time. --- app/models.py | 1 + tests/app/organisation/test_rest.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index 60d683980..62c8c36c1 100644 --- a/app/models.py +++ b/app/models.py @@ -427,6 +427,7 @@ class Organisation(db.Model): 'active': self.active, 'count_of_live_services': len(self.live_services), 'domains': self.domain_list, + 'organisation_type': self.organisation_type, } diff --git a/tests/app/organisation/test_rest.py b/tests/app/organisation/test_rest.py index 633f8338f..38df2b986 100644 --- a/tests/app/organisation/test_rest.py +++ b/tests/app/organisation/test_rest.py @@ -15,7 +15,7 @@ from tests.app.db import ( def test_get_all_organisations(admin_request, notify_db_session): - create_organisation(name='inactive org', active=False) + create_organisation(name='inactive org', active=False, organisation_type='nhs_central') create_organisation(name='active org', domains=['example.com']) response = admin_request.get( @@ -24,14 +24,24 @@ def test_get_all_organisations(admin_request, notify_db_session): ) assert len(response) == 2 + assert set(response[0].keys()) == set(response[1].keys()) == { + 'name', + 'id', + 'active', + 'count_of_live_services', + 'domains', + 'organisation_type', + } assert response[0]['name'] == 'active org' assert response[0]['active'] is True assert response[0]['count_of_live_services'] == 0 assert response[0]['domains'] == ['example.com'] + assert response[0]['organisation_type'] is None assert response[1]['name'] == 'inactive org' assert response[1]['active'] is False assert response[1]['count_of_live_services'] == 0 assert response[1]['domains'] == [] + assert response[1]['organisation_type'] == 'nhs_central' def test_get_organisation_by_id(admin_request, notify_db_session):