Verified Commit a832b3cd authored by Mario Oenning's avatar Mario Oenning
Browse files

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: Mario Oenning's avatarmoson-mo <mo-son@mailbox.org>
parent 1216399d
Pipeline #40227 passed with stages
in 2 minutes and 45 seconds
This diff is collapsed.
......@@ -71,10 +71,10 @@ def test_login_logout(client: TestClient, user: User):
response = request.post("/logout", data=post_data)
assert response.status_code == int(HTTPStatus.SEE_OTHER)
request.cookies = {"AURSID": response.cookies.get("AURSID")}
response = request.post(
"/logout",
data=post_data,
cookies={"AURSID": response.cookies.get("AURSID")},
)
assert response.status_code == int(HTTPStatus.SEE_OTHER)
......@@ -196,7 +196,9 @@ def test_authenticated_login(client: TestClient, user: User):
# when requesting GET /login as an authenticated user.
# Now, let's verify that we receive 403 Forbidden when we
# try to get /login as an authenticated user.
response = request.get("/login", cookies=response.cookies)
request.cookies = response.cookies
response = request.get("/login")
assert response.status_code == int(HTTPStatus.OK)
assert "Logged-in as: <strong>test</strong>" in response.text
......@@ -356,7 +358,8 @@ def test_generate_unique_sid_exhausted(
with mock.patch(generate_unique_sid_, mock_generate_sid):
with client as request:
# Set cookies = {} to remove any previous login kept by TestClient.
response = request.post("/login", data=post_data, cookies={})
request.cookies = {}
response = request.post("/login", data=post_data)
assert response.status_code == int(HTTPStatus.INTERNAL_SERVER_ERROR)
assert "500 - Internal Server Error" in response.text
......
......@@ -197,7 +197,8 @@ def test_metadata_change(
with client as request:
endp = f"/pkgbase/{pkgbasename}/keywords"
post_data = {"keywords": "abc def"}
resp = request.post(endp, data=post_data, cookies=cookies, allow_redirects=True)
request.cookies = cookies
resp = request.post(endp, data=post_data)
assert resp.status_code == HTTPStatus.OK
# Run main() again, which should now produce a new commit with the
......
......@@ -210,7 +210,8 @@ def test_homepage_dashboard(redis, packages, user):
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
response = request.get("/", cookies=cookies)
request.cookies = cookies
response = request.get("/")
assert response.status_code == int(HTTPStatus.OK)
root = parse_root(response.text)
......@@ -307,7 +308,8 @@ def test_homepage_dashboard_flagged(user: User, user2: User, package: Package):
# flagged maintained packages.
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
resp = request.get("/", cookies=cookies)
request.cookies = cookies
resp = request.get("/")
assert resp.status_code == int(HTTPStatus.OK)
root = parse_root(resp.text)
......
......@@ -71,7 +71,8 @@ def test_archdev_navbar_authenticated(client: TestClient, user: User):
expected = ["Dashboard", "Packages", "Requests", "My Account", "Logout"]
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
resp = request.get("/", cookies=cookies)
request.cookies = cookies
resp = request.get("/")
assert resp.status_code == int(HTTPStatus.OK)
root = parse_root(resp.text)
......@@ -92,7 +93,8 @@ def test_archdev_navbar_authenticated_tu(client: TestClient, trusted_user: User)
]
cookies = {"AURSID": trusted_user.login(Request(), "testPassword")}
with client as request:
resp = request.get("/", cookies=cookies)
request.cookies = cookies
resp = request.get("/")
assert resp.status_code == int(HTTPStatus.OK)
root = parse_root(resp.text)
......@@ -173,9 +175,12 @@ def test_rtl(client: TestClient):
expected = [[], [], ["rtl"], ["rtl"]]
with client as request:
responses["default"] = request.get("/")
responses["de"] = request.get("/", cookies={"AURLANG": "de"})
responses["he"] = request.get("/", cookies={"AURLANG": "he"})
responses["ar"] = request.get("/", cookies={"AURLANG": "ar"})
request.cookies = {"AURLANG": "de"}
responses["de"] = request.get("/")
request.cookies = {"AURLANG": "he"}
responses["he"] = request.get("/")
request.cookies = {"AURLANG": "ar"}
responses["ar"] = request.get("/")
for i, (lang, resp) in enumerate(responses.items()):
assert resp.status_code == int(HTTPStatus.OK)
t = parse_root(resp.text)
......
......@@ -410,7 +410,8 @@ def test_package_comments(client: TestClient, user: User, package: Package):
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
resp = request.get(package_endpoint(package), cookies=cookies)
request.cookies = cookies
resp = request.get(package_endpoint(package))
assert resp.status_code == int(HTTPStatus.OK)
root = parse_root(resp.text)
......@@ -465,7 +466,8 @@ def test_package_authenticated(client: TestClient, user: User, package: Package)
This process also occurs when pkgbase.html is rendered."""
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
resp = request.get(package_endpoint(package), cookies=cookies)
request.cookies = cookies
resp = request.get(package_endpoint(package))
assert resp.status_code == int(HTTPStatus.OK)
expected = [
......@@ -493,7 +495,8 @@ def test_package_authenticated_maintainer(
):
cookies = {"AURSID": maintainer.login(Request(), "testPassword")}
with client as request:
resp = request.get(package_endpoint(package), cookies=cookies)
request.cookies = cookies
resp = request.get(package_endpoint(package))
assert resp.status_code == int(HTTPStatus.OK)
expected = [
......@@ -515,7 +518,8 @@ def test_package_authenticated_maintainer(
def test_package_authenticated_tu(client: TestClient, tu_user: User, package: Package):
cookies = {"AURSID": tu_user.login(Request(), "testPassword")}
with client as request:
resp = request.get(package_endpoint(package), cookies=cookies)
request.cookies = cookies
resp = request.get(package_endpoint(package))
assert resp.status_code == int(HTTPStatus.OK)
expected = [
......@@ -941,10 +945,10 @@ def test_packages_sort_by_voted(
# Test that, by default, the first result is what we just set above.
cookies = {"AURSID": maintainer.login(Request(), "testPassword")}
with client as request:
request.cookies = cookies
response = request.get(
"/packages",
params={"SB": "w", "SO": "d"}, # Voted # Descending, Voted first.
cookies=cookies,
)
assert response.status_code == int(HTTPStatus.OK)
......@@ -966,10 +970,10 @@ def test_packages_sort_by_notify(
# Test that, by default, the first result is what we just set above.
cookies = {"AURSID": maintainer.login(Request(), "testPassword")}
with client as request:
request.cookies = cookies
response = request.get(
"/packages",
params={"SB": "o", "SO": "d"}, # Voted # Descending, Voted first.
cookies=cookies,
)
assert response.status_code == int(HTTPStatus.OK)
......@@ -1142,10 +1146,10 @@ def test_packages_post_unknown_action(client: TestClient, user: User, package: P
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
request.cookies = cookies
resp = request.post(
"/packages",
data={"action": "unknown"},
cookies=cookies,
)
assert resp.status_code == int(HTTPStatus.BAD_REQUEST)
......@@ -1158,10 +1162,10 @@ def test_packages_post_error(client: TestClient, user: User, package: Package):
with mock.patch.dict("aurweb.routers.packages.PACKAGE_ACTIONS", actions):
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
request.cookies = cookies
resp = request.post(
"/packages",
data={"action": "stub"},
cookies=cookies,
)
assert resp.status_code == int(HTTPStatus.BAD_REQUEST)
......@@ -1178,10 +1182,10 @@ def test_packages_post(client: TestClient, user: User, package: Package):
with mock.patch.dict("aurweb.routers.packages.PACKAGE_ACTIONS", actions):
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
request.cookies = cookies
resp = request.post(
"/packages",
data={"action": "stub"},
cookies=cookies,
)
assert resp.status_code == int(HTTPStatus.OK)
......@@ -1250,7 +1254,8 @@ def test_packages_post_notify(client: TestClient, user: User, package: Package):
# an error to be rendered.
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
resp = request.post("/packages", data={"action": "notify"}, cookies=cookies)
request.cookies = cookies
resp = request.post("/packages", data={"action": "notify"})
assert resp.status_code == int(HTTPStatus.BAD_REQUEST)
errors = get_errors(resp.text)
expected = "You did not select any packages to be notified about."
......@@ -1258,9 +1263,8 @@ def test_packages_post_notify(client: TestClient, user: User, package: Package):
# Now let's actually enable notifications on `package`.
with client as request:
resp = request.post(
"/packages", data={"action": "notify", "IDs": [package.ID]}, cookies=cookies
)
request.cookies = cookies
resp = request.post("/packages", data={"action": "notify", "IDs": [package.ID]})
assert resp.status_code == int(HTTPStatus.OK)
expected = "The selected packages' notifications have been enabled."
successes = get_successes(resp.text)
......@@ -1269,9 +1273,8 @@ def test_packages_post_notify(client: TestClient, user: User, package: Package):
# Try to enable notifications when they're already enabled,
# causing an error to be rendered.
with client as request:
resp = request.post(
"/packages", data={"action": "notify", "IDs": [package.ID]}, cookies=cookies
)
request.cookies = cookies
resp = request.post("/packages", data={"action": "notify", "IDs": [package.ID]})
assert resp.status_code == int(HTTPStatus.BAD_REQUEST)
errors = get_errors(resp.text)
expected = "You did not select any packages to be notified about."
......@@ -1289,7 +1292,8 @@ def test_packages_post_unnotify(client: TestClient, user: User, package: Package
# Request removal of the notification without any IDs.
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
resp = request.post("/packages", data={"action": "unnotify"}, cookies=cookies)
request.cookies = cookies
resp = request.post("/packages", data={"action": "unnotify"})
assert resp.status_code == int(HTTPStatus.BAD_REQUEST)
errors = get_errors(resp.text)
expected = "You did not select any packages for notification removal."
......@@ -1297,10 +1301,10 @@ def test_packages_post_unnotify(client: TestClient, user: User, package: Package
# Request removal of the notification; really.
with client as request:
request.cookies = cookies
resp = request.post(
"/packages",
data={"action": "unnotify", "IDs": [package.ID]},
cookies=cookies,
)
assert resp.status_code == int(HTTPStatus.OK)
successes = get_successes(resp.text)
......@@ -1315,10 +1319,10 @@ def test_packages_post_unnotify(client: TestClient, user: User, package: Package
# Try it again. The notif no longer exists.
with client as request:
request.cookies = cookies
resp = request.post(
"/packages",
data={"action": "unnotify", "IDs": [package.ID]},
cookies=cookies,
)
assert resp.status_code == int(HTTPStatus.BAD_REQUEST)
errors = get_errors(resp.text)
......@@ -1331,7 +1335,8 @@ def test_packages_post_adopt(client: TestClient, user: User, package: Package):
# Try to adopt an empty list of packages.
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
resp = request.post("/packages", data={"action": "adopt"}, cookies=cookies)
request.cookies = cookies
resp = request.post("/packages", data={"action": "adopt"})
assert resp.status_code == int(HTTPStatus.BAD_REQUEST)
errors = get_errors(resp.text)
expected = "You did not select any packages to adopt."
......@@ -1339,10 +1344,10 @@ def test_packages_post_adopt(client: TestClient, user: User, package: Package):
# Now, let's try to adopt a package that's already maintained.
with client as request:
request.cookies = cookies
resp = request.post(
"/packages",
data={"action": "adopt", "IDs": [package.ID], "confirm": True},
cookies=cookies,
)
assert resp.status_code == int(HTTPStatus.BAD_REQUEST)
errors = get_errors(resp.text)
......@@ -1356,9 +1361,8 @@ def test_packages_post_adopt(client: TestClient, user: User, package: Package):
# Now, let's try to adopt without confirming.
with client as request:
resp = request.post(
"/packages", data={"action": "adopt", "IDs": [package.ID]}, cookies=cookies
)
request.cookies = cookies
resp = request.post("/packages", data={"action": "adopt", "IDs": [package.ID]})
assert resp.status_code == int(HTTPStatus.BAD_REQUEST)
errors = get_errors(resp.text)
expected = (
......@@ -1369,10 +1373,10 @@ def test_packages_post_adopt(client: TestClient, user: User, package: Package):
# Let's do it again now that there is no maintainer.
with client as request:
request.cookies = cookies
resp = request.post(
"/packages",
data={"action": "adopt", "IDs": [package.ID], "confirm": True},
cookies=cookies,
)
assert resp.status_code == int(HTTPStatus.OK)
successes = get_successes(resp.text)
......@@ -1446,10 +1450,10 @@ def test_packages_post_disown(
"""Disown packages as a Trusted User, which cannot bypass idle time."""
cookies = {"AURSID": tu_user.login(Request(), "testPassword")}
with client as request:
request.cookies = cookies
resp = request.post(
"/packages",
data={"action": "disown", "IDs": [package.ID], "confirm": True},
cookies=cookies,
)
errors = get_errors(resp.text)
......@@ -1576,7 +1580,8 @@ def test_account_comments(client: TestClient, user: User, package: Package):
cookies = {"AURSID": user.login(Request(), "testPassword")}
endpoint = f"/account/{user.Username}/comments"
with client as request:
resp = request.get(endpoint, cookies=cookies)
request.cookies = cookies
resp = request.get(endpoint)
assert resp.status_code == int(HTTPStatus.OK)
root = parse_root(resp.text)
......
This diff is collapsed.
......@@ -254,7 +254,8 @@ def test_request(client: TestClient, auser: User, pkgbase: PackageBase):
"""Test the standard pkgbase request route GET method."""
endpoint = f"/pkgbase/{pkgbase.Name}/request"
with client as request:
resp = request.get(endpoint, cookies=auser.cookies)
request.cookies = auser.cookies
resp = request.get(endpoint)
assert resp.status_code == int(HTTPStatus.OK)
......@@ -263,7 +264,8 @@ def test_request_post_deletion(client: TestClient, auser2: User, pkgbase: Packag
endpoint = f"/pkgbase/{pkgbase.Name}/request"
data = {"comments": "Test request.", "type": "deletion"}
with client as request:
resp = request.post(endpoint, data=data, cookies=auser2.cookies)
request.cookies = auser2.cookies
resp = request.post(endpoint, data=data)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
pkgreq = pkgbase.requests.first()
......@@ -285,7 +287,8 @@ def test_request_post_deletion_as_maintainer(
endpoint = f"/pkgbase/{pkgbase.Name}/request"
data = {"comments": "Test request.", "type": "deletion"}
with client as request:
resp = request.post(endpoint, data=data, cookies=auser.cookies)
request.cookies = auser.cookies
resp = request.post(endpoint, data=data)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
# Check the pkgreq record got created and accepted.
......@@ -368,7 +371,8 @@ def test_request_post_merge(
"comments": "Test request.",
}
with client as request:
resp = request.post(endpoint, data=data, cookies=auser.cookies)
request.cookies = auser.cookies
resp = request.post(endpoint, data=data)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
pkgreq = pkgbase.requests.first()
......@@ -392,7 +396,8 @@ def test_request_post_orphan(client: TestClient, auser: User, pkgbase: PackageBa
"comments": "Test request.",
}
with client as request:
resp = request.post(endpoint, data=data, cookies=auser.cookies)
request.cookies = auser.cookies
resp = request.post(endpoint, data=data)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
pkgreq = pkgbase.requests.first()
......@@ -428,7 +433,8 @@ def test_deletion_request(
comments = "Test closure."
data = {"comments": comments, "confirm": True}
with client as request:
resp = request.post(endpoint, data=data, cookies=tu_user.cookies)
request.cookies = tu_user.cookies
resp = request.post(endpoint, data=data)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
assert resp.headers.get("location") == "/packages"
......@@ -460,7 +466,8 @@ def test_deletion_autorequest(client: TestClient, tu_user: User, pkgbase: Packag
endpoint = f"/pkgbase/{pkgbase.Name}/delete"
data = {"confirm": True}
with client as request:
resp = request.post(endpoint, data=data, cookies=tu_user.cookies)
request.cookies = tu_user.cookies
resp = request.post(endpoint, data=data)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
assert resp.headers.get("location") == "/packages"
......@@ -498,7 +505,8 @@ def test_merge_request(
comments = "Test merge closure."
data = {"into": target.Name, "comments": comments, "confirm": True}
with client as request:
resp = request.post(endpoint, data=data, cookies=tu_user.cookies)
request.cookies = tu_user.cookies
resp = request.post(endpoint, data=data)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
assert resp.headers.get("location") == f"/pkgbase/{target.Name}"
......@@ -545,7 +553,8 @@ def test_merge_autorequest(
endpoint = f"/pkgbase/{pkgbase.Name}/merge"
data = {"into": target.Name, "confirm": True}
with client as request:
resp = request.post(endpoint, data=data, cookies=tu_user.cookies)
request.cookies = tu_user.cookies
resp = request.post(endpoint, data=data)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
assert resp.headers.get("location") == f"/pkgbase/{target.Name}"
......@@ -582,7 +591,8 @@ def test_orphan_request(
comments = "Test orphan closure."
data = {"comments": comments, "confirm": True}
with client as request:
resp = request.post(endpoint, data=data, cookies=tu_user.cookies)
request.cookies = tu_user.cookies
resp = request.post(endpoint, data=data)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
assert resp.headers.get("location") == f"/pkgbase/{pkgbase.Name}"
......@@ -615,7 +625,8 @@ def test_request_post_orphan_autogenerated_closure(
endpoint = f"/pkgbase/{pkgbase.Name}/disown"
data = {"confirm": True}
with client as request:
resp = request.post(endpoint, data=data, cookies=tu_user.cookies)
request.cookies = tu_user.cookies
resp = request.post(endpoint, data=data)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
assert resp.headers.get("location") == f"/pkgbase/{pkgbase.Name}"
......@@ -677,7 +688,8 @@ def test_orphan_as_maintainer(client: TestClient, auser: User, pkgbase: PackageB
endpoint = f"/pkgbase/{pkgbase.Name}/disown"
data = {"confirm": True}
with client as request:
resp = request.post(endpoint, data=data, cookies=auser.cookies)
request.cookies = auser.cookies
resp = request.post(endpoint, data=data)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
assert resp.headers.get("location") == f"/pkgbase/{pkgbase.Name}"
......@@ -694,7 +706,8 @@ def test_orphan_without_requests(
endpoint = f"/pkgbase/{pkgbase.Name}/disown"
data = {"confirm": True}
with client as request:
resp = request.post(endpoint, data=data, cookies=tu_user.cookies)
request.cookies = tu_user.cookies
resp = request.post(endpoint, data=data)
assert resp.status_code == int(HTTPStatus.BAD_REQUEST)
errors = get_errors(resp.text)
......@@ -733,6 +746,7 @@ def test_requests(
):
cookies = {"AURSID": tu_user.login(Request(), "testPassword")}
with client as request:
request.cookies = cookies
resp = request.get(
"/requests",
params={
......@@ -742,7 +756,6 @@ def test_requests(
"SeB": "nd",
"SB": "n",
},
cookies=cookies,
)
assert resp.status_code == int(HTTPStatus.OK)
......@@ -756,7 +769,8 @@ def test_requests(
# Request page 2 of the requests page.
with client as request:
resp = request.get("/requests", params={"O": 50}, cookies=cookies) # Page 2
request.cookies = cookies
resp = request.get("/requests", params={"O": 50}) # Page 2
assert resp.status_code == int(HTTPStatus.OK)
assert "‹ Previous" in resp.text
......@@ -775,6 +789,7 @@ def test_requests_with_filters(
):
cookies = {"AURSID": tu_user.login(Request(), "testPassword")}
with client as request:
request.cookies = cookies
resp = request.get(
"/requests",
params={
......@@ -789,7 +804,6 @@ def test_requests_with_filters(
"filter_rejected": True,
"filter_maintainer_requests": False,
},
cookies=cookies,
)
assert resp.status_code == int(HTTPStatus.OK)
......@@ -803,6 +817,7 @@ def test_requests_with_filters(
# Request page 2 of the requests page.
with client as request:
request.cookies = cookies
resp = request.get(
"/requests",
params={
......@@ -813,7 +828,6 @@ def test_requests_with_filters(
"filter_rejected": True,
"filter_maintainer_requests": False,
},
cookies=cookies,
) # Page 2
assert resp.status_code == int(HTTPStatus.OK)
......@@ -833,10 +847,10 @@ def test_requests_for_maintainer_requests(
):
cookies = {"AURSID": tu_user.login(Request(), "testPassword")}
with client as request:
request.cookies = cookies
resp = request.get(
"/requests",
params={"filter_maintainer_requests": True},
cookies=cookies,
)
assert resp.status_code == int(HTTPStatus.OK)
......@@ -854,7 +868,8 @@ def test_requests_by_deleted_users(
cookies = {"AURSID": tu_user.login(Request(), "testPassword")}
with client as request:
resp = request.get("/requests", cookies=cookies)
request.cookies = cookies
resp = request.get("/requests")
assert resp.status_code == HTTPStatus.OK
root = parse_root(resp.text)
......@@ -867,7 +882,8 @@ def test_requests_selfmade(
):
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
resp = request.get("/requests", cookies=cookies)
request.cookies = cookies
resp = request.get("/requests")
assert resp.status_code == int(HTTPStatus.OK)
# As the user who creates all of the requests, we should see all of them.
......@@ -885,7 +901,8 @@ def test_requests_selfmade(
def test_requests_close(client: TestClient, user: User, pkgreq: PackageRequest):
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
resp = request.get(f"/requests/{pkgreq.ID}/close", cookies=cookies)
request.cookies = cookies
resp = request.get(f"/requests/{pkgreq.ID}/close")
assert resp.status_code == int(HTTPStatus.OK)
......@@ -894,7 +911,10 @@ def test_requests_close_unauthorized(
):
cookies = {"AURSID": maintainer.login(Request(), "testPassword")}
with client as request:
resp = request.get(f"/requests/{pkgreq.ID}/close", cookies=cookies)
request.cookies = cookies
resp = request.get(
f"/requests/{pkgreq.ID}/close",
)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
assert resp.headers.get("location") == "/"
......@@ -904,10 +924,10 @@ def test_requests_close_post_unauthorized(
):
cookies = {"AURSID": maintainer.login(Request(), "testPassword")}
with client as request:
request.cookies = cookies
resp = request.post(
f"/requests/{pkgreq.ID}/close",
data={"reason": ACCEPTED_ID},
cookies=cookies,
)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
assert resp.headers.get("location") == "/"
......@@ -916,7 +936,8 @@ def test_requests_close_post_unauthorized(
def test_requests_close_post(client: TestClient, user: User, pkgreq: PackageRequest):
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
resp = request.post(f"/requests/{pkgreq.ID}/close", cookies=cookies)
request.cookies = cookies
resp = request.post(f"/requests/{pkgreq.ID}/close")
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
assert pkgreq.Status == REJECTED_ID
......@@ -929,7 +950,10 @@ def test_requests_close_post_rejected(
):
cookies = {"AURSID": user.login(Request(), "testPassword")}
with client as request:
resp = request.post(f"/requests/{pkgreq.ID}/close", cookies=cookies)
request.cookies = cookies
resp = request.post(
f"/requests/{pkgreq.ID}/close",
)
assert resp.status_code == int(HTTPStatus.SEE_OTHER)
assert pkgreq.Status == REJECTED_ID
......
......@@ -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"