Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def test_http_methods(client):
async with respx.mock:
url = "https://foo.bar/"
m = respx.get(url, status_code=404)
respx.post(url, status_code=201)
respx.put(url, status_code=202)
respx.patch(url, status_code=500)
respx.delete(url, status_code=204)
respx.head(url, status_code=405)
respx.options(url, status_code=501)
response = httpx.get(url)
assert response.status_code == 404
response = await client.get(url)
assert response.status_code == 404
response = httpx.post(url)
assert response.status_code == 201
response = await client.post(url)
assert response.status_code == 201
response = httpx.put(url)
assert response.status_code == 202
response = await client.put(url)
assert response.status_code == 202