How to use the aioresponses.compat.merge_params function in aioresponses

To help you get started, we’ve selected a few aioresponses examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pnuckowski / aioresponses / aioresponses / core.py View on Github external
async def _request_mock(self, orig_self: ClientSession,
                            method: str, url: 'Union[URL, str]',
                            *args: Tuple,
                            **kwargs: Dict) -> 'ClientResponse':
        """Return mocked response object or raise connection error."""
        if orig_self.closed:
            raise RuntimeError('Session is closed')

        url = normalize_url(merge_params(url, kwargs.get('params')))
        url_str = str(url)
        for prefix in self._passthrough:
            if url_str.startswith(prefix):
                return (await self.patcher.temp_original(
                    orig_self, method, url, *args, **kwargs
                ))

        response = await self.match(method, url, **kwargs)

        key = (method, url)
        self.requests.setdefault(key, [])
        self.requests[key].append(RequestCall(args, copy.deepcopy(kwargs)))

        if response is None:
            raise ClientConnectionError(
                'Connection refused: {} {}'.format(method, url)