feat: remove entire pr package including agents, autonomous, cache, config, and core modules
Delete the pr/ directory and all its submodules: pr/__init__.py, pr/__main__.py, pr/agents/ (agent_communication.py, agent_manager.py, agent_roles.py), pr/autonomous/ (detection.py, mode.py), pr/cache/, pr/config/, pr/core/, and pr/tools/. Update the Makefile implode target to use python -m rp.implode instead of direct cp. Add changelog entry for version 1.13.0 documenting the switch to synchronous HTTP client.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from pr.core.advanced_context import AdvancedContextManager
|
||||
from rp.core.advanced_context import AdvancedContextManager
|
||||
|
||||
|
||||
class TestAdvancedContextManager:
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from pr.agents.agent_communication import (
|
||||
from rp.agents.agent_communication import (
|
||||
AgentCommunicationBus,
|
||||
AgentMessage,
|
||||
MessageType,
|
||||
)
|
||||
from pr.agents.agent_manager import AgentInstance, AgentManager
|
||||
from pr.agents.agent_roles import AgentRole, get_agent_role, list_agent_roles
|
||||
from rp.agents.agent_manager import AgentInstance, AgentManager
|
||||
from rp.agents.agent_roles import AgentRole, get_agent_role, list_agent_roles
|
||||
|
||||
|
||||
def test_get_agent_role():
|
||||
|
||||
+27
-27
@@ -1,64 +1,64 @@
|
||||
import unittest
|
||||
import json
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import patch
|
||||
|
||||
from rp.core.api import call_api, list_models
|
||||
|
||||
|
||||
class TestApi(unittest.TestCase):
|
||||
|
||||
@patch("rp.core.http_client.SyncHTTPClient.request")
|
||||
@patch("rp.core.http_client.http_client.post")
|
||||
@patch("rp.core.api.auto_slim_messages")
|
||||
def test_call_api_success(self, mock_slim, mock_request):
|
||||
def test_call_api_success(self, mock_slim, mock_post):
|
||||
mock_slim.return_value = [{"role": "user", "content": "test"}]
|
||||
mock_response = MagicMock()
|
||||
mock_response.status = 200
|
||||
mock_response.text = (
|
||||
'{"choices": [{"message": {"content": "response"}}], "usage": {"tokens": 10}}'
|
||||
)
|
||||
mock_response.json.return_value = json.loads(mock_response.text)
|
||||
mock_request.return_value = mock_response
|
||||
mock_post.return_value = {
|
||||
"status": 200,
|
||||
"text": '{"choices": [{"message": {"content": "response"}}], "usage": {"tokens": 10}}',
|
||||
"json": lambda: json.loads(
|
||||
'{"choices": [{"message": {"content": "response"}}], "usage": {"tokens": 10}}'
|
||||
),
|
||||
}
|
||||
|
||||
result = call_api([], "model", "http://url", "key", True, [{"name": "tool"}])
|
||||
|
||||
self.assertIn("choices", result)
|
||||
mock_request.assert_called_once()
|
||||
mock_post.assert_called_once()
|
||||
|
||||
@patch("rp.core.http_client.SyncHTTPClient.request")
|
||||
@patch("rp.core.http_client.http_client.post")
|
||||
@patch("rp.core.api.auto_slim_messages")
|
||||
def test_call_api_http_error(self, mock_slim, mock_request):
|
||||
def test_call_api_http_error(self, mock_slim, mock_post):
|
||||
mock_slim.return_value = [{"role": "user", "content": "test"}]
|
||||
mock_request.return_value = {"error": True, "status": 500, "text": "error"}
|
||||
mock_post.return_value = {"error": True, "status": 500, "text": "error"}
|
||||
|
||||
result = call_api([], "model", "http://url", "key", False, [])
|
||||
|
||||
self.assertIn("error", result)
|
||||
|
||||
@patch("rp.core.http_client.SyncHTTPClient.request")
|
||||
@patch("rp.core.http_client.http_client.post")
|
||||
@patch("rp.core.api.auto_slim_messages")
|
||||
def test_call_api_general_error(self, mock_slim, mock_request):
|
||||
def test_call_api_general_error(self, mock_slim, mock_post):
|
||||
mock_slim.return_value = [{"role": "user", "content": "test"}]
|
||||
mock_request.return_value = {"error": True, "exception": "test error"}
|
||||
mock_post.return_value = {"error": True, "exception": "test error"}
|
||||
|
||||
result = call_api([], "model", "http://url", "key", False, [])
|
||||
|
||||
self.assertIn("error", result)
|
||||
|
||||
@patch("rp.core.http_client.SyncHTTPClient.request")
|
||||
def test_list_models_success(self, mock_request):
|
||||
mock_response = MagicMock()
|
||||
mock_response.status = 200
|
||||
mock_response.text = '{"data": [{"id": "model1"}]}'
|
||||
mock_response.json.return_value = json.loads(mock_response.text)
|
||||
mock_request.return_value = mock_response
|
||||
@patch("rp.core.http_client.http_client.get")
|
||||
def test_list_models_success(self, mock_get):
|
||||
mock_get.return_value = {
|
||||
"status": 200,
|
||||
"text": '{"data": [{"id": "model1"}]}',
|
||||
"json": lambda: json.loads('{"data": [{"id": "model1"}]}'),
|
||||
}
|
||||
|
||||
result = list_models("http://url", "key")
|
||||
|
||||
self.assertEqual(result, [{"id": "model1"}])
|
||||
|
||||
@patch("rp.core.http_client.SyncHTTPClient.request")
|
||||
def test_list_models_error(self, mock_request):
|
||||
mock_request.return_value = {"error": True, "exception": "error"}
|
||||
@patch("rp.core.http_client.http_client.get")
|
||||
def test_list_models_error(self, mock_get):
|
||||
mock_get.return_value = {"error": True, "exception": "error"}
|
||||
|
||||
result = list_models("http://url", "key")
|
||||
|
||||
|
||||
+10
-10
@@ -2,7 +2,7 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from rp.__main__ import main
|
||||
from rp.__main__ import main_def as main
|
||||
|
||||
|
||||
def test_main_version(capsys):
|
||||
@@ -39,7 +39,7 @@ def test_main_create_config_fail(capsys):
|
||||
|
||||
def test_main_list_sessions_with_sessions(capsys):
|
||||
sessions = [{"name": "test", "created_at": "2023-01-01", "message_count": 5}]
|
||||
with patch("pr.core.session.SessionManager") as mock_sm:
|
||||
with patch("rp.core.session.SessionManager") as mock_sm:
|
||||
mock_instance = mock_sm.return_value
|
||||
mock_instance.list_sessions.return_value = sessions
|
||||
with patch("sys.argv", ["pr", "--list-sessions"]):
|
||||
@@ -50,7 +50,7 @@ def test_main_list_sessions_with_sessions(capsys):
|
||||
|
||||
|
||||
def test_main_delete_session_success(capsys):
|
||||
with patch("pr.core.session.SessionManager") as mock_sm:
|
||||
with patch("rp.core.session.SessionManager") as mock_sm:
|
||||
mock_instance = mock_sm.return_value
|
||||
mock_instance.delete_session.return_value = True
|
||||
with patch("sys.argv", ["pr", "--delete-session", "test"]):
|
||||
@@ -60,7 +60,7 @@ def test_main_delete_session_success(capsys):
|
||||
|
||||
|
||||
def test_main_delete_session_fail(capsys):
|
||||
with patch("pr.core.session.SessionManager") as mock_sm:
|
||||
with patch("rp.core.session.SessionManager") as mock_sm:
|
||||
mock_instance = mock_sm.return_value
|
||||
mock_instance.delete_session.return_value = False
|
||||
with patch("sys.argv", ["pr", "--delete-session", "test"]):
|
||||
@@ -70,7 +70,7 @@ def test_main_delete_session_fail(capsys):
|
||||
|
||||
|
||||
def test_main_export_session_json(capsys):
|
||||
with patch("pr.core.session.SessionManager") as mock_sm:
|
||||
with patch("rp.core.session.SessionManager") as mock_sm:
|
||||
mock_instance = mock_sm.return_value
|
||||
mock_instance.export_session.return_value = True
|
||||
with patch("sys.argv", ["pr", "--export-session", "test", "output.json"]):
|
||||
@@ -80,7 +80,7 @@ def test_main_export_session_json(capsys):
|
||||
|
||||
|
||||
def test_main_export_session_md(capsys):
|
||||
with patch("pr.core.session.SessionManager") as mock_sm:
|
||||
with patch("rp.core.session.SessionManager") as mock_sm:
|
||||
mock_instance = mock_sm.return_value
|
||||
mock_instance.export_session.return_value = True
|
||||
with patch("sys.argv", ["pr", "--export-session", "test", "output.md"]):
|
||||
@@ -91,7 +91,7 @@ def test_main_export_session_md(capsys):
|
||||
|
||||
def test_main_usage(capsys):
|
||||
usage = {"total_requests": 10, "total_tokens": 1000, "total_cost": 0.01}
|
||||
with patch("pr.core.usage_tracker.UsageTracker.get_total_usage", return_value=usage):
|
||||
with patch("rp.core.usage_tracker.UsageTracker.get_total_usage", return_value=usage):
|
||||
with patch("sys.argv", ["pr", "--usage"]):
|
||||
main()
|
||||
captured = capsys.readouterr()
|
||||
@@ -100,7 +100,7 @@ def test_main_usage(capsys):
|
||||
|
||||
|
||||
def test_main_plugins_no_plugins(capsys):
|
||||
with patch("pr.plugins.loader.PluginLoader") as mock_loader:
|
||||
with patch("rp.plugins.loader.PluginLoader") as mock_loader:
|
||||
mock_instance = mock_loader.return_value
|
||||
mock_instance.load_plugins.return_value = None
|
||||
mock_instance.list_loaded_plugins.return_value = []
|
||||
@@ -111,7 +111,7 @@ def test_main_plugins_no_plugins(capsys):
|
||||
|
||||
|
||||
def test_main_plugins_with_plugins(capsys):
|
||||
with patch("pr.plugins.loader.PluginLoader") as mock_loader:
|
||||
with patch("rp.plugins.loader.PluginLoader") as mock_loader:
|
||||
mock_instance = mock_loader.return_value
|
||||
mock_instance.load_plugins.return_value = None
|
||||
mock_instance.list_loaded_plugins.return_value = ["plugin1", "plugin2"]
|
||||
@@ -122,7 +122,7 @@ def test_main_plugins_with_plugins(capsys):
|
||||
|
||||
|
||||
def test_main_run_assistant():
|
||||
with patch("pr.__main__.Assistant") as mock_assistant:
|
||||
with patch("rp.__main__.Assistant") as mock_assistant:
|
||||
mock_instance = mock_assistant.return_value
|
||||
with patch("sys.argv", ["pr", "test message"]):
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user