Fix mock_get_organisation_by_domain and mock_get_service_organisation

This commits stops the `mock_get_organisation_by_domain` and
`mock_get_service_organisation` fixtures from being called like
functions.
This commit is contained in:
Katie Smith
2019-12-20 15:02:47 +00:00
parent 41d33b2995
commit 6bc4f1898f
3 changed files with 24 additions and 23 deletions

View File

@@ -3,7 +3,7 @@ from flask import session, url_for
from app.utils import is_gov_user
from tests import organisation_json
from tests.conftest import mock_get_organisation_by_domain, normalize_spaces
from tests.conftest import normalize_spaces
def test_non_gov_user_cannot_see_add_service_button(
@@ -66,7 +66,10 @@ def test_get_should_not_render_radios_if_org_type_known(
client_request,
mocker,
):
mock_get_organisation_by_domain(mocker, organisation_type='central')
mocker.patch(
'app.organisations_client.get_organisation_by_domain',
return_value=organisation_json(organisation_type='central'),
)
page = client_request.get('main.add_service')
assert page.select_one('h1').text.strip() == 'About your service'
assert page.select_one('input[name=name]')['value'] == ''
@@ -113,7 +116,10 @@ def test_should_add_service_and_redirect_to_tour_when_no_services(
):
api_user_active['email_address'] = email_address
client_request.login(api_user_active)
mock_get_organisation_by_domain(mocker, organisation_type=inherited)
mocker.patch(
'app.organisations_client.get_organisation_by_domain',
return_value=organisation_json(organisation_type=inherited),
)
client_request.post(
'main.add_service',
_data={

View File

@@ -7,11 +7,7 @@ from flask import url_for
from freezegun import freeze_time
from tests import organisation_json
from tests.conftest import (
SERVICE_ONE_ID,
mock_get_service_organisation,
normalize_spaces,
)
from tests.conftest import SERVICE_ONE_ID, normalize_spaces
class _MockS3Object():
@@ -94,11 +90,12 @@ def test_show_agreement_page(
crown,
expected_links,
):
mock_get_service_organisation(
mocker,
org = organisation_json(
crown=crown,
agreement_signed=agreement_signed,
agreement_signed=agreement_signed
)
mocker.patch('app.organisations_client.get_service_organisation', return_value=org)
page = client_request.get('main.service_agreement', service_id=SERVICE_ONE_ID)
links = page.select('main .column-five-sixths a')
assert len(links) == len(expected_links)

View File

@@ -33,7 +33,6 @@ from tests.conftest import (
create_platform_admin_user,
create_reply_to_email_address,
create_sms_sender,
mock_get_service_organisation,
normalize_spaces,
)
@@ -1095,11 +1094,10 @@ def test_should_check_for_mou_on_request_to_go_live(
return_value=None,
)
mock_get_service_organisation(
mocker,
agreement_signed=agreement_signed,
mocker.patch(
'app.organisations_client.get_service_organisation',
return_value=organisation_json(agreement_signed=agreement_signed)
)
page = client_request.get(
'main.request_to_go_live', service_id=SERVICE_ONE_ID
)
@@ -1452,11 +1450,11 @@ def test_should_redirect_after_request_to_go_live(
formatted_displayed_volumes,
extra_tags,
):
mock_get_service_organisation(
mocker,
name=None,
agreement_signed=None,
mocker.patch(
'app.organisations_client.get_service_organisation',
return_value=organisation_json(name=None, agreement_signed=None)
)
for channel, volume in volumes:
mocker.patch(
'app.models.service.Service.volume_{}'.format(channel),
@@ -1767,9 +1765,9 @@ def test_ready_to_go_live(
agreement_signed,
expected_tags,
):
mock_get_service_organisation(
mocker,
agreement_signed=agreement_signed,
mocker.patch(
'app.organisations_client.get_service_organisation',
return_value=organisation_json(agreement_signed=agreement_signed)
)
for prop in {