# tests/test_admin.py import pytest class TestAdminAPI: def test_get_all_users_admin(self, client, admin_headers, test_user): """Test admin getting all users""" response = client.get("/api/v1/admin/users", headers=admin_headers) assert response.status_code == 200 data = response.json() assert len(data) >= 2 # test_user + admin user def test_get_all_users_non_admin(self, client, auth_headers): """Test non-admin trying to access admin endpoint""" response = client.get("/api/v1/admin/users", headers=auth_headers) assert response.status_code == 403 assert "Access denied" in response.json()["detail"] or "admin" in response.json()["detail"].lower() def test_toggle_user_status_admin(self, client, admin_headers, test_user): """Test admin toggling user status""" response = client.put(f"/api/v1/admin/users/{test_user.id}/status", headers=admin_headers) assert response.status_code == 200 assert "deactivated" in response.json()["message"] or "activated" in response.json()["message"] def test_get_all_shops_admin(self, client, admin_headers, test_shop): """Test admin getting all shops""" response = client.get("/api/v1/admin/shops", headers=admin_headers) assert response.status_code == 200 data = response.json() assert data["total"] >= 1