mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-08-14 00:47:52 +00:00
fix: resolve ruff I001 import sorting and E501 line length in tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
130dd99387
commit
181d9ac0eb
@@ -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.",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from openjarvis.core.config import MemoryFilesConfig, SystemPromptConfig
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from openjarvis.core.types import Message, Role
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user