nhs_central is crown org and also we do not update org type while

updating service anymore.
This commit is contained in:
Pea Tyczynska
2019-07-16 14:56:04 +01:00
parent e4cb56b5d3
commit d89ef0594f
7 changed files with 10 additions and 36 deletions

View File

@@ -106,9 +106,6 @@ def dao_add_service_to_organisation(service, organisation_id):
db.session.add(service)
def dao_get_invited_organisation_user(user_id):
return InvitedOrganisationUser.query.filter_by(id=user_id).one()

View File

@@ -38,6 +38,7 @@ from app.models import (
TemplateRedacted,
User,
VerifyCode,
CROWN_ORGANISATION_TYPES,
EMAIL_TYPE,
INTERNATIONAL_SMS_TYPE,
KEY_TYPE_TEST,
@@ -285,6 +286,8 @@ def dao_create_service(
service.research_mode = False
if organisation:
service.crown = organisation.crown
elif service.organisation_type in CROWN_ORGANISATION_TYPES:
service.crown = True
elif service.organisation_type in (NON_CROWN_ORGANISATION_TYPES + ['nhs']):
service.crown = False
service.count_as_live = not user.platform_admin

View File

@@ -328,7 +328,9 @@ ORGANISATION_TYPES = [
"central", "local", "nhs_central",
"nhs_local", "emergency_service", "school_or_college", "other",
]
NON_CROWN_ORGANISATION_TYPES = ["local", "nhs_central", "nhs_local", "emergency_service", "school_or_college"]
CROWN_ORGANISATION_TYPES = ["nhs_central"]
NON_CROWN_ORGANISATION_TYPES = ["local", "nhs_local", "emergency_service", "school_or_college"]
class OrganisationTypes(db.Model):

View File

@@ -86,7 +86,7 @@ from app.errors import (
)
from app.letters.utils import letter_print_day
from app.models import (
KEY_TYPE_NORMAL, LETTER_TYPE, NON_CROWN_ORGANISATION_TYPES, NOTIFICATION_CANCELLED, Permission, Service,
KEY_TYPE_NORMAL, LETTER_TYPE, NOTIFICATION_CANCELLED, Permission, Service,
EmailBranding, LetterBranding
)
from app.notifications.process_notifications import persist_notification, send_notification_to_queue
@@ -224,9 +224,6 @@ def update_service(service_id):
current_data.update(request.get_json())
service = service_schema.load(current_data).data
org_type = req_json.get('organisation_type', None)
if org_type and service.organisation_type in (NON_CROWN_ORGANISATION_TYPES + ["nhs"]):
service.crown = False
if 'email_branding' in req_json:
email_branding_id = req_json['email_branding']

View File

@@ -29,7 +29,7 @@ def upgrade():
{'name': x, 'is_crown': y, 'annual_free_sms_fragment_limit': z} for x, y, z in [
["central", None, 250000],
["local", False, 25000],
["nhs_central", False, 250000],
["nhs_central", True, 250000],
["nhs_local", False, 25000],
["emergency_service", False, 25000],
["school_or_college", False, 25000],

View File

@@ -389,7 +389,7 @@ def test_get_all_user_services_should_return_empty_list_if_no_services_for_user(
@freeze_time('2019-04-23T10:00:00')
def test_dao_fetch_live_services_data(sample_user):
org = create_organisation(organisation_type='crown')
org = create_organisation(organisation_type='nhs_central')
service = create_service(go_live_user=sample_user, go_live_at='2014-04-20T10:00:00')
template = create_template(service=service)
service_2 = create_service(service_name='second', go_live_at='2017-04-20T10:00:00', go_live_user=sample_user)
@@ -427,7 +427,7 @@ def test_dao_fetch_live_services_data(sample_user):
# checks the results and that they are ordered by date:
assert results == [
{'service_id': mock.ANY, 'service_name': 'Sample service', 'organisation_name': 'test_org_1',
'organisation_type': 'crown', 'consent_to_research': None, 'contact_name': 'Test User',
'organisation_type': 'nhs_central', 'consent_to_research': None, 'contact_name': 'Test User',
'contact_email': 'notify@digital.cabinet-office.gov.uk', 'contact_mobile': '+447700900986',
'live_date': datetime(2014, 4, 20, 10, 0), 'sms_volume_intent': None, 'email_volume_intent': None,
'letter_volume_intent': None, 'sms_totals': 2, 'email_totals': 1, 'letter_totals': 1,

View File

@@ -696,31 +696,6 @@ def test_update_service_flags(client, sample_service):
assert set(result['data']['permissions']) == set([LETTER_TYPE, INTERNATIONAL_SMS_TYPE])
@pytest.mark.parametrize("org_type, expected",
[("central", None),
("local", False),
("nhs_central", False),
("nhs_local", False),
("emergency_service", False),
("school_or_college", False),
("other", None)])
def test_update_service_sets_crown_based_on_org_type(client, sample_service, org_type, expected):
sample_service.crown = None
data = {
'organisation_type': org_type,
}
auth_header = create_authorization_header()
resp = client.post(
'/service/{}'.format(sample_service.id),
data=json.dumps(data),
headers=[('Content-Type', 'application/json'), auth_header]
)
result = resp.json
assert resp.status_code == 200
assert result['data']['crown'] is expected
@pytest.mark.parametrize('field', (
'volume_email',
'volume_sms',