mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 10:28:55 -04:00
update tests
This commit is contained in:
@@ -65,7 +65,7 @@ def test_update_organisation(notify_db_session):
|
|||||||
data = {
|
data = {
|
||||||
'name': 'new name',
|
'name': 'new name',
|
||||||
"crown": True,
|
"crown": True,
|
||||||
"organisation_type": 'local',
|
"organisation_type": 'state',
|
||||||
"agreement_signed": True,
|
"agreement_signed": True,
|
||||||
"agreement_signed_at": datetime.datetime.utcnow(),
|
"agreement_signed_at": datetime.datetime.utcnow(),
|
||||||
"agreement_signed_by_id": user.id,
|
"agreement_signed_by_id": user.id,
|
||||||
@@ -124,8 +124,8 @@ def test_update_organisation_does_not_update_the_service_if_certain_attributes_n
|
|||||||
email_branding = create_email_branding()
|
email_branding = create_email_branding()
|
||||||
letter_branding = create_letter_branding()
|
letter_branding = create_letter_branding()
|
||||||
|
|
||||||
sample_service.organisation_type = 'local'
|
sample_service.organisation_type = 'state'
|
||||||
sample_organisation.organisation_type = 'central'
|
sample_organisation.organisation_type = 'federal'
|
||||||
sample_organisation.email_branding = email_branding
|
sample_organisation.email_branding = email_branding
|
||||||
sample_organisation.letter_branding = letter_branding
|
sample_organisation.letter_branding = letter_branding
|
||||||
|
|
||||||
@@ -138,8 +138,8 @@ def test_update_organisation_does_not_update_the_service_if_certain_attributes_n
|
|||||||
|
|
||||||
assert sample_organisation.name == 'updated org name'
|
assert sample_organisation.name == 'updated org name'
|
||||||
|
|
||||||
assert sample_organisation.organisation_type == 'central'
|
assert sample_organisation.organisation_type == 'federal'
|
||||||
assert sample_service.organisation_type == 'local'
|
assert sample_service.organisation_type == 'state'
|
||||||
|
|
||||||
assert sample_organisation.email_branding == email_branding
|
assert sample_organisation.email_branding == email_branding
|
||||||
assert sample_service.email_branding is None
|
assert sample_service.email_branding is None
|
||||||
@@ -152,20 +152,20 @@ def test_update_organisation_updates_the_service_org_type_if_org_type_is_provide
|
|||||||
sample_service,
|
sample_service,
|
||||||
sample_organisation,
|
sample_organisation,
|
||||||
):
|
):
|
||||||
sample_service.organisation_type = 'local'
|
sample_service.organisation_type = 'state'
|
||||||
sample_organisation.organisation_type = 'local'
|
sample_organisation.organisation_type = 'state'
|
||||||
|
|
||||||
sample_organisation.services.append(sample_service)
|
sample_organisation.services.append(sample_service)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
dao_update_organisation(sample_organisation.id, organisation_type='central')
|
dao_update_organisation(sample_organisation.id, organisation_type='federal')
|
||||||
|
|
||||||
assert sample_organisation.organisation_type == 'central'
|
assert sample_organisation.organisation_type == 'federal'
|
||||||
assert sample_service.organisation_type == 'central'
|
assert sample_service.organisation_type == 'federal'
|
||||||
assert Service.get_history_model().query.filter_by(
|
assert Service.get_history_model().query.filter_by(
|
||||||
id=sample_service.id,
|
id=sample_service.id,
|
||||||
version=2
|
version=2
|
||||||
).one().organisation_type == 'central'
|
).one().organisation_type == 'federal'
|
||||||
|
|
||||||
|
|
||||||
def test_update_organisation_updates_the_service_branding_if_branding_is_provided(
|
def test_update_organisation_updates_the_service_branding_if_branding_is_provided(
|
||||||
@@ -228,8 +228,8 @@ def test_update_organisation_updates_services_with_new_crown_type(
|
|||||||
def test_add_service_to_organisation(sample_service, sample_organisation):
|
def test_add_service_to_organisation(sample_service, sample_organisation):
|
||||||
assert sample_organisation.services == []
|
assert sample_organisation.services == []
|
||||||
|
|
||||||
sample_service.organisation_type = "central"
|
sample_service.organisation_type = "federal"
|
||||||
sample_organisation.organisation_type = "local"
|
sample_organisation.organisation_type = "state"
|
||||||
sample_organisation.crown = False
|
sample_organisation.crown = False
|
||||||
|
|
||||||
dao_add_service_to_organisation(sample_service, sample_organisation.id)
|
dao_add_service_to_organisation(sample_service, sample_organisation.id)
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ def test_create_service(notify_db_session):
|
|||||||
email_from="email_from",
|
email_from="email_from",
|
||||||
message_limit=1000,
|
message_limit=1000,
|
||||||
restricted=False,
|
restricted=False,
|
||||||
organisation_type='central',
|
organisation_type='federal',
|
||||||
created_by=user)
|
created_by=user)
|
||||||
dao_create_service(service, user)
|
dao_create_service(service, user)
|
||||||
assert Service.query.count() == 1
|
assert Service.query.count() == 1
|
||||||
@@ -110,7 +110,7 @@ def test_create_service(notify_db_session):
|
|||||||
assert service_db.prefix_sms is True
|
assert service_db.prefix_sms is True
|
||||||
assert service.active is True
|
assert service.active is True
|
||||||
assert user in service_db.users
|
assert user in service_db.users
|
||||||
assert service_db.organisation_type == 'central'
|
assert service_db.organisation_type == 'federal'
|
||||||
assert service_db.crown is None
|
assert service_db.crown is None
|
||||||
assert not service.letter_branding
|
assert not service.letter_branding
|
||||||
assert not service.organisation_id
|
assert not service.organisation_id
|
||||||
@@ -119,13 +119,13 @@ def test_create_service(notify_db_session):
|
|||||||
def test_create_service_with_organisation(notify_db_session):
|
def test_create_service_with_organisation(notify_db_session):
|
||||||
user = create_user(email='local.authority@local-authority.gov.uk')
|
user = create_user(email='local.authority@local-authority.gov.uk')
|
||||||
organisation = create_organisation(
|
organisation = create_organisation(
|
||||||
name='Some local authority', organisation_type='local', domains=['local-authority.gov.uk'])
|
name='Some local authority', organisation_type='state', domains=['local-authority.gov.uk'])
|
||||||
assert Service.query.count() == 0
|
assert Service.query.count() == 0
|
||||||
service = Service(name="service_name",
|
service = Service(name="service_name",
|
||||||
email_from="email_from",
|
email_from="email_from",
|
||||||
message_limit=1000,
|
message_limit=1000,
|
||||||
restricted=False,
|
restricted=False,
|
||||||
organisation_type='central',
|
organisation_type='federal',
|
||||||
created_by=user)
|
created_by=user)
|
||||||
dao_create_service(service, user)
|
dao_create_service(service, user)
|
||||||
assert Service.query.count() == 1
|
assert Service.query.count() == 1
|
||||||
@@ -138,7 +138,7 @@ def test_create_service_with_organisation(notify_db_session):
|
|||||||
assert service_db.prefix_sms is True
|
assert service_db.prefix_sms is True
|
||||||
assert service.active is True
|
assert service.active is True
|
||||||
assert user in service_db.users
|
assert user in service_db.users
|
||||||
assert service_db.organisation_type == 'local'
|
assert service_db.organisation_type == 'state'
|
||||||
assert service_db.crown is None
|
assert service_db.crown is None
|
||||||
assert not service.letter_branding
|
assert not service.letter_branding
|
||||||
assert service.organisation_id == organisation.id
|
assert service.organisation_id == organisation.id
|
||||||
@@ -447,7 +447,7 @@ def test_get_all_user_services_should_return_empty_list_if_no_services_for_user(
|
|||||||
|
|
||||||
@freeze_time('2019-04-23T10:00:00')
|
@freeze_time('2019-04-23T10:00:00')
|
||||||
def test_dao_fetch_live_services_data(sample_user):
|
def test_dao_fetch_live_services_data(sample_user):
|
||||||
org = create_organisation(organisation_type='nhs_central')
|
org = create_organisation(organisation_type='federal')
|
||||||
service = create_service(go_live_user=sample_user, go_live_at='2014-04-20T10:00:00')
|
service = create_service(go_live_user=sample_user, go_live_at='2014-04-20T10:00:00')
|
||||||
sms_template = create_template(service=service)
|
sms_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)
|
service_2 = create_service(service_name='second', go_live_at='2017-04-20T10:00:00', go_live_user=sample_user)
|
||||||
@@ -485,7 +485,7 @@ def test_dao_fetch_live_services_data(sample_user):
|
|||||||
# checks the results and that they are ordered by date:
|
# checks the results and that they are ordered by date:
|
||||||
assert results == [
|
assert results == [
|
||||||
{'service_id': mock.ANY, 'service_name': 'Sample service', 'organisation_name': 'test_org_1',
|
{'service_id': mock.ANY, 'service_name': 'Sample service', 'organisation_name': 'test_org_1',
|
||||||
'organisation_type': 'nhs_central', 'consent_to_research': None, 'contact_name': 'Test User',
|
'organisation_type': 'federal', 'consent_to_research': None, 'contact_name': 'Test User',
|
||||||
'contact_email': 'notify@digital.cabinet-office.gov.uk', 'contact_mobile': '+447700900986',
|
'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,
|
'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,
|
'letter_volume_intent': None, 'sms_totals': 2, 'email_totals': 1, 'letter_totals': 1,
|
||||||
|
|||||||
@@ -715,7 +715,7 @@ def test_update_service(client, notify_db_session, sample_service):
|
|||||||
'email_from': 'updated.service.name',
|
'email_from': 'updated.service.name',
|
||||||
'created_by': str(sample_service.created_by.id),
|
'created_by': str(sample_service.created_by.id),
|
||||||
'email_branding': str(brand.id),
|
'email_branding': str(brand.id),
|
||||||
'organisation_type': 'school_or_college',
|
'organisation_type': 'federal',
|
||||||
}
|
}
|
||||||
|
|
||||||
auth_header = create_admin_authorization_header()
|
auth_header = create_admin_authorization_header()
|
||||||
@@ -730,7 +730,7 @@ def test_update_service(client, notify_db_session, sample_service):
|
|||||||
assert result['data']['name'] == 'updated service name'
|
assert result['data']['name'] == 'updated service name'
|
||||||
assert result['data']['email_from'] == 'updated.service.name'
|
assert result['data']['email_from'] == 'updated.service.name'
|
||||||
assert result['data']['email_branding'] == str(brand.id)
|
assert result['data']['email_branding'] == str(brand.id)
|
||||||
assert result['data']['organisation_type'] == 'school_or_college'
|
assert result['data']['organisation_type'] == 'federal'
|
||||||
|
|
||||||
|
|
||||||
def test_cant_update_service_org_type_to_random_value(client, sample_service):
|
def test_cant_update_service_org_type_to_random_value(client, sample_service):
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ def test_populate_annual_billing_with_defaults(
|
|||||||
def test_populate_annual_billing_with_defaults_sets_free_allowance_to_zero_if_previous_year_is_zero(
|
def test_populate_annual_billing_with_defaults_sets_free_allowance_to_zero_if_previous_year_is_zero(
|
||||||
notify_db_session, notify_api
|
notify_db_session, notify_api
|
||||||
):
|
):
|
||||||
service = create_service(organisation_type='central')
|
service = create_service(organisation_type='federal')
|
||||||
create_annual_billing(service_id=service.id, free_sms_fragment_limit=0, financial_year_start=2021)
|
create_annual_billing(service_id=service.id, free_sms_fragment_limit=0, financial_year_start=2021)
|
||||||
notify_api.test_cli_runner().invoke(
|
notify_api.test_cli_runner().invoke(
|
||||||
populate_annual_billing_with_defaults, ['-y', 2022]
|
populate_annual_billing_with_defaults, ['-y', 2022]
|
||||||
|
|||||||
Reference in New Issue
Block a user