32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import pytest
|
|
from fastapi import status
|
|
|
|
def test_get_cards_for_group(client, auth_headers, test_group, test_card):
|
|
"""Test getting all cards for a group."""
|
|
response = client.get(f"/cards/{test_group.id}", headers=auth_headers)
|
|
assert response.status_code == 200
|
|
|
|
cards = response.json()
|
|
assert len(cards) >= 1
|
|
assert any(card["id"] == test_card.id for card in cards)
|
|
|
|
|
|
def test_get_cards_for_nonexistent_group(client, auth_headers):
|
|
"""Test getting cards for a non-existent group."""
|
|
response = client.get("/cards/99999", headers=auth_headers)
|
|
assert response.status_code == 200
|
|
|
|
cards = response.json()
|
|
assert len(cards) == 0 # Empty list for non-existent group
|
|
|
|
|
|
def test_card_operations_by_non_admin(client, test_group, user_auth_headers):
|
|
"""Test that non-admin users cannot perform card operations."""
|
|
# Try to add a card
|
|
response = client.post(f"/cards/{test_group.id}", headers=user_auth_headers)
|
|
assert response.status_code == 403
|
|
|
|
# Try to get cards
|
|
response = client.get(f"/cards/{test_group.id}", headers=user_auth_headers)
|
|
assert response.status_code == 403
|