From 181d9ac0eb85f1d1ed44ff89e9f36eeb57abee94 Mon Sep 17 00:00:00 2001 From: Tarun Suresh Date: Tue, 17 Mar 2026 00:13:49 +0000 Subject: [PATCH] fix: resolve ruff I001 import sorting and E501 line length in tests Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/agents/test_executor_ephemeral.py | 10 ++++++---- .../test_system_prompt_builder_integration.py | 1 + tests/daemon/test_session_expiry.py | 1 + tests/security/test_credential_stripper.py | 5 ++++- tests/sessions/test_compression.py | 14 ++++++++++++-- tests/tools/test_memory_manage.py | 3 ++- tests/tools/test_skill_manage.py | 3 ++- tests/tools/test_user_profile_manage.py | 3 ++- 8 files changed, 30 insertions(+), 10 deletions(-) diff --git a/tests/agents/test_executor_ephemeral.py b/tests/agents/test_executor_ephemeral.py index 537181dd..16062d1a 100644 --- a/tests/agents/test_executor_ephemeral.py +++ b/tests/agents/test_executor_ephemeral.py @@ -2,6 +2,8 @@ from __future__ import annotations from unittest.mock import MagicMock, patch +REGISTRY_PATH = "openjarvis.core.registry.AgentRegistry.get" + def test_run_ephemeral_creates_and_runs_agent(): from openjarvis.agents.executor import AgentExecutor @@ -11,11 +13,11 @@ def test_run_ephemeral_creates_and_runs_agent(): mock_agent_cls = MagicMock() mock_agent_instance = MagicMock() - mock_agent_instance.run.return_value = MagicMock(content="Flushed 3 memories.") + mock_agent_instance.run.return_value = MagicMock(content="Flushed.") mock_agent_cls.return_value = mock_agent_instance - with patch("openjarvis.core.registry.AgentRegistry.get", return_value=mock_agent_cls): - result = executor.run_ephemeral( + with patch(REGISTRY_PATH, return_value=mock_agent_cls): + executor.run_ephemeral( agent_type="simple", system_prompt="Save important context.", input_text="Review and flush.", @@ -34,7 +36,7 @@ def test_run_ephemeral_passes_input(): mock_agent_instance.run.return_value = MagicMock(content="Done.") mock_agent_cls.return_value = mock_agent_instance - with patch("openjarvis.core.registry.AgentRegistry.get", return_value=mock_agent_cls): + with patch(REGISTRY_PATH, return_value=mock_agent_cls): executor.run_ephemeral( agent_type="simple", system_prompt="Test prompt.", diff --git a/tests/agents/test_system_prompt_builder_integration.py b/tests/agents/test_system_prompt_builder_integration.py index bb4cce2f..439b5e4c 100644 --- a/tests/agents/test_system_prompt_builder_integration.py +++ b/tests/agents/test_system_prompt_builder_integration.py @@ -1,6 +1,7 @@ from __future__ import annotations from pathlib import Path + from openjarvis.core.config import MemoryFilesConfig, SystemPromptConfig diff --git a/tests/daemon/test_session_expiry.py b/tests/daemon/test_session_expiry.py index 10da40e6..6f8082e7 100644 --- a/tests/daemon/test_session_expiry.py +++ b/tests/daemon/test_session_expiry.py @@ -1,6 +1,7 @@ from __future__ import annotations from unittest.mock import MagicMock + from openjarvis.core.types import Message, Role diff --git a/tests/security/test_credential_stripper.py b/tests/security/test_credential_stripper.py index 899ea1b4..01f7f781 100644 --- a/tests/security/test_credential_stripper.py +++ b/tests/security/test_credential_stripper.py @@ -4,7 +4,10 @@ from __future__ import annotations def test_strips_openai_key(): from openjarvis.security.credential_stripper import CredentialStripper stripper = CredentialStripper() - text = "Error: auth failed with key sk-proj-abc123def456ghi789jkl012mno345pqr678stu901vwx234" + text = ( + "Error: auth failed with key " + "sk-proj-abc123def456ghi789jkl012mno345pqr678stu901vwx234" + ) result = stripper.strip(text) assert "sk-proj-" not in result assert "[REDACTED:" in result diff --git a/tests/sessions/test_compression.py b/tests/sessions/test_compression.py index d4509bfb..0c29ee65 100644 --- a/tests/sessions/test_compression.py +++ b/tests/sessions/test_compression.py @@ -1,6 +1,7 @@ from __future__ import annotations import pytest + from openjarvis.core.registry import CompressionRegistry from openjarvis.core.types import Message, Role @@ -37,10 +38,19 @@ def test_rule_based_strips_tool_boilerplate(): from openjarvis.sessions.compression import RuleBasedPrecompression compressor = RuleBasedPrecompression() + long_snippet = "x" * 5000 + tool_output = ( + '{"results": [{"title": "Result 1",' + f' "snippet": "A very long snippet {long_snippet}"' + "}]}" + ) msgs = [ Message(role=Role.ASSISTANT, content="Let me search."), - Message(role=Role.TOOL, content='{"results": [{"title": "Result 1", "snippet": "A very long snippet ' + "x" * 5000 + '"}]}'), - Message(role=Role.ASSISTANT, content="Based on the search, here is the answer."), + Message(role=Role.TOOL, content=tool_output), + Message( + role=Role.ASSISTANT, + content="Based on the search, here is the answer.", + ), ] result = compressor.compress(msgs, threshold=0.5) total_len = sum(len(m.content) for m in result) diff --git a/tests/tools/test_memory_manage.py b/tests/tools/test_memory_manage.py index 27c83c7e..6c063018 100644 --- a/tests/tools/test_memory_manage.py +++ b/tests/tools/test_memory_manage.py @@ -1,8 +1,9 @@ from __future__ import annotations -import pytest from pathlib import Path +import pytest + @pytest.fixture def memory_file(tmp_path: Path) -> Path: diff --git a/tests/tools/test_skill_manage.py b/tests/tools/test_skill_manage.py index 7987938d..ac651028 100644 --- a/tests/tools/test_skill_manage.py +++ b/tests/tools/test_skill_manage.py @@ -1,8 +1,9 @@ from __future__ import annotations -import pytest from pathlib import Path +import pytest + @pytest.fixture def skills_dir(tmp_path: Path) -> Path: diff --git a/tests/tools/test_user_profile_manage.py b/tests/tools/test_user_profile_manage.py index 94ff51fb..dff0ef3c 100644 --- a/tests/tools/test_user_profile_manage.py +++ b/tests/tools/test_user_profile_manage.py @@ -1,8 +1,9 @@ from __future__ import annotations -import pytest from pathlib import Path +import pytest + @pytest.fixture def user_file(tmp_path: Path) -> Path: