[Tests] add card manager PATCH tests
This commit is contained in:
@@ -29,3 +29,47 @@ def test_card_operations_by_non_admin(client, test_group, user_auth_headers):
|
||||
# Try to get cards
|
||||
response = client.get(f"/api/v1/cards/{test_group.id}", headers=user_auth_headers)
|
||||
assert response.status_code == 403
|
||||
|
||||
def test_update_card(client, auth_headers, test_group, test_card):
|
||||
"""Test Patching a card entity"""
|
||||
update_data = {
|
||||
"name": "changed_name",
|
||||
"enabled": "False"
|
||||
}
|
||||
|
||||
response = client.patch(
|
||||
f"/api/v1/cards/{test_card.id}",
|
||||
json=update_data,
|
||||
headers=auth_headers
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
data = response.json()
|
||||
assert data["name"] == "changed_name"
|
||||
assert data["enabled"] == False
|
||||
assert data["group_id"] == test_card.group_id
|
||||
|
||||
def test_update_wrong_card(client, auth_headers, test_group, test_card):
|
||||
"""Test Patching a card entity"""
|
||||
|
||||
response = client.patch(
|
||||
f"/api/v1/cards/9999",
|
||||
json={},
|
||||
headers=auth_headers
|
||||
)
|
||||
assert response.status_code == 404
|
||||
assert "Card not found" in response.json()["detail"]
|
||||
|
||||
def test_update_card_with_wrong_group(client, auth_headers, test_group, test_card):
|
||||
"""Test Patching a card entity with wrong group"""
|
||||
update_data = {
|
||||
"group_id": "9999"
|
||||
}
|
||||
|
||||
response = client.patch(
|
||||
f"/api/v1/cards/{test_card.id}",
|
||||
json=update_data,
|
||||
headers=auth_headers
|
||||
)
|
||||
assert response.status_code == 404
|
||||
assert "GroupID not found" in response.json()["detail"]
|
||||
Reference in New Issue
Block a user