no longer add an annual billing entry creating a service

this is now handled by a separate call from the admin app
This commit is contained in:
Leo Hemsted
2017-12-06 11:01:18 +00:00
parent 8cd422ebea
commit 4cdcc4e035
6 changed files with 33 additions and 80 deletions

View File

@@ -51,7 +51,6 @@ from app.models import (
Service,
ServicePermission,
ServicePermissionTypes,
AnnualBilling,
BRANDING_GOVUK,
DVLA_ORG_HM_GOVERNMENT,
KEY_TYPE_NORMAL,
@@ -90,7 +89,7 @@ def test_create_service(sample_user):
restricted=False,
organisation_type='central',
created_by=sample_user)
dao_create_service(service, sample_user, 12345)
dao_create_service(service, sample_user)
assert Service.query.count() == 1
service_db = Service.query.one()
@@ -103,12 +102,8 @@ def test_create_service(sample_user):
assert service_db.prefix_sms is True
assert service.active is True
assert sample_user in service_db.users
assert service_db.free_sms_fragment_limit == 250000
assert service_db.organisation_type == 'central'
assert service_db.crown is True
annual_billing = AnnualBilling.query.one()
assert annual_billing.service == service_db
assert annual_billing.free_sms_fragment_limit == 12345
def test_cannot_create_two_services_with_same_name(sample_user):
@@ -125,8 +120,8 @@ def test_cannot_create_two_services_with_same_name(sample_user):
restricted=False,
created_by=sample_user)
with pytest.raises(IntegrityError) as excinfo:
dao_create_service(service1, sample_user, 12345)
dao_create_service(service2, sample_user, 12345)
dao_create_service(service1, sample_user)
dao_create_service(service2, sample_user)
assert 'duplicate key value violates unique constraint "services_name_key"' in str(excinfo.value)
@@ -143,8 +138,8 @@ def test_cannot_create_two_services_with_same_email_from(sample_user):
restricted=False,
created_by=sample_user)
with pytest.raises(IntegrityError) as excinfo:
dao_create_service(service1, sample_user, 12345)
dao_create_service(service2, sample_user, 12345)
dao_create_service(service1, sample_user)
dao_create_service(service2, sample_user)
assert 'duplicate key value violates unique constraint "services_email_from_key"' in str(excinfo.value)
@@ -156,7 +151,7 @@ def test_cannot_create_service_with_no_user(notify_db_session, sample_user):
restricted=False,
created_by=sample_user)
with pytest.raises(FlushError) as excinfo:
dao_create_service(service, None, 12345)
dao_create_service(service, None)
assert "Can't flush None value found in collection Service.users" in str(excinfo.value)
@@ -166,7 +161,7 @@ def test_should_add_user_to_service(sample_user):
message_limit=1000,
restricted=False,
created_by=sample_user)
dao_create_service(service, sample_user, 12345)
dao_create_service(service, sample_user)
assert sample_user in Service.query.first().users
new_user = User(
name='Test User',
@@ -185,7 +180,7 @@ def test_should_remove_user_from_service(sample_user):
message_limit=1000,
restricted=False,
created_by=sample_user)
dao_create_service(service, sample_user, 12345)
dao_create_service(service, sample_user)
new_user = User(
name='Test User',
email_address='new_user@digital.cabinet-office.gov.uk',
@@ -337,7 +332,7 @@ def test_create_service_creates_a_history_record_with_current_data(sample_user):
message_limit=1000,
restricted=False,
created_by=sample_user)
dao_create_service(service, sample_user, 12345)
dao_create_service(service, sample_user)
assert Service.query.count() == 1
assert Service.get_history_model().query.count() == 1
@@ -364,7 +359,7 @@ def test_update_service_creates_a_history_record_with_current_data(sample_user):
message_limit=1000,
restricted=False,
created_by=sample_user)
dao_create_service(service, sample_user, 12345)
dao_create_service(service, sample_user)
assert Service.query.count() == 1
assert Service.query.first().version == 1
@@ -392,7 +387,7 @@ def test_update_service_permission_creates_a_history_record_with_current_data(sa
message_limit=1000,
restricted=False,
created_by=sample_user)
dao_create_service(service, sample_user, 12345)
dao_create_service(service, sample_user)
service.permissions.append(ServicePermission(service_id=service.id, permission='letter'))
dao_update_service(service)
@@ -435,7 +430,7 @@ def test_create_service_and_history_is_transactional(sample_user):
created_by=sample_user)
with pytest.raises(IntegrityError) as excinfo:
dao_create_service(service, sample_user, 12345)
dao_create_service(service, sample_user)
assert 'column "name" violates not-null constraint' in str(excinfo.value)
assert Service.query.count() == 0
@@ -484,7 +479,7 @@ def test_add_existing_user_to_another_service_doesnot_change_old_permissions(sam
restricted=False,
created_by=sample_user)
dao_create_service(service_one, sample_user, 12345)
dao_create_service(service_one, sample_user)
assert sample_user.id == service_one.users[0].id
test_user_permissions = Permission.query.filter_by(service=service_one, user=sample_user).all()
assert len(test_user_permissions) == 8
@@ -501,7 +496,7 @@ def test_add_existing_user_to_another_service_doesnot_change_old_permissions(sam
message_limit=1000,
restricted=False,
created_by=other_user)
dao_create_service(service_two, other_user, 12345)
dao_create_service(service_two, other_user)
assert other_user.id == service_two.users[0].id
other_user_permissions = Permission.query.filter_by(service=service_two, user=other_user).all()
@@ -530,7 +525,7 @@ def test_fetch_stats_filters_on_service(sample_notification):
email_from="hello",
restricted=False,
message_limit=1000)
dao_create_service(service_two, sample_notification.service.created_by, 12345)
dao_create_service(service_two, sample_notification.service.created_by)
stats = dao_fetch_stats_for_service(service_two.id)
assert len(stats) == 0