Spaces:
Running
Running
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| def test_analytics_migration_is_additive_and_forces_rls() -> None: | |
| text = (ROOT / "app/social/migrations/0010_analytics_insights.sql").read_text() | |
| normalized = text.lower() | |
| assert "drop table" not in normalized | |
| for table in ( | |
| "analytics_sync_runs", | |
| "analytics_metric_snapshots", | |
| "analytics_post_metrics", | |
| "analytics_platform_metrics", | |
| ): | |
| assert f"create table if not exists {table}" in normalized | |
| assert normalized.count("force row level security") >= 1 | |
| assert "current_setting(''app.workspace_id''" in normalized | |
| def test_analytics_routes_and_transports_are_narrow() -> None: | |
| api = (ROOT / "app/analytics/api.py").read_text() | |
| mcp = (ROOT / "app/mcp/tools/analytics.py").read_text() | |
| sdk = (ROOT / "sdk/typescript/src/resources/analytics.ts").read_text() | |
| for route in ( | |
| '"/overview"', | |
| '"/timeseries"', | |
| '"/platforms"', | |
| '"/posts"', | |
| '"/sync"', | |
| ): | |
| assert route in api | |
| assert "execute analytics query" not in mcp.lower() | |
| assert "class AnalyticsResource" in sdk | |
| def test_analytics_never_fabricates_provider_metrics() -> None: | |
| service = (ROOT / "app/analytics/service.py").read_text() | |
| provider = (ROOT / "app/social/providers/base.py").read_text() | |
| assert "self.social_analytics.post" in service | |
| assert "get_metrics" in provider | |
| assert "random.randint" not in service | |