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.
dx(backend/copilot): run_block_test.py runs on its own without a backend stack (#15372)
Reinier van der Leer11d0a036fbdf
diff --git a/autogpt_platform/backend/backend/copilot/tools/run_block_test.py b/autogpt_platform/backend/backend/copilot/tools/run_block_test.pyindex e972edf81e..e8e530d115 100644--- a/autogpt_platform/backend/backend/copilot/tools/run_block_test.py+++ b/autogpt_platform/backend/backend/copilot/tools/run_block_test.py@@ -21,6 +21,16 @@ from .run_block import RunBlockTool_TEST_USER_ID = "test-user-run-block"[email protected](autouse=True)+def _no_pending_reviews():+ """No test here seeds a review; unstubbed, this lookup is an RPC to a database+ manager that only an earlier test's ``server`` fixture would have started."""+ reviews = MagicMock()+ reviews.get_pending_reviews_for_chat_session = AsyncMock(return_value=[])+ with patch("backend.copilot.tools.helpers.review_db", return_value=reviews):+ yield++def make_mock_block(block_id: str, name: str, block_type: BlockType, disabled: bool = False):@@ -205,11 +215,14 @@ class TestRunBlockFiltering:@pytest.mark.asyncio(loop_scope="session")async def test_non_excluded_block_passes_guard(self):- """Non-excluded blocks pass the filtering guard (may fail later for other reasons)."""+ """A standard block passes the filtering guard and reaches the schema preview."""session = make_session(user_id=_TEST_USER_ID)- standard_block = make_mock_block(- "standard-id", "HTTP Request", BlockType.STANDARD+ standard_block = make_mock_block_with_schema(+ block_id="standard-id",+ name="HTTP Request",+ input_properties={"url": {"type": "string"}},+ required_fields=["url"],)with (@@ -231,10 +244,7 @@ class TestRunBlockFiltering:dry_run=False,)- # Should NOT be an ErrorResponse about CoPilot exclusion- # (may be other errors like missing credentials, but not the exclusion guard)- if isinstance(response, ErrorResponse):- assert "cannot be run directly" not in response.message+ assert isinstance(response, BlockDetailsResponse)class TestRunBlockInputValidation: