diff --git a/tests/integration/test_oauth_interactive.py b/tests/integration/test_oauth_interactive.py index fdd4402..e107b10 100644 --- a/tests/integration/test_oauth_interactive.py +++ b/tests/integration/test_oauth_interactive.py @@ -1,7 +1,7 @@ """Interactive integration tests for OAuth authentication.""" -import os import logging +import os import pytest diff --git a/tests/integration/test_oauth_playwright.py b/tests/integration/test_oauth_playwright.py index 2a6fc6c..9b5ccb7 100644 --- a/tests/integration/test_oauth_playwright.py +++ b/tests/integration/test_oauth_playwright.py @@ -9,51 +9,46 @@ logger = logging.getLogger(__name__) pytestmark = [pytest.mark.integration, pytest.mark.oauth] -class TestOAuthPlaywright: - """Test automated Playwright OAuth authentication.""" +async def test_playwright_oauth_token_acquisition(playwright_oauth_token: str): + """Test that Playwright can acquire an OAuth token automatically.""" + assert playwright_oauth_token is not None + assert isinstance(playwright_oauth_token, str) + assert len(playwright_oauth_token) > 0 + logger.info( + f"Successfully acquired OAuth token via Playwright: {playwright_oauth_token[:20]}..." + ) - async def test_playwright_oauth_token_acquisition( - self, playwright_oauth_token: str - ): - """Test that Playwright can acquire an OAuth token automatically.""" - assert playwright_oauth_token is not None - assert isinstance(playwright_oauth_token, str) - assert len(playwright_oauth_token) > 0 - logger.info( - f"Successfully acquired OAuth token via Playwright: {playwright_oauth_token[:20]}..." - ) - async def test_oauth_client_with_playwright_flow(self, nc_oauth_client_playwright): - """Test that OAuth client created via Playwright flow can access Nextcloud APIs.""" - # Test 1: Check capabilities - capabilities = await nc_oauth_client_playwright.capabilities() - assert capabilities is not None - logger.info("OAuth client (Playwright) successfully fetched capabilities") +async def test_oauth_client_with_playwright_flow(nc_oauth_client_playwright): + """Test that OAuth client created via Playwright flow can access Nextcloud APIs.""" + # Test 1: Check capabilities + capabilities = await nc_oauth_client_playwright.capabilities() + assert capabilities is not None + logger.info("OAuth client (Playwright) successfully fetched capabilities") - # Test 2: List notes - notes = await nc_oauth_client_playwright.notes.get_all_notes() - assert isinstance(notes, list) - logger.info(f"OAuth client (Playwright) successfully listed {len(notes)} notes") + # Test 2: List notes + notes = await nc_oauth_client_playwright.notes.get_all_notes() + assert isinstance(notes, list) + logger.info(f"OAuth client (Playwright) successfully listed {len(notes)} notes") - async def test_mcp_oauth_client_with_playwright( - self, nc_mcp_oauth_client_playwright - ): - """Test that MCP OAuth client via Playwright can execute tools.""" - import json - # Test: Execute the 'nc_notes_search_notes' tool - result = await nc_mcp_oauth_client_playwright.call_tool( - "nc_notes_search_notes", arguments={"query": ""} - ) +async def test_mcp_oauth_client_with_playwright(nc_mcp_oauth_client_playwright): + """Test that MCP OAuth client via Playwright can execute tools.""" + import json - assert result.isError is False, f"Tool execution failed: {result.content}" - assert result.content is not None - response_data = json.loads(result.content[0].text) + # Test: Execute the 'nc_notes_search_notes' tool + result = await nc_mcp_oauth_client_playwright.call_tool( + "nc_notes_search_notes", arguments={"query": ""} + ) - # The search response should have a 'results' field containing the list - assert "results" in response_data - assert isinstance(response_data["results"], list) + assert result.isError is False, f"Tool execution failed: {result.content}" + assert result.content is not None + response_data = json.loads(result.content[0].text) - logger.info( - f"Successfully executed 'nc_notes_search_notes' tool on Playwright OAuth MCP server and got {len(response_data['results'])} notes." - ) + # The search response should have a 'results' field containing the list + assert "results" in response_data + assert isinstance(response_data["results"], list) + + logger.info( + f"Successfully executed 'nc_notes_search_notes' tool on Playwright OAuth MCP server and got {len(response_data['results'])} notes." + )