mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
Make service created by platform admin non-counted
If a service has been created by someone on our team, it’s probably a test service, which shouldn’t be included in the count of live services.
This commit is contained in:
@@ -179,6 +179,7 @@ def dao_create_service(
|
||||
service.active = True
|
||||
service.research_mode = False
|
||||
service.crown = service.organisation_type == 'central'
|
||||
service.count_as_live = not user.platform_admin
|
||||
|
||||
for permission in service_permissions:
|
||||
service_permission = ServicePermission(service_id=service.id, permission=permission)
|
||||
|
||||
@@ -221,7 +221,17 @@ def test_get_service_by_id_should_404_if_no_service_for_user(notify_api, sample_
|
||||
assert json_resp['message'] == 'No result found'
|
||||
|
||||
|
||||
def test_create_service(admin_request, sample_user):
|
||||
@pytest.mark.parametrize('platform_admin, expected_count_as_live', (
|
||||
(True, False),
|
||||
(False, True),
|
||||
))
|
||||
def test_create_service(
|
||||
admin_request,
|
||||
sample_user,
|
||||
platform_admin,
|
||||
expected_count_as_live,
|
||||
):
|
||||
sample_user.platform_admin = platform_admin
|
||||
data = {
|
||||
'name': 'created service',
|
||||
'user_id': str(sample_user.id),
|
||||
@@ -240,6 +250,7 @@ def test_create_service(admin_request, sample_user):
|
||||
assert not json_resp['data']['research_mode']
|
||||
assert json_resp['data']['rate_limit'] == 3000
|
||||
assert json_resp['data']['letter_branding'] is None
|
||||
assert json_resp['data']['count_as_live'] is expected_count_as_live
|
||||
|
||||
service_db = Service.query.get(json_resp['data']['id'])
|
||||
assert service_db.name == 'created service'
|
||||
|
||||
Reference in New Issue
Block a user