Personal AI, On Personal Devices
Python
fix: resolve ruff I001 import sorting and E501 line length in tests
Tarun Suresh181d9ac0eb85
diff --git a/tests/agents/test_executor_ephemeral.py b/tests/agents/test_executor_ephemeral.pyindex 537181dd..16062d1a 100644--- a/tests/agents/test_executor_ephemeral.py+++ b/tests/agents/test_executor_ephemeral.py@@ -2,6 +2,8 @@ from __future__ import annotationsfrom 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.pyindex 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 annotationsfrom pathlib import Path+from openjarvis.core.config import MemoryFilesConfig, SystemPromptConfigdiff --git a/tests/daemon/test_session_expiry.py b/tests/daemon/test_session_expiry.pyindex 10da40e6..6f8082e7 100644--- a/tests/daemon/test_session_expiry.py+++ b/tests/daemon/test_session_expiry.py@@ -1,6 +1,7 @@from __future__ import annotationsfrom unittest.mock import MagicMock+from openjarvis.core.types import Message, Rolediff --git a/tests/security/test_credential_stripper.py b/tests/security/test_credential_stripper.pyindex 899ea1b4..01f7f781 100644--- a/tests/security/test_credential_stripper.py+++ b/tests/security/test_credential_stripper.py@@ -4,7 +4,10 @@ from __future__ import annotationsdef test_strips_openai_key():from openjarvis.security.credential_stripper import CredentialStripperstripper = 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 resultassert "[REDACTED:" in resultdiff --git a/tests/sessions/test_compression.py b/tests/sessions/test_compression.pyindex d4509bfb..0c29ee65 100644--- a/tests/sessions/test_compression.py+++ b/tests/sessions/test_compression.py@@ -1,6 +1,7 @@from __future__ import annotationsimport pytest+from openjarvis.core.registry import CompressionRegistryfrom openjarvis.core.types import Message, Role@@ -37,10 +38,19 @@ def test_rule_based_strips_tool_boilerplate():from openjarvis.sessions.compression import RuleBasedPrecompressioncompressor = 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.pyindex 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 pytestfrom pathlib import Path+import pytest+@pytest.fixturedef memory_file(tmp_path: Path) -> Path:diff --git a/tests/tools/test_skill_manage.py b/tests/tools/test_skill_manage.pyindex 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 pytestfrom pathlib import Path+import pytest+@pytest.fixturedef skills_dir(tmp_path: Path) -> Path:diff --git a/tests/tools/test_user_profile_manage.py b/tests/tools/test_user_profile_manage.pyindex 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 pytestfrom pathlib import Path+import pytest+@pytest.fixturedef user_file(tmp_path: Path) -> Path: