Merge pull request #3643 from alphagov/broadcast-org

move service to broadcast org when broadcasting is enabled
This commit is contained in:
Leo Hemsted
2020-09-24 13:13:34 +01:00
committed by GitHub
4 changed files with 50 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ import pytest
from flask import url_for
from app.main.views.service_settings import PLATFORM_ADMIN_SERVICE_PERMISSIONS
from tests.conftest import normalize_spaces
from tests.conftest import SERVICE_ONE_ID, normalize_spaces, set_config
@pytest.fixture
@@ -215,3 +215,38 @@ def test_normal_user_doesnt_see_any_platform_admin_settings(
for permission in platform_admin_settings:
assert permission not in page
def test_setting_broadcast_sets_organisation_if_config_value_set(
mock_update_service_organisation,
mock_update_service,
platform_admin_client,
fake_uuid,
):
with set_config(platform_admin_client.application, 'BROADCAST_ORGANISATION_ID', fake_uuid):
response = platform_admin_client.post(
url_for('main.service_set_permission', service_id=SERVICE_ONE_ID, permission='broadcast'),
data={'enabled': True}
)
assert response.status_code == 302
assert response.location == url_for('main.service_settings', service_id=SERVICE_ONE_ID, _external=True)
mock_update_service_organisation.assert_called_once_with(
service_id=SERVICE_ONE_ID,
org_id=fake_uuid
)
def test_setting_broadcast_doesnt_set_organisation_if_config_value_not_set(
mock_update_service_organisation,
mock_update_service,
platform_admin_client,
):
with set_config(platform_admin_client.application, 'BROADCAST_ORGANISATION_ID', None):
response = platform_admin_client.post(
url_for('main.service_set_permission', service_id=SERVICE_ONE_ID, permission='broadcast'),
data={'enabled': True}
)
assert response.status_code == 302
assert response.location == url_for('main.service_settings', service_id=SERVICE_ONE_ID, _external=True)
assert not mock_update_service_organisation.called

View File

@@ -3360,7 +3360,7 @@ def mock_get_service_organisation(
@pytest.fixture(scope='function')
def mock_update_service_organisation(mocker):
def _update_service_organisation(service_id, organisation_id):
def _update_service_organisation(service_id, org_id):
return
return mocker.patch(
@@ -3504,7 +3504,7 @@ def mock_organisation_name_is_unique(mocker):
@pytest.fixture(scope='function')
def mock_update_organisation(mocker):
def _update_org(organisation_id, **kwargs):
def _update_org(org, **kwargs):
return
return mocker.patch('app.organisations_client.update_organisation', side_effect=_update_org)