From 379cf88fa5375f3764f2e6a0d9e7cad57c846324 Mon Sep 17 00:00:00 2001 From: outp1 Date: Fri, 3 Mar 2023 17:09:36 +0300 Subject: [PATCH] test for passing unmatched requests --- tests/test_aioresponses.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_aioresponses.py b/tests/test_aioresponses.py index d0b150c..7167c45 100644 --- a/tests/test_aioresponses.py +++ b/tests/test_aioresponses.py @@ -783,3 +783,18 @@ async def test_relative_url_redirect_followed(self, rsps): self.assertEqual(str(response.url), f"{base_url}/baz") self.assertEqual(len(response.history), 1) self.assertEqual(str(response.history[0].url), url) + + async def test_pass_through_unmatched_requests(self): + matched_url = "https://matched_example.org" + unmatched_url = "https://httpbin.org/get" + params_unmatched = {'foo': 'bar'} + + with aioresponses(passthrough_unmatched=True) as m: + m.post(URL(matched_url), status=200) + mocked_response = await self.session.post(URL(matched_url)) + response = await self.session.get( + URL(unmatched_url), params=params_unmatched + ) + self.assertEqual(response.status, 200) + self.assertEqual(str(response.url), 'https://httpbin.org/get?foo=bar') + self.assertEqual(mocked_response.status, 200)