import pytest from .conftest import assert_collection_response ROUTE_PREFIX: str = "/api/users/" @pytest.mark.skip(reason="In progress, requires DB integration") class TestPermissions: endpoint = f"{ROUTE_PREFIX}permissions" class TestGetUserPermissions: mock_email = "john@doe.com" def test_single_user(self, test_client): """Test fetching permissions for a single email.""" response = test_client.get( f"{TestPermissions.endpoint}?email={self.mock_email}" ) assert response.status_code == 200, response.text # TODO add more assertions once the real permissions from DB are implemented def test_single_user_not_found(self, test_client): """Test fetching permissions for a non-existent email.""" # TODO: replace with a real email that does not exist in the DB response = test_client.get( f"{TestPermissions.endpoint}?email={self.mock_email}" ) assert response.status_code == 404, response.text class TestGetUsersPermissions: mock_email_count = 50 mock_emails = [f"john_doe_{i}@anycorp.com" for i in range(mock_email_count)] def test_users(self, test_client): """Test fetching permissions for multiple emails.""" limit = 3 response = test_client.post( TestPermissions.endpoint, json={"emails": self.mock_emails}, params={"limit": limit, "offset": 0}, ) assert_collection_response(response, expect_empty=False), response.text response_data = response.json()["data"] assert ( len(response_data) == limit ), f"Expected {limit} records, but got {len(response_data)}" # TODO add more assertions once the real permissions from DB are implemented class TestGetPermissionsMetadata: def test_metadata(self, test_client): """Test fetching permission metadata.""" response = test_client.get(f"{TestPermissions.endpoint}/meta") assert response.status_code == 200, response.text # TODO add more assertions once the real permissions from DB are implemented