def test_make_api_callback_request(self, mocked_method):
        url = "http://www.google.com"
        method = "GET"
        params = '{"q": "test"}'
        headers = '{"X-TEST": "TEST"}'

        make_request(
            method=method, url=url, params=params, headers=headers, timeout=settings.DEFAULT_CALLBACK_REQUEST_TIMEOUT
        )

        mocked_method.assert_called_once_with(
            method, url, params=params, headers=headers, timeout=settings.DEFAULT_CALLBACK_REQUEST_TIMEOUT
        )
    def test_make_api_callback_request(self, mocked_method):
        url = "http://www.google.com"
        method = "GET"
        params = '{"q": "test"}'
        headers = '{"X-TEST": "TEST"}'

        make_request(method=method,
                     url=url,
                     params=params,
                     headers=headers,
                     timeout=settings.DEFAULT_CALLBACK_REQUEST_TIMEOUT)

        mocked_method.assert_called_once_with(
            method,
            url,
            params=params,
            headers=headers,
            timeout=settings.DEFAULT_CALLBACK_REQUEST_TIMEOUT)
Пример #3
0
def run_api_endpoint_callbacks(api_endpoint):
    responses = []
    for api_callback in api_endpoint.callbacks.all():
        logger.debug("Make callback: %s", api_callback)
        response = make_request(method=api_callback.method, url=api_callback.url, params=api_callback.get_params(),
                                headers=api_callback.get_headers(), timeout=settings.DEFAULT_CALLBACK_REQUEST_TIMEOUT)
        if response:
            logger.debug("Callback response status code: %s", response.status_code)
            responses.append(response)
    return responses
Пример #4
0
def run_api_endpoint_callbacks(api_endpoint):
    responses = []
    for api_callback in api_endpoint.callbacks.all():
        logger.debug("Make callback: %s", api_callback)
        response = make_request(
            method=api_callback.method,
            url=api_callback.url,
            params=api_callback.get_params(),
            headers=api_callback.get_headers(),
            timeout=settings.DEFAULT_CALLBACK_REQUEST_TIMEOUT)
        if response:
            logger.debug("Callback response status code: %s",
                         response.status_code)
            responses.append(response)
    return responses