Trying to mock the response of a aiohttp.ClientSession for testing purposes
My code looks like this:
async def run_request(endpoint: str, **kwargs) -> dict:
async with aiohttp.ClientSession() as session:
async with session.post(endpoint, **kwargs) as response:
response_json = await response.json()
return {"response": response, "response_json": response_json}
I would like to test my code with something that I image looks like this:
@patch("aiohttp.ClientSession.post", <something>)
def test_run_request(self):
How can I do that?