mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 21:48:49 -04:00
make service live or training
This commit is contained in:
@@ -3658,6 +3658,7 @@ def test_set_as_broadcast_service_sets_broadcast_channel(
|
||||
assert sample_service.service_broadcast_settings is None
|
||||
data = {
|
||||
'broadcast_channel': channel,
|
||||
'service_mode': 'live',
|
||||
}
|
||||
|
||||
resp = client.post(
|
||||
@@ -3685,6 +3686,7 @@ def test_set_as_broadcast_service_updates_channel_for_broadcast_service(
|
||||
'/service/{}/set-as-broadcast-service'.format(sample_broadcast_service.id),
|
||||
data=json.dumps({
|
||||
'broadcast_channel': "test",
|
||||
'service_mode': 'training',
|
||||
}),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||
)
|
||||
@@ -3705,6 +3707,7 @@ def test_set_as_broadcast_service_rejects_unknown_channels(
|
||||
):
|
||||
data = {
|
||||
'broadcast_channel': channel,
|
||||
'service_mode': 'live',
|
||||
}
|
||||
|
||||
resp = client.post(
|
||||
@@ -3716,7 +3719,7 @@ def test_set_as_broadcast_service_rejects_unknown_channels(
|
||||
|
||||
|
||||
def test_set_as_broadcast_service_rejects_if_no_channel(client, notify_db, sample_service, broadcast_organisation):
|
||||
data = {}
|
||||
data = {'service_mode': 'training'}
|
||||
|
||||
resp = client.post(
|
||||
'/service/{}/set-as-broadcast-service'.format(sample_service.id),
|
||||
@@ -3737,6 +3740,7 @@ def test_set_as_broadcast_service_gives_broadcast_permission_and_removes_other_p
|
||||
'/service/{}/set-as-broadcast-service'.format(sample_service.id),
|
||||
data=json.dumps({
|
||||
'broadcast_channel': "severe",
|
||||
'service_mode': 'training',
|
||||
}),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||
)
|
||||
@@ -3758,6 +3762,7 @@ def test_set_as_broadcast_service_maintains_broadcast_permission_for_existing_br
|
||||
'/service/{}/set-as-broadcast-service'.format(sample_broadcast_service.id),
|
||||
data=json.dumps({
|
||||
'broadcast_channel': "severe",
|
||||
'service_mode': 'live',
|
||||
}),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||
)
|
||||
@@ -3776,6 +3781,7 @@ def test_set_as_broadcast_service_sets_count_as_live_to_false(client, notify_db,
|
||||
'/service/{}/set-as-broadcast-service'.format(sample_service.id),
|
||||
data=json.dumps({
|
||||
'broadcast_channel': "severe",
|
||||
'service_mode': 'live',
|
||||
}),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||
)
|
||||
@@ -3794,6 +3800,7 @@ def test_set_as_broadcast_service_sets_service_org_to_broadcast_org(client, noti
|
||||
'/service/{}/set-as-broadcast-service'.format(sample_service.id),
|
||||
data=json.dumps({
|
||||
'broadcast_channel': "severe",
|
||||
'service_mode': 'training',
|
||||
}),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||
)
|
||||
@@ -3813,8 +3820,84 @@ def test_set_as_broadcast_service_does_not_error_if_run_on_a_service_that_is_alr
|
||||
'/service/{}/set-as-broadcast-service'.format(sample_service.id),
|
||||
data=json.dumps({
|
||||
'broadcast_channel': "severe",
|
||||
'service_mode': "live"
|
||||
}),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||
)
|
||||
result = resp.json
|
||||
assert resp.status_code == 200
|
||||
|
||||
|
||||
def test_set_as_broadcast_service_sets_service_to_live_mode(
|
||||
client, notify_db, sample_service, broadcast_organisation
|
||||
):
|
||||
sample_service.restricted = True
|
||||
notify_db.session.add(sample_service)
|
||||
notify_db.session.commit()
|
||||
assert sample_service.restricted == True
|
||||
data = {
|
||||
'broadcast_channel': 'severe',
|
||||
'service_mode': 'live',
|
||||
}
|
||||
|
||||
resp = client.post(
|
||||
'/service/{}/set-as-broadcast-service'.format(sample_service.id),
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||
)
|
||||
result = resp.json
|
||||
assert resp.status_code == 200
|
||||
assert result['data']['name'] == 'Sample service'
|
||||
assert result['data']['restricted'] == False
|
||||
|
||||
|
||||
def test_set_as_broadcast_service_sets_service_to_training_mode(
|
||||
client, notify_db, sample_broadcast_service, broadcast_organisation
|
||||
):
|
||||
sample_broadcast_service.restricted = False
|
||||
notify_db.session.add(sample_broadcast_service)
|
||||
notify_db.session.commit()
|
||||
assert sample_broadcast_service.restricted == False
|
||||
|
||||
data = {
|
||||
'broadcast_channel': 'severe',
|
||||
'service_mode': 'training',
|
||||
}
|
||||
|
||||
resp = client.post(
|
||||
'/service/{}/set-as-broadcast-service'.format(sample_broadcast_service.id),
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||
)
|
||||
result = resp.json
|
||||
assert resp.status_code == 200
|
||||
assert result['data']['name'] == 'Sample broadcast service'
|
||||
assert result['data']['restricted'] == True
|
||||
|
||||
|
||||
@pytest.mark.parametrize('service_mode', ["testing", ""])
|
||||
def test_set_as_broadcast_service_rejects_unknown_service_mode(
|
||||
client, notify_db, sample_service, broadcast_organisation, service_mode
|
||||
):
|
||||
data = {
|
||||
'broadcast_channel': 'severe',
|
||||
'service_mode': service_mode,
|
||||
}
|
||||
|
||||
resp = client.post(
|
||||
'/service/{}/set-as-broadcast-service'.format(sample_service.id),
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||
)
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
def test_set_as_broadcast_service_rejects_if_no_service_mode(client, notify_db, sample_service, broadcast_organisation):
|
||||
data = {'broadcast_channel': 'severe'}
|
||||
|
||||
resp = client.post(
|
||||
'/service/{}/set-as-broadcast-service'.format(sample_service.id),
|
||||
data=json.dumps(data),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||
)
|
||||
assert resp.status_code == 400
|
||||
|
||||
Reference in New Issue
Block a user