def test_search_denials(authorized_client, data_standard_case, requests_mock, queue_pk, standard_case_pk): end_user_id = data_standard_case["case"]["data"]["end_user"]["id"] end_user_name = data_standard_case["case"]["data"]["end_user"]["name"] end_user_address = data_standard_case["case"]["data"]["end_user"][ "address"] requests_mock.get( client._build_absolute_uri( f"/external-data/denial-search/?search={end_user_name}&search={end_user_address}" ), json={"hits": { "hits": [] }}, ) url = reverse("cases:denials", kwargs={ "pk": standard_case_pk, "queue_pk": queue_pk }) data = {"objects": ["1", "2", "3"]} response = authorized_client.get(f"{url}?end_user={end_user_id}") assert response.status_code == 200
def test_remove_matching_denials(authorized_client, requests_mock, mock_queue, mock_case, queue_pk, open_case_pk): requests_mock.delete( client._build_absolute_uri( f"/applications/{open_case_pk}/denial-matches/")) url = reverse("cases:remove-matching-denials", kwargs={ "pk": open_case_pk, "queue_pk": queue_pk }) data = {"objects": ["1", "2", "3"]} response = authorized_client.post(url, data) assert response.status_code == 302 assert response.url == reverse("cases:case", kwargs={ "queue_pk": queue_pk, "pk": open_case_pk }) assert requests_mock.request_history[0].json() == { "objects": ["1", "2", "3"] }
def mock_countries(requests_mock): url = client._build_absolute_uri("/static/countries/") # in relity there are around 275 countries data = { "countries": [ { "id": "AE-AZ", "name": "Abu Dhabi", "type": "gov.uk Territory", "is_eu": False }, { "id": "AF", "name": "Afghanistan", "type": "gov.uk Country", "is_eu": False }, { "id": "AE-AJ", "name": "Ajman", "type": "gov.uk Territory", "is_eu": False }, ] } requests_mock.get(url=url, json=data) yield data
def mock_denial_upload_validation_error(requests_mock): url = client._build_absolute_uri("/external-data/denial/") data = { "errors": { "csv_file": [ 'Error: [Row 2] {"denied_name": ["This field may not be blank."]}' ] } } yield requests_mock.post(url=url, status_code=400, json=data)
def mock_exporter_user(requests_mock): url = client._build_absolute_uri("/users/authenticate/") data = { "user": { "id": 123, "email": "*****@*****.**", "first_name": "Foo", "last_name": "Bar", "status": "Active", "token": "foo", "lite_api_user_id": "d355428a-64cb-4347-853b-afcacee15d93", } } requests_mock.get(url=url, json=data) yield data
def mock_units(requests_mock): url = client._build_absolute_uri("/static/units/") data = { "units": { "GRM": "Gram(s)", "KGM": "Kilogram(s)", "NAR": "Number of articles", "MTK": "Square metre(s)", "MTR": "Metre(s)", "LTR": "Litre(s)", "MTQ": "Cubic metre(s)", "ITG": "Intangible", } } requests_mock.get(url=url, json=data) yield data
def mock_list_open_general_licences(data_list_open_general_licences, requests_mock): url = _build_absolute_uri( "/open-general-licences/?convert_to_options=False®istered=True&disable_pagination=True" ) return requests_mock.get(url=url, json=data_list_open_general_licences)
def mock_list_no_licence_required(data_list_no_licence_required, requests_mock): url = _build_absolute_uri("/licences/nlrs/?page=1") return requests_mock.get(url=url, json=data_list_no_licence_required)
def mock_list_licences(requests_mock, data_list_licences): url = _build_absolute_uri("/licences/?page=1") return requests_mock.get(url=url, json=data_list_licences)
def mock_pv_gradings(requests_mock): url = client._build_absolute_uri("/static/private-venture-gradings/") yield requests_mock.get(url=url, json={"pv_gradings": []})
def mock_control_list_entries(requests_mock, data_control_list_entries): url = client._build_absolute_uri("/static/control-list-entries/") yield requests_mock.get(url=url, json=data_control_list_entries)
def mock_denial_patch(requests_mock): url = client._build_absolute_uri(f"/external-data/denial/{denial_pk}/") yield requests_mock.patch(url=url, json={})
def mock_denial_retrieve(requests_mock): url = client._build_absolute_uri(f"/external-data/denial/{denial_pk}/") yield requests_mock.get(url=url, json={"id": denial_pk})
def mock_denial_upload(requests_mock): url = client._build_absolute_uri("/external-data/denial/") yield requests_mock.post(url=url)