personal memory agent
1# SPDX-License-Identifier: AGPL-3.0-only
2# Copyright (c) 2026 sol pbc
3
4"""Tests for Convey app endpoints.
5
6Tests that all apps with workspace.html can be accessed via /app/{app_name}
7using Flask's in-process test client.
8"""
9
10from pathlib import Path
11
12import pytest
13
14from convey import create_app
15
16
17def get_app_names() -> list[str]:
18 """Get list of app names from apps/ directory.
19
20 Returns app names for all apps with workspace.html.
21 """
22 project_root = Path(__file__).parent.parent.parent
23 apps_dir = project_root / "apps"
24
25 app_names = []
26 for app_path in apps_dir.iterdir():
27 if app_path.is_dir() and (app_path / "workspace.html").exists():
28 app_names.append(app_path.name)
29
30 return sorted(app_names)
31
32
33@pytest.fixture(scope="session")
34def convey_client():
35 """Create an in-process Convey Flask test client."""
36 journal = str(
37 Path(__file__).resolve().parent.parent.parent / "tests" / "fixtures" / "journal"
38 )
39 app = create_app(journal)
40 return app.test_client()
41
42
43@pytest.mark.parametrize("app_name", get_app_names())
44def test_app_endpoint(convey_client, app_name: str):
45 """Test that each app endpoint returns 200."""
46 route = f"/app/{app_name}"
47 response = convey_client.get(route, follow_redirects=True)
48
49 assert response.status_code == 200, (
50 f"App '{app_name}' at {route} returned {response.status_code}. "
51 "Always use 'make screenshot' to validate this failure"
52 )