Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_base_api_request_preview_handler(self):
base_api = BaseApi(self._api_key, [self._request_handler_mock])
endpoint_name = "endpoint_xx"
method_name = "method_xx"
region = "region_xx"
url_ext = "url_xx"
kwarg = "extra_xx"
base_api.request(endpoint_name, method_name, region, url_ext, extra=kwarg)
self._request_handler_mock.preview_request.assert_called_once_with(
region,
endpoint_name,
method_name,
"https://region_xx.api.riotgames.com%s" % url_ext,
{"extra": kwarg},
)
def test_base_api_request_static_preview_handler(self):
base_api = BaseApi(self._api_key, [self._request_handler_mock])
version = "version_xx"
locale = "locale_xx"
url_ext = "url_xx"
ret = base_api.request_static(version, locale, url_ext)
self._request_handler_mock.preview_static_request.assert_called_once_with(
"https://ddragon.leagueoflegends.com/cdn/%s/data/%s/%s.json"
% (version, locale, url_ext),
{},
)
def test_base_api_request_static_after_handler_with_preview_return(self):
base_api = BaseApi(self._api_key, [self._request_handler_mock])
version = "version_xx"
locale = "locale_xx"
url_ext = "url_xx"
ret = base_api.request_static(version, locale, url_ext)
self._request_handler_mock.after_static_request.assert_called_once_with(
"https://ddragon.leagueoflegends.com/cdn/%s/data/%s/%s.json"
% (version, locale, url_ext),
self._expected_preview_return,
)
self.assertEqual(ret, self._expected_after_return)
def test_base_api_request_static_after_handler_with_preview_no_return(
self, mock_get
):
mock_get.return_value = self._mock_api_response
base_api = BaseApi(self._api_key, [self._request_handler_mock_no_return])
version = "version_xx"
locale = "locale_xx"
url_ext = "url_xx"
ret = base_api.request_static(version, locale, url_ext)
self._request_handler_mock_no_return.after_static_request.assert_called_once_with(
"https://ddragon.leagueoflegends.com/cdn/%s/data/%s/%s.json"
% (version, locale, url_ext),
self._mock_api_response,
)
mock_get.assert_called_once_with(
"https://ddragon.leagueoflegends.com/cdn/%s/data/%s/%s.json"
% (version, locale, url_ext)
)
def test_base_api_request_after_handler_with_preview_no_return(self, mock_get):
mock_get.return_value = self._mock_api_response
base_api = BaseApi(self._api_key, [self._request_handler_mock_no_return])
endpoint_name = "endpoint_xx"
method_name = "method_xx"
region = "region_xx"
url_ext = "url_xx"
kwarg = "extra_xx"
ret = base_api.request(endpoint_name, method_name, region, url_ext, extra=kwarg)
self._request_handler_mock_no_return.after_request.assert_called_once_with(
region,
endpoint_name,
method_name,
"https://region_xx.api.riotgames.com%s" % url_ext,
self._mock_api_response,
)
def test_base_api_request_after_handler_with_preview_return(self):
base_api = BaseApi(self._api_key, [self._request_handler_mock])
endpoint_name = "endpoint_xx"
method_name = "method_xx"
region = "region_xx"
url_ext = "url_xx"
kwarg = "extra_xx"
ret = base_api.request(endpoint_name, method_name, region, url_ext, extra=kwarg)
self._request_handler_mock.after_request.assert_called_once_with(
region,
endpoint_name,
method_name,
"https://region_xx.api.riotgames.com%s" % url_ext,
self._expected_preview_return,
)