AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
test(backend): request the app stack in the search tests that need it, and drop the dead graph_cleanup overrides (#15338)
Reinier van der Leer5733e9278a85
diff --git a/autogpt_platform/backend/backend/api/features/integrations/conftest.py b/autogpt_platform/backend/backend/api/features/integrations/conftest.pyindex d87d125707..be2a64c56f 100644--- a/autogpt_platform/backend/backend/api/features/integrations/conftest.py+++ b/autogpt_platform/backend/backend/api/features/integrations/conftest.py@@ -6,8 +6,3 @@ import pytest@pytest.fixture(scope="session")def server():yield None--[email protected](scope="session", autouse=True)-def graph_cleanup():- yielddiff --git a/autogpt_platform/backend/backend/api/features/mailerlite/routes_test.py b/autogpt_platform/backend/backend/api/features/mailerlite/routes_test.pyindex ba0d1d4e6b..2dcd313774 100644--- a/autogpt_platform/backend/backend/api/features/mailerlite/routes_test.py+++ b/autogpt_platform/backend/backend/api/features/mailerlite/routes_test.py@@ -4,7 +4,6 @@ with the webhook's secret can."""import hashlibimport hmacimport json-from collections.abc import Iteratorfrom unittest.mock import AsyncMockimport fastapi@@ -33,11 +32,6 @@ def server() -> None:return None[email protected](scope="session", autouse=True)-def graph_cleanup() -> Iterator[None]:- yield--@pytest.fixture(autouse=True)def secret(monkeypatch: pytest.MonkeyPatch) -> None:monkeypatch.setattr(routes.settings.secrets, "mailerlite_webhook_secret", SECRET)diff --git a/autogpt_platform/backend/backend/api/features/mcp/conftest.py b/autogpt_platform/backend/backend/api/features/mcp/conftest.pyindex d87d125707..be2a64c56f 100644--- a/autogpt_platform/backend/backend/api/features/mcp/conftest.py+++ b/autogpt_platform/backend/backend/api/features/mcp/conftest.py@@ -6,8 +6,3 @@ import pytest@pytest.fixture(scope="session")def server():yield None--[email protected](scope="session", autouse=True)-def graph_cleanup():- yielddiff --git a/autogpt_platform/backend/backend/api/features/orgs/conftest.py b/autogpt_platform/backend/backend/api/features/orgs/conftest.pyindex 41ec85b2f7..5026d8eff0 100644--- a/autogpt_platform/backend/backend/api/features/orgs/conftest.py+++ b/autogpt_platform/backend/backend/api/features/orgs/conftest.py@@ -11,9 +11,3 @@ import pytestdef server():"""No-op — org tests don't need the full backend server."""yield None--[email protected](scope="session", autouse=True)-def graph_cleanup():- """No-op — org tests don't create real graphs."""- yielddiff --git a/autogpt_platform/backend/backend/api/features/search/content_handlers_integration_test.py b/autogpt_platform/backend/backend/api/features/search/content_handlers_integration_test.pyindex bfd819e0fb..f20605631a 100644--- a/autogpt_platform/backend/backend/api/features/search/content_handlers_integration_test.py+++ b/autogpt_platform/backend/backend/api/features/search/content_handlers_integration_test.py@@ -42,7 +42,7 @@ async def _first_db_call(coro_factory):@pytest.mark.asyncio(loop_scope="session")-async def test_store_agent_handler_real_db():+async def test_store_agent_handler_real_db(server):"""Test StoreAgentHandler with real database queries."""handler = StoreAgentHandler()@@ -72,7 +72,7 @@ async def test_store_agent_handler_real_db():@pytest.mark.asyncio(loop_scope="session")-async def test_block_handler_real_db():+async def test_block_handler_real_db(server):"""Test BlockHandler with real database queries."""handler = BlockHandler()@@ -102,7 +102,7 @@ async def test_block_handler_real_db():@pytest.mark.asyncio(loop_scope="session")-async def test_documentation_handler_real_fs():+async def test_documentation_handler_real_fs(server):"""Test DocumentationHandler with real filesystem."""handler = DocumentationHandler()@@ -132,7 +132,7 @@ async def test_documentation_handler_real_fs():@pytest.mark.asyncio(loop_scope="session")-async def test_get_embedding_stats_all_types():+async def test_get_embedding_stats_all_types(server):"""Test get_embedding_stats aggregates all content types."""stats = await get_embedding_stats()@@ -156,7 +156,7 @@ async def test_get_embedding_stats_all_types():@pytest.mark.asyncio(loop_scope="session")@patch("backend.api.features.search.embeddings.generate_embedding")-async def test_ensure_content_embedding_blocks(mock_generate):+async def test_ensure_content_embedding_blocks(mock_generate, server):"""Test creating embeddings for blocks (mocked OpenAI)."""# Mock OpenAI to return fake embeddingmock_generate.return_value = [0.1] * EMBEDDING_DIM@@ -186,7 +186,7 @@ async def test_ensure_content_embedding_blocks(mock_generate):@pytest.mark.asyncio(loop_scope="session")@patch("backend.api.features.search.embeddings.generate_embedding")-async def test_backfill_all_content_types_dry_run(mock_generate):+async def test_backfill_all_content_types_dry_run(mock_generate, server):"""Test backfill_all_content_types processes all handlers in order."""# Mock OpenAI to return fake embeddingmock_generate.return_value = [0.1] * EMBEDDING_DIMdiff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/conftest.py b/autogpt_platform/backend/backend/blocks/dataforb2b/conftest.pyindex f3e4fba99b..3a793264b7 100644--- a/autogpt_platform/backend/backend/blocks/dataforb2b/conftest.py+++ b/autogpt_platform/backend/backend/blocks/dataforb2b/conftest.py@@ -1,15 +1,8 @@"""Keep DataForB2B unit tests independent of platform services."""-from collections.abc import AsyncIterator-import pytest_asyncio@pytest_asyncio.fixture(scope="session", loop_scope="session")async def server() -> None:return None---@pytest_asyncio.fixture(scope="session", loop_scope="session", autouse=True)-async def graph_cleanup() -> AsyncIterator[None]:- yielddiff --git a/autogpt_platform/backend/backend/blocks/slant3d/conftest.py b/autogpt_platform/backend/backend/blocks/slant3d/conftest.pyindex bf36439d77..26d3debaf8 100644--- a/autogpt_platform/backend/backend/blocks/slant3d/conftest.py+++ b/autogpt_platform/backend/backend/blocks/slant3d/conftest.py@@ -1,13 +1,6 @@-from collections.abc import AsyncIterator-import pytest_asyncio@pytest_asyncio.fixture(scope="session", loop_scope="session")async def server() -> None:return None---@pytest_asyncio.fixture(scope="session", loop_scope="session", autouse=True)-async def graph_cleanup() -> AsyncIterator[None]:- yielddiff --git a/autogpt_platform/backend/backend/cli/mailerlite_backfill_test.py b/autogpt_platform/backend/backend/cli/mailerlite_backfill_test.pyindex 8386c8be3c..b7a36a5bc5 100644--- a/autogpt_platform/backend/backend/cli/mailerlite_backfill_test.py+++ b/autogpt_platform/backend/backend/cli/mailerlite_backfill_test.py@@ -31,11 +31,6 @@ def server():yield None[email protected](scope="session", autouse=True)-def graph_cleanup():- yield--def test_a_complete_run_reports_and_succeeds(capsys):cli._finish_checkout(5, 0, 2)out = capsys.readouterr().outdiff --git a/autogpt_platform/backend/backend/cli/onboarding_role_backfill_test.py b/autogpt_platform/backend/backend/cli/onboarding_role_backfill_test.pyindex c2c15b92d7..4b8a1c9165 100644--- a/autogpt_platform/backend/backend/cli/onboarding_role_backfill_test.py+++ b/autogpt_platform/backend/backend/cli/onboarding_role_backfill_test.py@@ -26,11 +26,6 @@ def server():yield None[email protected](scope="session", autouse=True)-def graph_cleanup():- yield--def test_the_dry_run_report_counts_reliable_and_skipped(capsys):records = [RoleRecord(user_id="1", email="[email protected]", choice="Marketing"),diff --git a/autogpt_platform/backend/backend/copilot/codex_model_router_test.py b/autogpt_platform/backend/backend/copilot/codex_model_router_test.pyindex dd4bb87fa1..131daebd9c 100644--- a/autogpt_platform/backend/backend/copilot/codex_model_router_test.py+++ b/autogpt_platform/backend/backend/copilot/codex_model_router_test.py@@ -14,11 +14,6 @@ def _server_noop():return None[email protected](scope="session", autouse=True, name="graph_cleanup")-def _graph_cleanup_noop():- yield--def _model(model: str,*,diff --git a/autogpt_platform/backend/backend/copilot/dream_events_test.py b/autogpt_platform/backend/backend/copilot/dream_events_test.pyindex 6a4109879a..e16800200a 100644--- a/autogpt_platform/backend/backend/copilot/dream_events_test.py+++ b/autogpt_platform/backend/backend/copilot/dream_events_test.py@@ -8,7 +8,6 @@ has to import the helper and pass an emit closure.from __future__ import annotationsimport json-from collections.abc import AsyncIteratorimport pytestimport pytest_asyncio@@ -34,13 +33,6 @@ async def _server_noop() -> None:return None-@pytest_asyncio.fixture(- scope="session", loop_scope="session", autouse=True, name="graph_cleanup"-)-async def _graph_cleanup_noop() -> AsyncIterator[None]:- yield--def _sample_snapshot() -> DreamOperationsSnapshot:"""Build a non-trivial snapshot exercising every field."""return DreamOperationsSnapshot(diff --git a/autogpt_platform/backend/backend/copilot/graphiti/conftest.py b/autogpt_platform/backend/backend/copilot/graphiti/conftest.pyindex 4484ba66d5..ccaa1ce4c2 100644--- a/autogpt_platform/backend/backend/copilot/graphiti/conftest.py+++ b/autogpt_platform/backend/backend/copilot/graphiti/conftest.py@@ -4,7 +4,7 @@ Two responsibilities:1. **Opt out of the full SpinTestServer.** Mirrors``backend/copilot/tools/conftest.py`` — these tests don't need- postgres + rabbitmq + the platform-wide ``graph_cleanup`` autouse.+ postgres + rabbitmq.2. **Provide FalkorDB integration fixtures.** Tests marked``@pytest.mark.integration`` use the ``clean_graph`` and@@ -139,12 +139,6 @@ async def server(): # type: ignore[override]return None-@pytest_asyncio.fixture(scope="session", loop_scope="session", autouse=True)-async def graph_cleanup(): # type: ignore[override]- """No-op graph cleanup stub."""- yield--@pytest.fixture(scope="session")def falkordb_available() -> bool:"""Skip the calling integration suite if FalkorDB is unreachable.diff --git a/autogpt_platform/backend/backend/copilot/graphiti/dream_ratification_integration_test.py b/autogpt_platform/backend/backend/copilot/graphiti/dream_ratification_integration_test.pyindex 6aab3c3553..4213badf02 100644--- a/autogpt_platform/backend/backend/copilot/graphiti/dream_ratification_integration_test.py+++ b/autogpt_platform/backend/backend/copilot/graphiti/dream_ratification_integration_test.py@@ -19,7 +19,7 @@ Only the LLM boundary is stubbed — no API key, no network.Lives in ``graphiti/`` rather than ``dream/`` for the local conftest, whichsupplies the ``falkordb_available`` skip guard, the stubbed Graphiti client,-and the no-op ``server`` / ``graph_cleanup`` overrides that keep this suite+and the no-op ``server`` override that keeps this suiteoff SpinTestServer (postgres + rabbitmq). ``dream/`` has no conftest, andadding one would change how the existing dream unit tests run.diff --git a/autogpt_platform/backend/backend/copilot/sdk/conftest.py b/autogpt_platform/backend/backend/copilot/sdk/conftest.pyindex 0337044742..fc01a40ab5 100644--- a/autogpt_platform/backend/backend/copilot/sdk/conftest.py+++ b/autogpt_platform/backend/backend/copilot/sdk/conftest.py@@ -2,7 +2,6 @@from __future__ import annotations-from collections.abc import AsyncIteratorfrom unittest.mock import AsyncMock, patchfrom uuid import uuid4@@ -66,14 +65,6 @@ async def _server_noop() -> None:return None-@pytest_asyncio.fixture(- scope="session", loop_scope="session", autouse=True, name="graph_cleanup"-)-async def _graph_cleanup_noop() -> AsyncIterator[None]:- """No-op graph cleanup stub."""- yield--@pytest.fixture()def mock_chat_config():"""Mock ChatConfig so compact_transcript tests skip real config lookup."""diff --git a/autogpt_platform/backend/backend/copilot/stream_drift/conftest.py b/autogpt_platform/backend/backend/copilot/stream_drift/conftest.pyindex 7288e6561f..1d0ea4e7b0 100644--- a/autogpt_platform/backend/backend/copilot/stream_drift/conftest.py+++ b/autogpt_platform/backend/backend/copilot/stream_drift/conftest.py@@ -21,11 +21,6 @@ async def server(): # type: ignore[override]return None-@pytest_asyncio.fixture(scope="session", loop_scope="session", autouse=True)-async def graph_cleanup(): # type: ignore[override]- yield--@pytest.fixturedef baseline_io(monkeypatch: pytest.MonkeyPatch, baseline_offline: Nonediff --git a/autogpt_platform/backend/backend/copilot/stream_heartbeat_test.py b/autogpt_platform/backend/backend/copilot/stream_heartbeat_test.pyindex a8754d682b..48b19fe342 100644--- a/autogpt_platform/backend/backend/copilot/stream_heartbeat_test.py+++ b/autogpt_platform/backend/backend/copilot/stream_heartbeat_test.py@@ -7,7 +7,7 @@ schedule (sub-second thresholds) so they run quickly without flakiness."""import asyncio-from collections.abc import AsyncGenerator, AsyncIterator+from collections.abc import AsyncGeneratorimport pytestimport pytest_asyncio@@ -30,13 +30,6 @@ async def _server_noop() -> None:return None-@pytest_asyncio.fixture(- scope="session", loop_scope="session", autouse=True, name="graph_cleanup"-)-async def _graph_cleanup_noop() -> AsyncIterator[None]:- yield--@pytest.mark.asyncioasync def test_emits_status_after_silent_threshold():"""When no event is bumped, the watchdog fires the first scheduleddiff --git a/autogpt_platform/backend/backend/copilot/tools/conftest.py b/autogpt_platform/backend/backend/copilot/tools/conftest.pyindex 53ec890f6c..52c40178f2 100644--- a/autogpt_platform/backend/backend/copilot/tools/conftest.py+++ b/autogpt_platform/backend/backend/copilot/tools/conftest.py@@ -1,6 +1,6 @@"""Local conftest for copilot/tools tests.-Overrides the session-scoped `server` and `graph_cleanup` autouse fixtures from+Overrides the session-scoped `server` fixture frombackend/conftest.py so that integration tests in this directory do not triggerthe full SpinTestServer startup (which requires Postgres + RabbitMQ)."""@@ -17,12 +17,6 @@ async def server(): # type: ignore[override]return None-@pytest_asyncio.fixture(scope="session", loop_scope="session", autouse=True)-async def graph_cleanup(): # type: ignore[override]- """No-op graph cleanup stub."""- yield--@pytest.fixture(autouse=True)def stub_user_lookup_in_helpers(monkeypatch):"""Stub the ``user_db()`` accessor ONLY for the helpers.py-local binding.diff --git a/autogpt_platform/backend/backend/data/checkout_audience_test.py b/autogpt_platform/backend/backend/data/checkout_audience_test.pyindex b9524f2da4..cf64cc0d9d 100644--- a/autogpt_platform/backend/backend/data/checkout_audience_test.py+++ b/autogpt_platform/backend/backend/data/checkout_audience_test.py@@ -41,11 +41,6 @@ def server():yield None[email protected](scope="session", autouse=True)-def graph_cleanup():- yield--# ── queueing it ──────────────────────────────────────────────────────────────diff --git a/autogpt_platform/backend/backend/data/db_test.py b/autogpt_platform/backend/backend/data/db_test.pyindex 3fd1419fa0..2ebf3f48d1 100644--- a/autogpt_platform/backend/backend/data/db_test.py+++ b/autogpt_platform/backend/backend/data/db_test.py@@ -15,11 +15,6 @@ def server():yield None[email protected](scope="session", autouse=True)-def graph_cleanup():- yield--async def test_disconnect_bounds_the_engine_shutdown(monkeypatch):"""Prisma's shutdown wait is unbounded unless a timeout is handed to it.diff --git a/autogpt_platform/backend/backend/data/onboarding_audience_test.py b/autogpt_platform/backend/backend/data/onboarding_audience_test.pyindex 7032a4b2f5..4b8a8a98e4 100644--- a/autogpt_platform/backend/backend/data/onboarding_audience_test.py+++ b/autogpt_platform/backend/backend/data/onboarding_audience_test.py@@ -29,11 +29,6 @@ def server():yield None[email protected](scope="session", autouse=True)-def graph_cleanup():- yield--def _user(**overrides) -> SimpleNamespace:fields = dict(email=EMAIL, timezone="America/Chicago", marketing_opt_out_at=None)return SimpleNamespace(**{**fields, **overrides})diff --git a/autogpt_platform/backend/backend/data/onboarding_role_test.py b/autogpt_platform/backend/backend/data/onboarding_role_test.pyindex 6dbe77bd72..d5b0c14cf6 100644--- a/autogpt_platform/backend/backend/data/onboarding_role_test.py+++ b/autogpt_platform/backend/backend/data/onboarding_role_test.py@@ -19,11 +19,6 @@ def server():yield None[email protected](scope="session", autouse=True)-def graph_cleanup():- yield--@pytest.mark.parametrize("answer, choice, other, label",[diff --git a/autogpt_platform/backend/backend/notifications/briefing_runner_test.py b/autogpt_platform/backend/backend/notifications/briefing_runner_test.pyindex ba3b15c97f..d74765cc91 100644--- a/autogpt_platform/backend/backend/notifications/briefing_runner_test.py+++ b/autogpt_platform/backend/backend/notifications/briefing_runner_test.py@@ -1,6 +1,5 @@"""Scheduling and queue hand-off tests for alerts and Briefings."""-from collections.abc import Iteratorfrom datetime import datetime, timedelta, timezonefrom types import SimpleNamespacefrom unittest.mock import AsyncMock, patch@@ -21,11 +20,6 @@ def server() -> None:return None[email protected](scope="session", autouse=True)-def graph_cleanup() -> Iterator[None]:- yield--def _candidates(users: list) -> object:"""Stand-in for the paged async generator `_briefing_candidates` returns."""diff --git a/autogpt_platform/backend/backend/notifications/conftest.py b/autogpt_platform/backend/backend/notifications/conftest.pyindex f79773bac1..1feba7126f 100644--- a/autogpt_platform/backend/backend/notifications/conftest.py+++ b/autogpt_platform/backend/backend/notifications/conftest.py@@ -13,7 +13,6 @@ a module that reaches past the RPC fails its test rather than passing it.from datetime import datetime, timezonefrom types import SimpleNamespace-from typing import Iteratorfrom unittest.mock import AsyncMockimport pytest@@ -32,11 +31,6 @@ def server() -> None:return None[email protected](scope="session", autouse=True)-def graph_cleanup() -> Iterator[None]:- yield--def make_db_client(**overrides) -> SimpleNamespace:"""A stand-in `DatabaseManagerAsyncClient`.diff --git a/autogpt_platform/backend/backend/notifications/consumer_test.py b/autogpt_platform/backend/backend/notifications/consumer_test.pyindex 141ea7daa2..0a1b748f10 100644--- a/autogpt_platform/backend/backend/notifications/consumer_test.py+++ b/autogpt_platform/backend/backend/notifications/consumer_test.py@@ -8,7 +8,6 @@ takes its siblings down with it so a restart cannot double-consume.import asyncioimport inspect-from collections.abc import Iteratorfrom typing import Anyfrom unittest.mock import AsyncMock, MagicMock, patch@@ -25,11 +24,6 @@ def server() -> None:return None[email protected](scope="session", autouse=True)-def graph_cleanup() -> Iterator[None]:- yield--def _manager() -> NotificationManager:manager = NotificationManager.__new__(NotificationManager)manager.running = Truediff --git a/autogpt_platform/backend/backend/notifications/notifications_test.py b/autogpt_platform/backend/backend/notifications/notifications_test.pyindex 5e49648281..2dc198bb80 100644--- a/autogpt_platform/backend/backend/notifications/notifications_test.py+++ b/autogpt_platform/backend/backend/notifications/notifications_test.py@@ -7,7 +7,6 @@ suppress a resend, so an overlap is a duplicate email, not just wasted work."""import asyncio-from collections.abc import Iteratorimport pytest@@ -19,11 +18,6 @@ def server() -> None:return None[email protected](scope="session", autouse=True)-def graph_cleanup() -> Iterator[None]:- yield--def _manager() -> NotificationManager:"""A manager with no service wiring: `_spawn_pass` touches only `_passes`."""manager = NotificationManager.__new__(NotificationManager)diff --git a/autogpt_platform/backend/backend/util/conftest.py b/autogpt_platform/backend/backend/util/conftest.pyindex b2048f7022..b287114348 100644--- a/autogpt_platform/backend/backend/util/conftest.py+++ b/autogpt_platform/backend/backend/util/conftest.py@@ -7,8 +7,3 @@ import pytest@pytest.fixture(scope="session")def server():yield None--[email protected](scope="session", autouse=True)-def graph_cleanup():- yield