def test_query_get_method_bad_response(): response_from_api = dict({"offline": True}) vips.get = MagicMock(return_value=(False, response_from_api)) endpoint = TestConfig.VIPS_API_ROOT_URL + '/12345/status/' + TestVips.CORRELATION_ID vips.get(endpoint, TestConfig.VIPS_API_USERNAME, TestConfig.VIPS_API_PASSWORD) is_success, actual = vips.status_get("12345", TestConfig, TestVips.CORRELATION_ID) vips.get.assert_called_with(endpoint, TestConfig.VIPS_API_USERNAME, TestConfig.VIPS_API_PASSWORD, TestVips.CORRELATION_ID) print(json.dumps(actual)) assert is_success is False
def test_query_get_method_failure(): response_from_api = load_json_into_dict( 'python/common/tests/sample_data/vips/vips_query_404.json') vips.get = MagicMock(return_value=(True, response_from_api)) endpoint = TestConfig.VIPS_API_ROOT_URL + '/12345/status/' + TestVips.CORRELATION_ID vips.get(endpoint, TestConfig.VIPS_API_USERNAME, TestConfig.VIPS_API_PASSWORD) is_success, actual = vips.status_get("12345", TestConfig, TestVips.CORRELATION_ID) vips.get.assert_called_with(endpoint, TestConfig.VIPS_API_USERNAME, TestConfig.VIPS_API_PASSWORD, TestVips.CORRELATION_ID) print(json.dumps(actual)) assert is_success is True assert "fail" in actual['resp']
def get_vips_status(**args) -> tuple: """ Return True if the VIPS API responds to the get status request Further middleware required to determine if the query found a prohibition """ config = args.get('config') prohibition_number = args.get('prohibition_number') is_api_callout_successful, vips_status_data = vips.status_get( prohibition_number, config, prohibition_number) if is_api_callout_successful: args['vips_status'] = vips_status_data return True, args error = 'the VIPS get_status operation returned an invalid response' args['error_string'] = "The system is down, please try again later." logging.info(error) return False, args
def test_query_get_method_success(): response_from_api = load_json_into_dict( 'python/tests/sample_data/vips/vips_query_200.json') vips.get = MagicMock(return_value=(True, response_from_api)) endpoint = TestConfig.VIPS_API_ROOT_URL + '/12345/status/' + TestVips.CORRELATION_ID vips.get(endpoint, TestConfig.VIPS_API_USERNAME, TestConfig.VIPS_API_PASSWORD) is_success, actual = vips.status_get("12345", TestConfig, TestVips.CORRELATION_ID) vips.get.assert_called_with(endpoint, TestConfig.VIPS_API_USERNAME, TestConfig.VIPS_API_PASSWORD, TestVips.CORRELATION_ID) print(json.dumps(actual)) assert is_success is True assert "driverLicenceSeizedYn" in actual['data']['status'] assert "surnameNm" in actual['data']['status'] assert "disclosure" in actual['data']['status']