Skip to content

Commit

Permalink
test for passing unmatched requests
Browse files Browse the repository at this point in the history
  • Loading branch information
outp1 committed Mar 3, 2023
1 parent 94468db commit 379cf88
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_aioresponses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 379cf88

Please sign in to comment.