fix(test): FastAPI 0.87.0 - warning fixes

FastAPI 0.87.0 switched to the httpx library for their TestClient

* cookies need to be defined on the request instance instead of method calls

Signed-off-by: moson-mo <mo-son@mailbox.org>
This commit is contained in:
moson-mo 2022-11-24 22:43:31 +01:00
parent 1216399d53
commit a832b3cddb
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
10 changed files with 463 additions and 281 deletions

View file

@ -99,7 +99,8 @@ def test_user_language(client: TestClient, user: User):
assert sid is not None
with client as req:
response = req.post("/language", data=post_data, cookies={"AURSID": sid})
req.cookies = {"AURSID": sid}
response = req.post("/language", data=post_data)
assert response.status_code == int(HTTPStatus.SEE_OTHER)
assert user.LangPreference == "de"
@ -154,6 +155,5 @@ def test_id_redirect(client: TestClient):
"key": "value", # Test that this param persists.
"key2": "value2", # And this one.
},
allow_redirects=False,
)
assert response.headers.get("location") == "/test?key=value&key2=value2"