The fetch function should support POST requests.
()
| 159 | |
| 160 | |
| 161 | async def test_fetch_with_post_method(): |
| 162 | """ |
| 163 | The fetch function should support POST requests. |
| 164 | """ |
| 165 | response = await fetch( |
| 166 | "https://jsonplaceholder.typicode.com/posts", |
| 167 | method="POST", |
| 168 | headers={"Content-Type": "application/json"}, |
| 169 | body=json.dumps({"title": "foo", "body": "bar", "userId": 1}), |
| 170 | ) |
| 171 | assert response.ok |
| 172 | assert response.status == 201 |
| 173 | data = await response.json() |
| 174 | assert data["title"] == "foo" |
| 175 | assert data["body"] == "bar" |
| 176 | assert data["userId"] == 1 |
| 177 | assert "id" in data |
| 178 | |
| 179 | |
| 180 | async def test_fetch_with_put_method(): |