Skip to content

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.py
index 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():
- yield
diff --git a/autogpt_platform/backend/backend/api/features/mailerlite/routes_test.py b/autogpt_platform/backend/backend/api/features/mailerlite/routes_test.py
index 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 hashlib
import hmac
import json
-from collections.abc import Iterator
from unittest.mock import AsyncMock
import 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.py
index 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():
- yield
diff --git a/autogpt_platform/backend/backend/api/features/orgs/conftest.py b/autogpt_platform/backend/backend/api/features/orgs/conftest.py
index 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 pytest
def 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."""
- yield
diff --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.py
index 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 embedding
mock_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 embedding
mock_generate.return_value = [0.1] * EMBEDDING_DIM
diff --git a/autogpt_platform/backend/backend/blocks/dataforb2b/conftest.py b/autogpt_platform/backend/backend/blocks/dataforb2b/conftest.py
index 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]:
- yield
diff --git a/autogpt_platform/backend/backend/blocks/slant3d/conftest.py b/autogpt_platform/backend/backend/blocks/slant3d/conftest.py
index 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]:
- yield
diff --git a/autogpt_platform/backend/backend/cli/mailerlite_backfill_test.py b/autogpt_platform/backend/backend/cli/mailerlite_backfill_test.py
index 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().out
diff --git a/autogpt_platform/backend/backend/cli/onboarding_role_backfill_test.py b/autogpt_platform/backend/backend/cli/onboarding_role_backfill_test.py
index 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.py
index 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.py
index 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 annotations
import json
-from collections.abc import AsyncIterator
import pytest
import 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.py
index 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.py
index 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, which
supplies 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 suite
off SpinTestServer (postgres + rabbitmq). ``dream/`` has no conftest, and
adding 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.py
index 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 AsyncIterator
from unittest.mock import AsyncMock, patch
from 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.py
index 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.fixture
def baseline_io(
monkeypatch: pytest.MonkeyPatch, baseline_offline: None
diff --git a/autogpt_platform/backend/backend/copilot/stream_heartbeat_test.py b/autogpt_platform/backend/backend/copilot/stream_heartbeat_test.py
index 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 AsyncGenerator
import pytest
import 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.asyncio
async def test_emits_status_after_silent_threshold():
"""When no event is bumped, the watchdog fires the first scheduled
diff --git a/autogpt_platform/backend/backend/copilot/tools/conftest.py b/autogpt_platform/backend/backend/copilot/tools/conftest.py
index 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 from
backend/conftest.py so that integration tests in this directory do not trigger
the 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.py
index 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.py
index 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.py
index 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.py
index 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.py
index 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 Iterator
from datetime import datetime, timedelta, timezone
from types import SimpleNamespace
from 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.py
index 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, timezone
from types import SimpleNamespace
-from typing import Iterator
from unittest.mock import AsyncMock
import 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.py
index 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 asyncio
import inspect
-from collections.abc import Iterator
from typing import Any
from 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 = True
diff --git a/autogpt_platform/backend/backend/notifications/notifications_test.py b/autogpt_platform/backend/backend/notifications/notifications_test.py
index 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 Iterator
import 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.py
index 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