Fix tests using the new api root

This commit is contained in:
2026-06-24 15:54:06 +02:00
parent bc663582b5
commit 17842a14fd
7 changed files with 56 additions and 56 deletions
+21 -21
View File
@@ -13,7 +13,7 @@ def test_create_access_auth(client, auth_headers):
]
}
response = client.post("/aa/", json=aa_data, headers=auth_headers)
response = client.post("/api/v1/aa/", json=aa_data, headers=auth_headers)
assert response.status_code == 200
data = response.json()
@@ -25,7 +25,7 @@ def test_create_access_auth(client, auth_headers):
def test_get_all_access_auths(client, auth_headers, test_aa):
"""Test retrieving all access authorizations."""
response = client.get("/aa/", headers=auth_headers)
response = client.get("/api/v1/aa/", headers=auth_headers)
assert response.status_code == 200
aa_list = response.json()
@@ -37,7 +37,7 @@ def test_get_all_access_auths(client, auth_headers, test_aa):
def test_get_access_auth_by_id(client, auth_headers, test_aa):
"""Test retrieving a specific access authorization by ID."""
response = client.get(f"/aa/{test_aa.id}", headers=auth_headers)
response = client.get(f"/api/v1/aa/{test_aa.id}", headers=auth_headers)
assert response.status_code == 200
data = response.json()
@@ -47,14 +47,14 @@ def test_get_access_auth_by_id(client, auth_headers, test_aa):
def test_get_nonexistent_access_auth(client, auth_headers):
"""Test retrieving a non-existent access authorization."""
response = client.get("/aa/99999", headers=auth_headers)
response = client.get("/api/v1/aa/99999", headers=auth_headers)
assert response.status_code == 404
def test_assign_access_auth_to_group(client, auth_headers, test_group, test_aa):
"""Test assigning an access authorization to a group."""
response = client.put(
f"/aa/assign/{test_group.id}/{test_aa.id}",
f"/api/v1/aa/assign/{test_group.id}/{test_aa.id}",
headers=auth_headers
)
assert response.status_code == 200
@@ -68,11 +68,11 @@ def test_assign_access_auth_to_group(client, auth_headers, test_group, test_aa):
def test_assign_already_assigned_access_auth(client, auth_headers, test_group, test_aa):
"""Test assigning an already assigned access authorization."""
# First assignment
client.put(f"/aa/assign/{test_group.id}/{test_aa.id}", headers=auth_headers)
client.put(f"/api/v1/aa/assign/{test_group.id}/{test_aa.id}", headers=auth_headers)
# Second assignment should indicate it's already assigned
response = client.put(
f"/aa/assign/{test_group.id}/{test_aa.id}",
f"/api/v1/aa/assign/{test_group.id}/{test_aa.id}",
headers=auth_headers
)
# According to the code, this returns 409 with "already assigned" message
@@ -83,11 +83,11 @@ def test_assign_already_assigned_access_auth(client, auth_headers, test_group, t
def test_unassign_access_auth_from_group(client, auth_headers, test_group, test_aa):
"""Test unassigning an access authorization from a group."""
# First assign
client.put(f"/aa/assign/{test_group.id}/{test_aa.id}", headers=auth_headers)
client.put(f"/api/v1/aa/assign/{test_group.id}/{test_aa.id}", headers=auth_headers)
# Then unassign
response = client.put(
f"/aa/unassign/{test_group.id}/{test_aa.id}",
f"/api/v1/aa/unassign/{test_group.id}/{test_aa.id}",
headers=auth_headers
)
assert response.status_code == 200
@@ -96,7 +96,7 @@ def test_unassign_access_auth_from_group(client, auth_headers, test_group, test_
def test_unassign_nonexistent_assignment(client, auth_headers, test_group, test_aa):
"""Test unassigning a non-existent assignment."""
response = client.put(
f"/aa/unassign/{test_group.id}/{test_aa.id}",
f"/api/v1/aa/unassign/{test_group.id}/{test_aa.id}",
headers=auth_headers
)
assert response.status_code == 404
@@ -104,13 +104,13 @@ def test_unassign_nonexistent_assignment(client, auth_headers, test_group, test_
def test_assign_to_nonexistent_group(client, auth_headers, test_aa):
"""Test assigning an AA to a non-existent group."""
response = client.put(f"/aa/assign/99999/{test_aa.id}", headers=auth_headers)
response = client.put(f"/api/v1/aa/assign/99999/{test_aa.id}", headers=auth_headers)
assert response.status_code == 404
def test_assign_nonexistent_aa(client, auth_headers, test_group):
"""Test assigning a non-existent AA to a group."""
response = client.put(f"/aa/assign/{test_group.id}/99999", headers=auth_headers)
response = client.put(f"/api/v1/aa/assign/{test_group.id}/99999", headers=auth_headers)
assert response.status_code == 404
@@ -122,7 +122,7 @@ def test_update_access_auth(client, auth_headers, test_aa):
}
response = client.patch(
f"/aa/{test_aa.id}",
f"/api/v1/aa/{test_aa.id}",
json=update_data,
headers=auth_headers
)
@@ -142,7 +142,7 @@ def test_update_access_auth_with_timetables(client, auth_headers, test_aa):
}
response = client.patch(
f"/aa/{test_aa.id}",
f"/api/v1/aa/{test_aa.id}",
json=update_data,
headers=auth_headers
)
@@ -157,24 +157,24 @@ def test_update_access_auth_with_timetables(client, auth_headers, test_aa):
def test_update_nonexistent_access_auth(client, auth_headers):
"""Test updating a non-existent access authorization."""
update_data = {"name": "Updated"}
response = client.patch("/aa/99999", json=update_data, headers=auth_headers)
response = client.patch("/api/v1/aa/99999", json=update_data, headers=auth_headers)
assert response.status_code == 404
def test_delete_access_auth(client, auth_headers, test_aa):
"""Test deleting an access authorization."""
response = client.delete(f"/aa/{test_aa.id}", headers=auth_headers)
response = client.delete(f"/api/v1/aa/{test_aa.id}", headers=auth_headers)
assert response.status_code == 200
assert "deleted successfully" in response.json()["message"].lower()
# Verify AA is deleted
response = client.get(f"/aa/{test_aa.id}", headers=auth_headers)
response = client.get(f"/api/v1/aa/{test_aa.id}", headers=auth_headers)
assert response.status_code == 404
def test_delete_nonexistent_access_auth(client, auth_headers):
"""Test deleting a non-existent access authorization."""
response = client.delete("/aa/99999", headers=auth_headers)
response = client.delete("/api/v1/aa/99999", headers=auth_headers)
assert response.status_code == 404
@@ -182,16 +182,16 @@ def test_aa_operations_by_non_admin(client, test_aa, user_auth_headers):
"""Test that non-admin users cannot perform AA operations."""
# Try to create an AA
response = client.post(
"/aa/",
"/api/v1/aa/",
json={"name": "test", "is_active": True, "timetables": []},
headers=user_auth_headers
)
assert response.status_code == 403
# Try to get all AAs
response = client.get("/aa/", headers=user_auth_headers)
response = client.get("/api/v1/aa/", headers=user_auth_headers)
assert response.status_code == 403
# Try to assign AA
response = client.put(f"/aa/assign/1/{test_aa.id}", headers=user_auth_headers)
response = client.put(f"/api/v1/aa/assign/1/{test_aa.id}", headers=user_auth_headers)
assert response.status_code == 403