From 5c2cdf6250ecb61c5935918bbd63e04edeb63c12 Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Mon, 15 Feb 2021 13:54:52 +0000 Subject: [PATCH] Remove redundant import of Mock and ANY It's conventional to use the "mocker" fixture to access these. --- .../main/views/organisations/test_organisations.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/app/main/views/organisations/test_organisations.py b/tests/app/main/views/organisations/test_organisations.py index bfd7b6c7c..32d35683f 100644 --- a/tests/app/main/views/organisations/test_organisations.py +++ b/tests/app/main/views/organisations/test_organisations.py @@ -1,5 +1,3 @@ -from unittest.mock import ANY, Mock - import pytest from bs4 import BeautifulSoup from flask import url_for @@ -102,7 +100,7 @@ def test_page_to_create_new_organisation( ('radio', 'organisation_type', 'other'), ('radio', 'crown_status', 'crown'), ('radio', 'crown_status', 'non-crown'), - ('hidden', 'csrf_token', ANY), + ('hidden', 'csrf_token', mocker.ANY), ] @@ -200,8 +198,8 @@ def test_create_new_organisation_fails_with_duplicate_name( mocker, ): def _create(**_kwargs): - json_mock = Mock(return_value={'message': 'Organisation name already exists'}) - resp_mock = Mock(status_code=400, json=json_mock) + json_mock = mocker.Mock(return_value={'message': 'Organisation name already exists'}) + resp_mock = mocker.Mock(status_code=400, json=json_mock) http_error = HTTPError(response=resp_mock, message="Default message") raise http_error @@ -1079,7 +1077,7 @@ def test_update_organisation_domains_when_domain_already_exists( client_request.login(user) mocker.patch('app.organisations_client.update_organisation', side_effect=HTTPError( - response=Mock( + response=mocker.Mock( status_code=400, json={'result': 'error', 'message': 'Domain already exists'} ), @@ -1229,7 +1227,7 @@ def test_confirm_update_organisation_with_name_already_in_use( mocker.patch( 'app.organisations_client.update_organisation_name', side_effect=HTTPError( - response=Mock( + response=mocker.Mock( status_code=400, json={'result': 'error', 'message': 'Organisation name already exists'} ),