pygeai 0.6.0b13__py3-none-any.whl → 0.6.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pygeai/__init__.py +1 -2
- pygeai/_docs/source/content/api_reference/project.rst +392 -0
- pygeai/_docs/source/content/authentication.rst +130 -1
- pygeai/_docs/source/content/debugger.rst +327 -157
- pygeai/_docs/source/content/migration.rst +391 -7
- pygeai/_docs/source/pygeai.core.common.rst +8 -0
- pygeai/_docs/source/pygeai.tests.auth.rst +56 -0
- pygeai/_docs/source/pygeai.tests.cli.rst +8 -0
- pygeai/admin/clients.py +1 -3
- pygeai/analytics/clients.py +1 -1
- pygeai/assistant/clients.py +2 -7
- pygeai/assistant/data/clients.py +0 -8
- pygeai/assistant/data_analyst/clients.py +0 -2
- pygeai/assistant/managers.py +1 -1
- pygeai/assistant/rag/clients.py +0 -2
- pygeai/assistant/rag/mappers.py +9 -11
- pygeai/auth/clients.py +26 -7
- pygeai/auth/endpoints.py +2 -1
- pygeai/chat/clients.py +2 -2
- pygeai/chat/managers.py +1 -1
- pygeai/cli/commands/admin.py +13 -25
- pygeai/cli/commands/analytics.py +56 -88
- pygeai/cli/commands/assistant.py +84 -138
- pygeai/cli/commands/auth.py +23 -46
- pygeai/cli/commands/base.py +0 -1
- pygeai/cli/commands/chat.py +218 -209
- pygeai/cli/commands/common.py +5 -5
- pygeai/cli/commands/configuration.py +79 -29
- pygeai/cli/commands/docs.py +3 -4
- pygeai/cli/commands/embeddings.py +13 -19
- pygeai/cli/commands/evaluation.py +133 -344
- pygeai/cli/commands/feedback.py +7 -15
- pygeai/cli/commands/files.py +26 -53
- pygeai/cli/commands/gam.py +28 -69
- pygeai/cli/commands/lab/ai_lab.py +96 -142
- pygeai/cli/commands/lab/common.py +1 -1
- pygeai/cli/commands/lab/spec.py +12 -32
- pygeai/cli/commands/llm.py +9 -18
- pygeai/cli/commands/migrate.py +43 -99
- pygeai/cli/commands/organization.py +223 -196
- pygeai/cli/commands/rag.py +35 -58
- pygeai/cli/commands/rerank.py +21 -25
- pygeai/cli/commands/secrets.py +39 -67
- pygeai/cli/commands/usage_limits.py +50 -136
- pygeai/cli/commands/validators.py +1 -1
- pygeai/cli/geai.py +32 -3
- pygeai/cli/geai_proxy.py +6 -2
- pygeai/cli/install_man.py +1 -1
- pygeai/cli/parsers.py +1 -1
- pygeai/core/base/clients.py +90 -21
- pygeai/core/base/mappers.py +39 -55
- pygeai/core/base/session.py +134 -22
- pygeai/core/common/config.py +50 -13
- pygeai/core/common/constants.py +8 -0
- pygeai/core/common/exceptions.py +6 -0
- pygeai/core/embeddings/clients.py +0 -1
- pygeai/core/embeddings/managers.py +0 -1
- pygeai/core/feedback/clients.py +0 -2
- pygeai/core/feedback/models.py +1 -1
- pygeai/core/files/clients.py +0 -3
- pygeai/core/files/managers.py +1 -1
- pygeai/core/files/mappers.py +4 -5
- pygeai/core/llm/clients.py +0 -1
- pygeai/core/models.py +4 -4
- pygeai/core/plugins/clients.py +0 -3
- pygeai/core/plugins/models.py +2 -2
- pygeai/core/rerank/clients.py +0 -2
- pygeai/core/secrets/clients.py +0 -2
- pygeai/core/services/rest.py +80 -14
- pygeai/core/singleton.py +24 -0
- pygeai/dbg/__init__.py +2 -2
- pygeai/dbg/debugger.py +276 -38
- pygeai/evaluation/clients.py +2 -4
- pygeai/evaluation/dataset/clients.py +0 -1
- pygeai/evaluation/plan/clients.py +0 -2
- pygeai/evaluation/result/clients.py +0 -2
- pygeai/gam/clients.py +1 -3
- pygeai/health/clients.py +1 -3
- pygeai/lab/clients.py +0 -1
- pygeai/lab/managers.py +0 -1
- pygeai/lab/models.py +0 -1
- pygeai/lab/strategies/clients.py +1 -2
- pygeai/lab/tools/clients.py +2 -2
- pygeai/lab/tools/mappers.py +1 -1
- pygeai/migration/strategies.py +5 -6
- pygeai/migration/tools.py +1 -1
- pygeai/organization/clients.py +118 -12
- pygeai/organization/endpoints.py +1 -0
- pygeai/organization/limits/clients.py +4 -6
- pygeai/organization/limits/managers.py +1 -4
- pygeai/organization/managers.py +2 -2
- pygeai/proxy/config.py +1 -0
- pygeai/proxy/managers.py +6 -5
- pygeai/tests/admin/test_clients.py +11 -11
- pygeai/tests/assistants/rag/test_clients.py +1 -1
- pygeai/tests/assistants/rag/test_models.py +1 -2
- pygeai/tests/assistants/test_clients.py +1 -1
- pygeai/tests/assistants/test_managers.py +1 -3
- pygeai/tests/auth/test_cli_configuration.py +252 -0
- pygeai/tests/auth/test_client_initialization.py +411 -0
- pygeai/tests/auth/test_clients.py +29 -27
- pygeai/tests/auth/test_config_manager.py +305 -0
- pygeai/tests/auth/test_header_injection.py +294 -0
- pygeai/tests/auth/test_oauth.py +3 -1
- pygeai/tests/auth/test_session_logging.py +119 -0
- pygeai/tests/auth/test_session_validation.py +408 -0
- pygeai/tests/auth/test_singleton_reset.py +201 -0
- pygeai/tests/chat/test_clients.py +1 -1
- pygeai/tests/chat/test_iris.py +1 -1
- pygeai/tests/chat/test_ui.py +0 -2
- pygeai/tests/cli/commands/lab/test_ai_lab.py +1 -3
- pygeai/tests/cli/commands/lab/test_common.py +0 -1
- pygeai/tests/cli/commands/test_chat.py +1 -1
- pygeai/tests/cli/commands/test_common.py +0 -1
- pygeai/tests/cli/commands/test_embeddings.py +2 -2
- pygeai/tests/cli/commands/test_evaluation.py +1 -9
- pygeai/tests/cli/commands/test_llm.py +1 -1
- pygeai/tests/cli/commands/test_migrate.py +1 -1
- pygeai/tests/cli/commands/test_rerank.py +0 -1
- pygeai/tests/cli/commands/test_secrets.py +1 -1
- pygeai/tests/cli/commands/test_show_help.py +0 -1
- pygeai/tests/cli/commands/test_validators.py +0 -1
- pygeai/tests/cli/test_credentials_flag.py +312 -0
- pygeai/tests/cli/test_error_handler.py +0 -1
- pygeai/tests/core/base/test_mappers.py +2 -2
- pygeai/tests/core/base/test_models.py +4 -4
- pygeai/tests/core/common/test_config.py +2 -7
- pygeai/tests/core/common/test_decorators.py +0 -1
- pygeai/tests/core/embeddings/test_managers.py +1 -1
- pygeai/tests/core/feedback/test_clients.py +2 -2
- pygeai/tests/core/files/test_clients.py +6 -6
- pygeai/tests/core/files/test_models.py +0 -1
- pygeai/tests/core/files/test_responses.py +0 -1
- pygeai/tests/core/llm/test_clients.py +1 -1
- pygeai/tests/core/plugins/test_clients.py +4 -4
- pygeai/tests/core/rerank/test_mappers.py +1 -3
- pygeai/tests/core/secrets/test_clients.py +2 -3
- pygeai/tests/core/services/test_rest.py +10 -10
- pygeai/tests/core/utils/test_console.py +0 -1
- pygeai/tests/dbg/test_debugger.py +95 -8
- pygeai/tests/evaluation/dataset/test_clients.py +24 -27
- pygeai/tests/evaluation/plan/test_clients.py +16 -18
- pygeai/tests/evaluation/result/test_clients.py +4 -5
- pygeai/tests/health/test_clients.py +2 -2
- pygeai/tests/integration/lab/agents/test_create_agent.py +1 -3
- pygeai/tests/integration/lab/agents/test_get_agent.py +1 -1
- pygeai/tests/integration/lab/processes/test_create_process.py +2 -2
- pygeai/tests/integration/lab/processes/test_create_task.py +2 -3
- pygeai/tests/integration/lab/processes/test_delete_process.py +0 -1
- pygeai/tests/integration/lab/processes/test_get_process.py +2 -4
- pygeai/tests/integration/lab/processes/test_list_process_instances.py +1 -3
- pygeai/tests/integration/lab/processes/test_update_process.py +3 -9
- pygeai/tests/integration/lab/reasoning_strategies/test_update_reasoning_strategy.py +1 -2
- pygeai/tests/integration/lab/tools/test_delete_tool.py +1 -1
- pygeai/tests/integration/lab/tools/test_list_tools.py +1 -1
- pygeai/tests/integration/lab/tools/test_update_tool.py +1 -1
- pygeai/tests/lab/agents/test_clients.py +17 -17
- pygeai/tests/lab/processes/test_clients.py +67 -67
- pygeai/tests/lab/processes/test_mappers.py +23 -23
- pygeai/tests/lab/spec/test_loader.py +0 -2
- pygeai/tests/lab/spec/test_parsers.py +1 -2
- pygeai/tests/lab/strategies/test_clients.py +10 -10
- pygeai/tests/lab/test_managers.py +3 -5
- pygeai/tests/lab/test_mappers.py +1 -4
- pygeai/tests/lab/tools/test_clients.py +21 -21
- pygeai/tests/lab/tools/test_mappers.py +0 -1
- pygeai/tests/organization/limits/test_clients.py +33 -33
- pygeai/tests/organization/limits/test_managers.py +7 -7
- pygeai/tests/organization/test_clients.py +78 -60
- pygeai/tests/proxy/test_clients.py +1 -1
- pygeai/tests/proxy/test_integration.py +1 -4
- pygeai/tests/proxy/test_managers.py +1 -2
- pygeai/tests/proxy/test_servers.py +1 -2
- pygeai/tests/snippets/assistants/rag/delete_rag_assistant.py +0 -1
- pygeai/tests/snippets/assistants/rag/get_documents.py +0 -1
- pygeai/tests/snippets/assistants/rag/get_rag_assistant_data.py +0 -1
- pygeai/tests/snippets/chat/get_request_status.py +0 -1
- pygeai/tests/snippets/dbg/file_debugging.py +72 -0
- pygeai/tests/snippets/dbg/module_debugging.py +60 -0
- pygeai/tests/snippets/embeddings/cohere_example.py +2 -2
- pygeai/tests/snippets/embeddings/openai_base64_example.py +1 -1
- pygeai/tests/snippets/evaluation/dataset/complete_workflow_example.py +8 -8
- pygeai/tests/snippets/evaluation/plan/complete_workflow_example.py +5 -5
- pygeai/tests/snippets/evaluation/result/complete_workflow_example.py +3 -3
- pygeai/tests/snippets/lab/agentic_flow_example_1.py +1 -1
- pygeai/tests/snippets/lab/agentic_flow_example_2.py +3 -4
- pygeai/tests/snippets/lab/agents/create_agent_with_permissions.py +2 -2
- pygeai/tests/snippets/lab/agents/delete_agent.py +1 -2
- pygeai/tests/snippets/lab/agents/get_agent.py +1 -1
- pygeai/tests/snippets/lab/agents/get_agent_with_new_fields.py +10 -10
- pygeai/tests/snippets/lab/agents/get_sharing_link.py +0 -1
- pygeai/tests/snippets/lab/agents/list_agents.py +1 -1
- pygeai/tests/snippets/lab/agents/publish_agent_revision.py +0 -1
- pygeai/tests/snippets/lab/agents/update_agent_properties.py +1 -1
- pygeai/tests/snippets/lab/crud_ui.py +3 -5
- pygeai/tests/snippets/lab/processes/kbs/get_kb.py +0 -1
- pygeai/tests/snippets/lab/processes/kbs/list_kbs.py +0 -1
- pygeai/tests/snippets/lab/processes/list_processes.py +1 -1
- pygeai/tests/snippets/lab/samples/summarize_files.py +0 -3
- pygeai/tests/snippets/lab/strategies/get_reasoning_strategy.py +0 -1
- pygeai/tests/snippets/lab/strategies/list_reasoning_strategies.py +1 -1
- pygeai/tests/snippets/lab/tools/get_tool.py +1 -1
- pygeai/tests/snippets/lab/tools/publish_tool_revision.py +0 -1
- pygeai/tests/snippets/lab/tools/set_parameters.py +1 -2
- pygeai/tests/snippets/lab/use_cases/c_code_fixer_agent_flow.py +2 -3
- pygeai/tests/snippets/lab/use_cases/file_summarizer_example_2.py +1 -1
- pygeai/tests/snippets/lab/use_cases/update_cli_expert.py +0 -1
- pygeai/tests/snippets/lab/use_cases/update_lab_expert.py +0 -1
- pygeai/tests/snippets/lab/use_cases/update_web_designer.py +0 -1
- pygeai/tests/snippets/lab/use_cases/update_web_reader.py +0 -1
- pygeai/tests/snippets/migrate/orchestrator_examples.py +1 -1
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/METADATA +32 -7
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/RECORD +217 -206
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/WHEEL +0 -0
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/entry_points.txt +0 -0
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
from unittest.mock import patch, Mock
|
|
3
3
|
|
|
4
|
-
from pygeai.core.services.rest import
|
|
4
|
+
from pygeai.core.services.rest import GEAIApiService
|
|
5
5
|
from pygeai.core.common.exceptions import InvalidResponseException
|
|
6
6
|
|
|
7
7
|
|
|
@@ -11,10 +11,10 @@ class TestApiService(unittest.TestCase):
|
|
|
11
11
|
"""
|
|
12
12
|
def setUp(self):
|
|
13
13
|
self.base_url = "https://api.example.com"
|
|
14
|
-
self.api_service =
|
|
14
|
+
self.api_service = GEAIApiService(self.base_url, username="user", password="pass", token="test_token")
|
|
15
15
|
|
|
16
16
|
def test_init_with_credentials(self):
|
|
17
|
-
service =
|
|
17
|
+
service = GEAIApiService(self.base_url, username="user", password="pass", token="token")
|
|
18
18
|
|
|
19
19
|
self.assertEqual(service.base_url, self.base_url)
|
|
20
20
|
self.assertEqual(service.username, "user")
|
|
@@ -22,7 +22,7 @@ class TestApiService(unittest.TestCase):
|
|
|
22
22
|
self.assertEqual(service.token, "token")
|
|
23
23
|
|
|
24
24
|
def test_init_without_credentials(self):
|
|
25
|
-
service =
|
|
25
|
+
service = GEAIApiService(self.base_url)
|
|
26
26
|
|
|
27
27
|
self.assertEqual(service.base_url, self.base_url)
|
|
28
28
|
self.assertIsNone(service.username)
|
|
@@ -46,7 +46,7 @@ class TestApiService(unittest.TestCase):
|
|
|
46
46
|
|
|
47
47
|
@patch('requests.Session.get')
|
|
48
48
|
def test_get_request_with_token(self, mock_get):
|
|
49
|
-
api_service =
|
|
49
|
+
api_service = GEAIApiService(self.base_url, token="test_token")
|
|
50
50
|
mock_response = Mock()
|
|
51
51
|
mock_response.url = f"{self.base_url}/test_endpoint"
|
|
52
52
|
mock_get.return_value = mock_response
|
|
@@ -71,7 +71,7 @@ class TestApiService(unittest.TestCase):
|
|
|
71
71
|
mock_get.assert_called_once_with(
|
|
72
72
|
url=f"{self.base_url}/test_endpoint",
|
|
73
73
|
params=None,
|
|
74
|
-
headers=
|
|
74
|
+
headers={}
|
|
75
75
|
)
|
|
76
76
|
self.assertEqual(response, mock_response)
|
|
77
77
|
|
|
@@ -135,7 +135,7 @@ class TestApiService(unittest.TestCase):
|
|
|
135
135
|
mock_post.assert_called_once_with(
|
|
136
136
|
url=f"{self.base_url}/test_endpoint",
|
|
137
137
|
json={"key": "value"},
|
|
138
|
-
headers=
|
|
138
|
+
headers={},
|
|
139
139
|
stream=True
|
|
140
140
|
)
|
|
141
141
|
self.assertEqual(result, ["line1", "line2"])
|
|
@@ -160,7 +160,7 @@ class TestApiService(unittest.TestCase):
|
|
|
160
160
|
|
|
161
161
|
mock_post.assert_called_once_with(
|
|
162
162
|
url=f"{self.base_url}/test_endpoint",
|
|
163
|
-
headers=
|
|
163
|
+
headers={},
|
|
164
164
|
data=mock_file
|
|
165
165
|
)
|
|
166
166
|
self.assertEqual(response, mock_response)
|
|
@@ -186,7 +186,7 @@ class TestApiService(unittest.TestCase):
|
|
|
186
186
|
|
|
187
187
|
mock_post.assert_called_once_with(
|
|
188
188
|
url=f"{self.base_url}/test_endpoint",
|
|
189
|
-
headers=
|
|
189
|
+
headers={},
|
|
190
190
|
data={"key": "value"},
|
|
191
191
|
files=mock_files
|
|
192
192
|
)
|
|
@@ -256,7 +256,7 @@ class TestApiService(unittest.TestCase):
|
|
|
256
256
|
self.assertEqual(result, f"{self.base_url}/test_endpoint")
|
|
257
257
|
|
|
258
258
|
def test_add_endpoint_to_url_without_protocol(self):
|
|
259
|
-
api_service =
|
|
259
|
+
api_service = GEAIApiService("api.example.com")
|
|
260
260
|
result = api_service._add_endpoint_to_url("test_endpoint")
|
|
261
261
|
|
|
262
262
|
self.assertEqual(result, "https://api.example.com/test_endpoint")
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
from unittest import TestCase
|
|
2
|
-
from unittest.mock import patch, MagicMock
|
|
2
|
+
from unittest.mock import patch, MagicMock
|
|
3
3
|
from types import FrameType
|
|
4
|
-
|
|
4
|
+
import tempfile
|
|
5
|
+
import os
|
|
6
|
+
import shutil
|
|
7
|
+
from pygeai.dbg.debugger import Debugger, Breakpoint, debug_file, debug_module
|
|
5
8
|
|
|
6
9
|
|
|
7
10
|
class TestBreakpoint(TestCase):
|
|
@@ -63,13 +66,14 @@ class TestDebugger(TestCase):
|
|
|
63
66
|
self.mock_console = self.console_patch.start()
|
|
64
67
|
self.mock_console.write_stdout = MagicMock()
|
|
65
68
|
|
|
66
|
-
self.
|
|
67
|
-
self.
|
|
69
|
+
self.util_patch = patch('pygeai.dbg.debugger.util.find_spec')
|
|
70
|
+
self.mock_find_spec = self.util_patch.start()
|
|
71
|
+
self.mock_find_spec.return_value = MagicMock()
|
|
68
72
|
|
|
69
73
|
def tearDown(self):
|
|
70
74
|
self.logging_patch.stop()
|
|
71
75
|
self.console_patch.stop()
|
|
72
|
-
self.
|
|
76
|
+
self.util_patch.stop()
|
|
73
77
|
|
|
74
78
|
def test_debugger_init_default(self):
|
|
75
79
|
debugger = Debugger()
|
|
@@ -401,8 +405,9 @@ class TestDebuggerCommands(TestCase):
|
|
|
401
405
|
self.console_patch = patch('pygeai.dbg.debugger.Console')
|
|
402
406
|
self.mock_console = self.console_patch.start()
|
|
403
407
|
|
|
404
|
-
self.
|
|
405
|
-
self.
|
|
408
|
+
self.util_patch = patch('pygeai.dbg.debugger.util.find_spec')
|
|
409
|
+
self.mock_find_spec = self.util_patch.start()
|
|
410
|
+
self.mock_find_spec.return_value = MagicMock()
|
|
406
411
|
|
|
407
412
|
self.pprint_patch = patch('pygeai.dbg.debugger.pprint')
|
|
408
413
|
self.mock_pprint = self.pprint_patch.start()
|
|
@@ -410,7 +415,7 @@ class TestDebuggerCommands(TestCase):
|
|
|
410
415
|
def tearDown(self):
|
|
411
416
|
self.logging_patch.stop()
|
|
412
417
|
self.console_patch.stop()
|
|
413
|
-
self.
|
|
418
|
+
self.util_patch.stop()
|
|
414
419
|
self.pprint_patch.stop()
|
|
415
420
|
|
|
416
421
|
def test_handle_breakpoint_continue(self):
|
|
@@ -504,3 +509,85 @@ class TestDebuggerCommands(TestCase):
|
|
|
504
509
|
with patch.object(debugger, '_get_source_lines', return_value=[(10, "test")]):
|
|
505
510
|
with self.assertRaises(SystemExit):
|
|
506
511
|
debugger.handle_breakpoint(mock_frame)
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
class TestDebugFile(TestCase):
|
|
515
|
+
"""Test debug_file helper function."""
|
|
516
|
+
|
|
517
|
+
def setUp(self):
|
|
518
|
+
self.test_dir = tempfile.mkdtemp()
|
|
519
|
+
self.test_file = os.path.join(self.test_dir, "test_script.py")
|
|
520
|
+
with open(self.test_file, "w") as f:
|
|
521
|
+
f.write("""
|
|
522
|
+
def main():
|
|
523
|
+
x = 10
|
|
524
|
+
y = 20
|
|
525
|
+
return x + y
|
|
526
|
+
|
|
527
|
+
if __name__ == "__main__":
|
|
528
|
+
result = main()
|
|
529
|
+
print(result)
|
|
530
|
+
""")
|
|
531
|
+
|
|
532
|
+
def tearDown(self):
|
|
533
|
+
shutil.rmtree(self.test_dir)
|
|
534
|
+
|
|
535
|
+
@patch("pygeai.dbg.debugger.logging")
|
|
536
|
+
@patch("pygeai.dbg.debugger.Console")
|
|
537
|
+
@patch("pygeai.dbg.debugger.util.find_spec")
|
|
538
|
+
def test_debug_file_creates_debugger(self, mock_find_spec, mock_console, mock_logging):
|
|
539
|
+
dbg = debug_file(self.test_file)
|
|
540
|
+
self.assertIsInstance(dbg, Debugger)
|
|
541
|
+
self.assertEqual(dbg.module_filter, "__main__")
|
|
542
|
+
|
|
543
|
+
def test_debug_file_not_found(self):
|
|
544
|
+
with self.assertRaises(FileNotFoundError):
|
|
545
|
+
debug_file("/nonexistent/file.py")
|
|
546
|
+
|
|
547
|
+
@patch("pygeai.dbg.debugger.logging")
|
|
548
|
+
@patch("pygeai.dbg.debugger.Console")
|
|
549
|
+
@patch("pygeai.dbg.debugger.util.find_spec")
|
|
550
|
+
def test_debug_file_with_args(self, mock_find_spec, mock_console, mock_logging):
|
|
551
|
+
dbg = debug_file(self.test_file, args=["arg1", "arg2"])
|
|
552
|
+
self.assertIsInstance(dbg, Debugger)
|
|
553
|
+
|
|
554
|
+
@patch("pygeai.dbg.debugger.logging")
|
|
555
|
+
@patch("pygeai.dbg.debugger.Console")
|
|
556
|
+
@patch("pygeai.dbg.debugger.util.find_spec")
|
|
557
|
+
def test_debug_file_with_breakpoints(self, mock_find_spec, mock_console, mock_logging):
|
|
558
|
+
dbg = debug_file(self.test_file, breakpoint_specs=[(None, "main")])
|
|
559
|
+
self.assertEqual(len(dbg.breakpoints), 1)
|
|
560
|
+
self.assertIn((None, "main"), dbg.breakpoints)
|
|
561
|
+
|
|
562
|
+
@patch("pygeai.dbg.debugger.logging")
|
|
563
|
+
@patch("pygeai.dbg.debugger.Console")
|
|
564
|
+
@patch("pygeai.dbg.debugger.util.find_spec")
|
|
565
|
+
def test_debug_file_with_pygeai_import(self, mock_find_spec, mock_console, mock_logging):
|
|
566
|
+
pygeai_file = os.path.join(self.test_dir, "test_pygeai.py")
|
|
567
|
+
with open(pygeai_file, "w") as f:
|
|
568
|
+
f.write("from pygeai.chat import ChatClient\n")
|
|
569
|
+
|
|
570
|
+
dbg = debug_file(pygeai_file)
|
|
571
|
+
self.assertEqual(dbg.module_filter, "")
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
class TestDebugModule(TestCase):
|
|
575
|
+
"""Test debug_module helper function."""
|
|
576
|
+
|
|
577
|
+
@patch("pygeai.dbg.debugger.logging")
|
|
578
|
+
@patch("pygeai.dbg.debugger.Console")
|
|
579
|
+
@patch("pygeai.dbg.debugger.util.find_spec")
|
|
580
|
+
def test_debug_module_creates_debugger(self, mock_find_spec, mock_console, mock_logging):
|
|
581
|
+
dbg = debug_module("os.path", "exists")
|
|
582
|
+
self.assertIsInstance(dbg, Debugger)
|
|
583
|
+
self.assertEqual(len(dbg.breakpoints), 1)
|
|
584
|
+
self.assertEqual(dbg.module_filter, "os")
|
|
585
|
+
|
|
586
|
+
def test_debug_module_invalid_module(self):
|
|
587
|
+
with self.assertRaises(ImportError):
|
|
588
|
+
debug_module("nonexistent.module", "main")
|
|
589
|
+
|
|
590
|
+
def test_debug_module_invalid_function(self):
|
|
591
|
+
with self.assertRaises(ImportError):
|
|
592
|
+
debug_module("os", "nonexistent_func")
|
|
593
|
+
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import unittest
|
|
2
|
-
from unittest.mock import patch, MagicMock
|
|
3
|
-
import json
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
from pygeai.core.base.session import Session
|
|
2
|
+
from unittest.mock import patch, MagicMock
|
|
6
3
|
|
|
7
4
|
from pygeai.evaluation.dataset.clients import EvaluationDatasetClient
|
|
8
5
|
|
|
@@ -18,14 +15,14 @@ class TestEvaluationDatasetClient(unittest.TestCase):
|
|
|
18
15
|
self.mock_response.json.return_value = {"id": "dataset-123", "status": "success"}
|
|
19
16
|
self.mock_response.status_code = 200
|
|
20
17
|
|
|
21
|
-
@patch('pygeai.core.services.rest.
|
|
18
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
22
19
|
def test_list_datasets(self, mock_get):
|
|
23
20
|
mock_get.return_value = self.mock_response
|
|
24
21
|
result = self.client.list_datasets()
|
|
25
22
|
mock_get.assert_called_once()
|
|
26
23
|
self.assertEqual(result, {"id": "dataset-123", "status": "success"})
|
|
27
24
|
|
|
28
|
-
@patch('pygeai.core.services.rest.
|
|
25
|
+
@patch('pygeai.core.services.rest.GEAIApiService.post')
|
|
29
26
|
def test_create_dataset_minimal(self, mock_post):
|
|
30
27
|
mock_post.return_value = self.mock_response
|
|
31
28
|
result = self.client.create_dataset(
|
|
@@ -40,7 +37,7 @@ class TestEvaluationDatasetClient(unittest.TestCase):
|
|
|
40
37
|
self.assertEqual(call_args[1]['data']['dataSetType'], "T")
|
|
41
38
|
self.assertTrue(call_args[1]['data']['dataSetActive'])
|
|
42
39
|
|
|
43
|
-
@patch('pygeai.core.services.rest.
|
|
40
|
+
@patch('pygeai.core.services.rest.GEAIApiService.post')
|
|
44
41
|
def test_create_dataset_with_rows(self, mock_post):
|
|
45
42
|
mock_post.return_value = self.mock_response
|
|
46
43
|
rows = [{"dataSetRowInput": "input1", "dataSetRowExpectedAnswer": "answer1"}]
|
|
@@ -58,7 +55,7 @@ class TestEvaluationDatasetClient(unittest.TestCase):
|
|
|
58
55
|
|
|
59
56
|
@patch('pathlib.Path.is_file')
|
|
60
57
|
@patch('pathlib.Path.open')
|
|
61
|
-
@patch('pygeai.core.services.rest.
|
|
58
|
+
@patch('pygeai.core.services.rest.GEAIApiService.post_file_binary')
|
|
62
59
|
def test_create_dataset_from_file_success(self, mock_post, mock_open_file, mock_is_file):
|
|
63
60
|
mock_is_file.return_value = True
|
|
64
61
|
mock_file = MagicMock()
|
|
@@ -79,14 +76,14 @@ class TestEvaluationDatasetClient(unittest.TestCase):
|
|
|
79
76
|
with self.assertRaises(FileNotFoundError):
|
|
80
77
|
self.client.create_dataset_from_file("/path/to/nonexistent.json")
|
|
81
78
|
|
|
82
|
-
@patch('pygeai.core.services.rest.
|
|
79
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
83
80
|
def test_get_dataset(self, mock_get):
|
|
84
81
|
mock_get.return_value = self.mock_response
|
|
85
82
|
result = self.client.get_dataset("dataset-123")
|
|
86
83
|
mock_get.assert_called_once()
|
|
87
84
|
self.assertEqual(result, {"id": "dataset-123", "status": "success"})
|
|
88
85
|
|
|
89
|
-
@patch('pygeai.core.services.rest.
|
|
86
|
+
@patch('pygeai.core.services.rest.GEAIApiService.put')
|
|
90
87
|
def test_update_dataset(self, mock_put):
|
|
91
88
|
mock_put.return_value = self.mock_response
|
|
92
89
|
rows = [{"dataSetRowInput": "updated"}]
|
|
@@ -103,14 +100,14 @@ class TestEvaluationDatasetClient(unittest.TestCase):
|
|
|
103
100
|
self.assertEqual(call_args[1]['data']['dataSetName'], "Updated Dataset")
|
|
104
101
|
self.assertEqual(call_args[1]['data']['rows'], rows)
|
|
105
102
|
|
|
106
|
-
@patch('pygeai.core.services.rest.
|
|
103
|
+
@patch('pygeai.core.services.rest.GEAIApiService.delete')
|
|
107
104
|
def test_delete_dataset(self, mock_delete):
|
|
108
105
|
mock_delete.return_value = self.mock_response
|
|
109
106
|
result = self.client.delete_dataset("dataset-123")
|
|
110
107
|
mock_delete.assert_called_once()
|
|
111
108
|
self.assertEqual(result, {"id": "dataset-123", "status": "success"})
|
|
112
109
|
|
|
113
|
-
@patch('pygeai.core.services.rest.
|
|
110
|
+
@patch('pygeai.core.services.rest.GEAIApiService.post')
|
|
114
111
|
def test_create_dataset_row(self, mock_post):
|
|
115
112
|
mock_post.return_value = self.mock_response
|
|
116
113
|
row = {
|
|
@@ -123,34 +120,34 @@ class TestEvaluationDatasetClient(unittest.TestCase):
|
|
|
123
120
|
call_args = mock_post.call_args
|
|
124
121
|
self.assertEqual(call_args[1]['data'], row)
|
|
125
122
|
|
|
126
|
-
@patch('pygeai.core.services.rest.
|
|
123
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
127
124
|
def test_list_dataset_rows(self, mock_get):
|
|
128
125
|
mock_get.return_value = self.mock_response
|
|
129
126
|
result = self.client.list_dataset_rows("dataset-123")
|
|
130
127
|
mock_get.assert_called_once()
|
|
131
128
|
self.assertEqual(result, {"id": "dataset-123", "status": "success"})
|
|
132
129
|
|
|
133
|
-
@patch('pygeai.core.services.rest.
|
|
130
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
134
131
|
def test_get_dataset_row(self, mock_get):
|
|
135
132
|
mock_get.return_value = self.mock_response
|
|
136
133
|
result = self.client.get_dataset_row("dataset-123", "row-456")
|
|
137
134
|
mock_get.assert_called_once()
|
|
138
135
|
self.assertEqual(result, {"id": "dataset-123", "status": "success"})
|
|
139
136
|
|
|
140
|
-
@patch('pygeai.core.services.rest.
|
|
137
|
+
@patch('pygeai.core.services.rest.GEAIApiService.put')
|
|
141
138
|
def test_update_dataset_row(self, mock_put):
|
|
142
139
|
mock_put.return_value = self.mock_response
|
|
143
140
|
row = {"dataSetRowInput": "updated input"}
|
|
144
141
|
result = self.client.update_dataset_row("dataset-123", "row-456", row)
|
|
145
142
|
mock_put.assert_called_once()
|
|
146
143
|
|
|
147
|
-
@patch('pygeai.core.services.rest.
|
|
144
|
+
@patch('pygeai.core.services.rest.GEAIApiService.delete')
|
|
148
145
|
def test_delete_dataset_row(self, mock_delete):
|
|
149
146
|
mock_delete.return_value = self.mock_response
|
|
150
147
|
result = self.client.delete_dataset_row("dataset-123", "row-456")
|
|
151
148
|
mock_delete.assert_called_once()
|
|
152
149
|
|
|
153
|
-
@patch('pygeai.core.services.rest.
|
|
150
|
+
@patch('pygeai.core.services.rest.GEAIApiService.post')
|
|
154
151
|
def test_create_dataset_row_expected_source(self, mock_post):
|
|
155
152
|
mock_post.return_value = self.mock_response
|
|
156
153
|
result = self.client.create_expected_source(
|
|
@@ -162,19 +159,19 @@ class TestEvaluationDatasetClient(unittest.TestCase):
|
|
|
162
159
|
)
|
|
163
160
|
mock_post.assert_called_once()
|
|
164
161
|
|
|
165
|
-
@patch('pygeai.core.services.rest.
|
|
162
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
166
163
|
def test_list_dataset_row_expected_sources(self, mock_get):
|
|
167
164
|
mock_get.return_value = self.mock_response
|
|
168
165
|
result = self.client.list_expected_sources("dataset-123", "row-456")
|
|
169
166
|
mock_get.assert_called_once()
|
|
170
167
|
|
|
171
|
-
@patch('pygeai.core.services.rest.
|
|
168
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
172
169
|
def test_get_expected_source(self, mock_get):
|
|
173
170
|
mock_get.return_value = self.mock_response
|
|
174
171
|
result = self.client.get_expected_source("dataset-123", "row-456", "source-789")
|
|
175
172
|
mock_get.assert_called_once()
|
|
176
173
|
|
|
177
|
-
@patch('pygeai.core.services.rest.
|
|
174
|
+
@patch('pygeai.core.services.rest.GEAIApiService.put')
|
|
178
175
|
def test_update_expected_source(self, mock_put):
|
|
179
176
|
mock_put.return_value = self.mock_response
|
|
180
177
|
result = self.client.update_expected_source(
|
|
@@ -187,13 +184,13 @@ class TestEvaluationDatasetClient(unittest.TestCase):
|
|
|
187
184
|
)
|
|
188
185
|
mock_put.assert_called_once()
|
|
189
186
|
|
|
190
|
-
@patch('pygeai.core.services.rest.
|
|
187
|
+
@patch('pygeai.core.services.rest.GEAIApiService.delete')
|
|
191
188
|
def test_delete_expected_source(self, mock_delete):
|
|
192
189
|
mock_delete.return_value = self.mock_response
|
|
193
190
|
result = self.client.delete_expected_source("dataset-123", "row-456", "source-789")
|
|
194
191
|
mock_delete.assert_called_once()
|
|
195
192
|
|
|
196
|
-
@patch('pygeai.core.services.rest.
|
|
193
|
+
@patch('pygeai.core.services.rest.GEAIApiService.post')
|
|
197
194
|
def test_create_dataset_row_filter_variable(self, mock_post):
|
|
198
195
|
mock_post.return_value = self.mock_response
|
|
199
196
|
result = self.client.create_filter_variable(
|
|
@@ -206,19 +203,19 @@ class TestEvaluationDatasetClient(unittest.TestCase):
|
|
|
206
203
|
)
|
|
207
204
|
mock_post.assert_called_once()
|
|
208
205
|
|
|
209
|
-
@patch('pygeai.core.services.rest.
|
|
206
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
210
207
|
def test_list_dataset_row_filter_variables(self, mock_get):
|
|
211
208
|
mock_get.return_value = self.mock_response
|
|
212
209
|
result = self.client.list_filter_variables("dataset-123", "row-456")
|
|
213
210
|
mock_get.assert_called_once()
|
|
214
211
|
|
|
215
|
-
@patch('pygeai.core.services.rest.
|
|
212
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
216
213
|
def test_get_filter_variable(self, mock_get):
|
|
217
214
|
mock_get.return_value = self.mock_response
|
|
218
215
|
result = self.client.get_filter_variable("dataset-123", "row-456", "var-789")
|
|
219
216
|
mock_get.assert_called_once()
|
|
220
217
|
|
|
221
|
-
@patch('pygeai.core.services.rest.
|
|
218
|
+
@patch('pygeai.core.services.rest.GEAIApiService.put')
|
|
222
219
|
def test_update_filter_variable(self, mock_put):
|
|
223
220
|
mock_put.return_value = self.mock_response
|
|
224
221
|
result = self.client.update_filter_variable(
|
|
@@ -232,7 +229,7 @@ class TestEvaluationDatasetClient(unittest.TestCase):
|
|
|
232
229
|
)
|
|
233
230
|
mock_put.assert_called_once()
|
|
234
231
|
|
|
235
|
-
@patch('pygeai.core.services.rest.
|
|
232
|
+
@patch('pygeai.core.services.rest.GEAIApiService.delete')
|
|
236
233
|
def test_delete_filter_variable(self, mock_delete):
|
|
237
234
|
mock_delete.return_value = self.mock_response
|
|
238
235
|
result = self.client.delete_filter_variable("dataset-123", "row-456", "var-789")
|
|
@@ -240,7 +237,7 @@ class TestEvaluationDatasetClient(unittest.TestCase):
|
|
|
240
237
|
|
|
241
238
|
@patch('pathlib.Path.is_file')
|
|
242
239
|
@patch('pathlib.Path.open')
|
|
243
|
-
@patch('pygeai.core.services.rest.
|
|
240
|
+
@patch('pygeai.core.services.rest.GEAIApiService.post_file_binary')
|
|
244
241
|
def test_upload_dataset_rows_file_success(self, mock_post, mock_open_file, mock_is_file):
|
|
245
242
|
mock_is_file.return_value = True
|
|
246
243
|
mock_file = MagicMock()
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
from unittest.mock import patch, MagicMock
|
|
3
|
-
import json
|
|
4
3
|
|
|
5
|
-
from pygeai.core.base.session import Session
|
|
6
4
|
from pygeai.evaluation.plan.clients import EvaluationPlanClient
|
|
7
5
|
|
|
8
6
|
|
|
@@ -17,14 +15,14 @@ class TestEvaluationPlanClient(unittest.TestCase):
|
|
|
17
15
|
self.mock_response.json.return_value = {"id": "plan-123", "status": "success"}
|
|
18
16
|
self.mock_response.status_code = 200
|
|
19
17
|
|
|
20
|
-
@patch('pygeai.core.services.rest.
|
|
18
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
21
19
|
def test_list_evaluation_plans(self, mock_get):
|
|
22
20
|
mock_get.return_value = self.mock_response
|
|
23
21
|
result = self.client.list_evaluation_plans()
|
|
24
22
|
mock_get.assert_called_once()
|
|
25
23
|
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
26
24
|
|
|
27
|
-
@patch('pygeai.core.services.rest.
|
|
25
|
+
@patch('pygeai.core.services.rest.GEAIApiService.post')
|
|
28
26
|
def test_create_evaluation_plan_minimal(self, mock_post):
|
|
29
27
|
mock_post.return_value = self.mock_response
|
|
30
28
|
result = self.client.create_evaluation_plan(
|
|
@@ -36,7 +34,7 @@ class TestEvaluationPlanClient(unittest.TestCase):
|
|
|
36
34
|
self.assertEqual(call_args[1]['data']['evaluationPlanName'], "Test Plan")
|
|
37
35
|
self.assertEqual(call_args[1]['data']['evaluationPlanType'], "TextPromptAssistant")
|
|
38
36
|
|
|
39
|
-
@patch('pygeai.core.services.rest.
|
|
37
|
+
@patch('pygeai.core.services.rest.GEAIApiService.post')
|
|
40
38
|
def test_create_evaluation_plan_with_assistant(self, mock_post):
|
|
41
39
|
mock_post.return_value = self.mock_response
|
|
42
40
|
result = self.client.create_evaluation_plan(
|
|
@@ -52,7 +50,7 @@ class TestEvaluationPlanClient(unittest.TestCase):
|
|
|
52
50
|
self.assertEqual(call_args[1]['data']['evaluationPlanAssistantName'], "Test Assistant")
|
|
53
51
|
self.assertEqual(call_args[1]['data']['evaluationPlanAssistantRevision'], "1.0")
|
|
54
52
|
|
|
55
|
-
@patch('pygeai.core.services.rest.
|
|
53
|
+
@patch('pygeai.core.services.rest.GEAIApiService.post')
|
|
56
54
|
def test_create_evaluation_plan_with_all_params(self, mock_post):
|
|
57
55
|
mock_post.return_value = self.mock_response
|
|
58
56
|
system_metrics = [{"systemMetricId": "metric-1", "systemMetricWeight": 0.5}]
|
|
@@ -69,14 +67,14 @@ class TestEvaluationPlanClient(unittest.TestCase):
|
|
|
69
67
|
self.assertEqual(call_args[1]['data']['dataSetId'], "dataset-123")
|
|
70
68
|
self.assertEqual(call_args[1]['data']['systemMetrics'], system_metrics)
|
|
71
69
|
|
|
72
|
-
@patch('pygeai.core.services.rest.
|
|
70
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
73
71
|
def test_get_evaluation_plan(self, mock_get):
|
|
74
72
|
mock_get.return_value = self.mock_response
|
|
75
73
|
result = self.client.get_evaluation_plan("plan-123")
|
|
76
74
|
mock_get.assert_called_once()
|
|
77
75
|
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
78
76
|
|
|
79
|
-
@patch('pygeai.core.services.rest.
|
|
77
|
+
@patch('pygeai.core.services.rest.GEAIApiService.put')
|
|
80
78
|
def test_update_evaluation_plan_name_only(self, mock_put):
|
|
81
79
|
mock_put.return_value = self.mock_response
|
|
82
80
|
result = self.client.update_evaluation_plan(
|
|
@@ -88,7 +86,7 @@ class TestEvaluationPlanClient(unittest.TestCase):
|
|
|
88
86
|
self.assertEqual(call_args[1]['data']['evaluationPlanName'], "Updated Plan")
|
|
89
87
|
self.assertEqual(len(call_args[1]['data']), 1)
|
|
90
88
|
|
|
91
|
-
@patch('pygeai.core.services.rest.
|
|
89
|
+
@patch('pygeai.core.services.rest.GEAIApiService.put')
|
|
92
90
|
def test_update_evaluation_plan_multiple_fields(self, mock_put):
|
|
93
91
|
mock_put.return_value = self.mock_response
|
|
94
92
|
system_metrics = [{"systemMetricId": "metric-1", "systemMetricWeight": 0.8}]
|
|
@@ -110,21 +108,21 @@ class TestEvaluationPlanClient(unittest.TestCase):
|
|
|
110
108
|
self.assertEqual(call_args[1]['data']['evaluationPlanAssistantId'], "asst-456")
|
|
111
109
|
self.assertEqual(call_args[1]['data']['systemMetrics'], system_metrics)
|
|
112
110
|
|
|
113
|
-
@patch('pygeai.core.services.rest.
|
|
111
|
+
@patch('pygeai.core.services.rest.GEAIApiService.delete')
|
|
114
112
|
def test_delete_evaluation_plan(self, mock_delete):
|
|
115
113
|
mock_delete.return_value = self.mock_response
|
|
116
114
|
result = self.client.delete_evaluation_plan("plan-123")
|
|
117
115
|
mock_delete.assert_called_once()
|
|
118
116
|
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
119
117
|
|
|
120
|
-
@patch('pygeai.core.services.rest.
|
|
118
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
121
119
|
def test_list_evaluation_plan_system_metrics(self, mock_get):
|
|
122
120
|
mock_get.return_value = self.mock_response
|
|
123
121
|
result = self.client.list_evaluation_plan_system_metrics("plan-123")
|
|
124
122
|
mock_get.assert_called_once()
|
|
125
123
|
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
126
124
|
|
|
127
|
-
@patch('pygeai.core.services.rest.
|
|
125
|
+
@patch('pygeai.core.services.rest.GEAIApiService.post')
|
|
128
126
|
def test_add_evaluation_plan_system_metric(self, mock_post):
|
|
129
127
|
mock_post.return_value = self.mock_response
|
|
130
128
|
result = self.client.add_evaluation_plan_system_metric(
|
|
@@ -137,7 +135,7 @@ class TestEvaluationPlanClient(unittest.TestCase):
|
|
|
137
135
|
self.assertEqual(call_args[1]['data']['systemMetricId'], "metric-456")
|
|
138
136
|
self.assertEqual(call_args[1]['data']['systemMetricWeight'], 0.75)
|
|
139
137
|
|
|
140
|
-
@patch('pygeai.core.services.rest.
|
|
138
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
141
139
|
def test_get_evaluation_plan_system_metric(self, mock_get):
|
|
142
140
|
mock_get.return_value = self.mock_response
|
|
143
141
|
result = self.client.get_evaluation_plan_system_metric(
|
|
@@ -147,7 +145,7 @@ class TestEvaluationPlanClient(unittest.TestCase):
|
|
|
147
145
|
mock_get.assert_called_once()
|
|
148
146
|
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
149
147
|
|
|
150
|
-
@patch('pygeai.core.services.rest.
|
|
148
|
+
@patch('pygeai.core.services.rest.GEAIApiService.put')
|
|
151
149
|
def test_update_evaluation_plan_system_metric(self, mock_put):
|
|
152
150
|
mock_put.return_value = self.mock_response
|
|
153
151
|
result = self.client.update_evaluation_plan_system_metric(
|
|
@@ -159,7 +157,7 @@ class TestEvaluationPlanClient(unittest.TestCase):
|
|
|
159
157
|
call_args = mock_put.call_args
|
|
160
158
|
self.assertEqual(call_args[1]['data']['systemMetricWeight'], 0.9)
|
|
161
159
|
|
|
162
|
-
@patch('pygeai.core.services.rest.
|
|
160
|
+
@patch('pygeai.core.services.rest.GEAIApiService.delete')
|
|
163
161
|
def test_delete_evaluation_plan_system_metric(self, mock_delete):
|
|
164
162
|
mock_delete.return_value = self.mock_response
|
|
165
163
|
result = self.client.delete_evaluation_plan_system_metric(
|
|
@@ -169,21 +167,21 @@ class TestEvaluationPlanClient(unittest.TestCase):
|
|
|
169
167
|
mock_delete.assert_called_once()
|
|
170
168
|
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
171
169
|
|
|
172
|
-
@patch('pygeai.core.services.rest.
|
|
170
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
173
171
|
def test_list_system_metrics(self, mock_get):
|
|
174
172
|
mock_get.return_value = self.mock_response
|
|
175
173
|
result = self.client.list_system_metrics()
|
|
176
174
|
mock_get.assert_called_once()
|
|
177
175
|
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
178
176
|
|
|
179
|
-
@patch('pygeai.core.services.rest.
|
|
177
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
180
178
|
def test_get_system_metric(self, mock_get):
|
|
181
179
|
mock_get.return_value = self.mock_response
|
|
182
180
|
result = self.client.get_system_metric("metric-456")
|
|
183
181
|
mock_get.assert_called_once()
|
|
184
182
|
self.assertEqual(result, {"id": "plan-123", "status": "success"})
|
|
185
183
|
|
|
186
|
-
@patch('pygeai.core.services.rest.
|
|
184
|
+
@patch('pygeai.core.services.rest.GEAIApiService.post')
|
|
187
185
|
def test_execute_evaluation_plan(self, mock_post):
|
|
188
186
|
mock_post.return_value = self.mock_response
|
|
189
187
|
result = self.client.execute_evaluation_plan("plan-123")
|
|
@@ -2,7 +2,6 @@ import unittest
|
|
|
2
2
|
from unittest.mock import patch, MagicMock
|
|
3
3
|
|
|
4
4
|
from pygeai.evaluation.result.clients import EvaluationResultClient
|
|
5
|
-
from pygeai.core.base.session import Session
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
class TestEvaluationResultClient(unittest.TestCase):
|
|
@@ -15,7 +14,7 @@ class TestEvaluationResultClient(unittest.TestCase):
|
|
|
15
14
|
self.mock_response = MagicMock()
|
|
16
15
|
self.mock_response.status_code = 200
|
|
17
16
|
|
|
18
|
-
@patch('pygeai.core.services.rest.
|
|
17
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
19
18
|
def test_list_evaluation_results_success(self, mock_get):
|
|
20
19
|
self.mock_response.json.return_value = [{"id": "result-1", "status": "completed"}, {"id": "result-2", "status": "pending"}]
|
|
21
20
|
mock_get.return_value = self.mock_response
|
|
@@ -27,7 +26,7 @@ class TestEvaluationResultClient(unittest.TestCase):
|
|
|
27
26
|
self.assertEqual(result[0]["id"], "result-1")
|
|
28
27
|
self.assertEqual(result[1]["id"], "result-2")
|
|
29
28
|
|
|
30
|
-
@patch('pygeai.core.services.rest.
|
|
29
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
31
30
|
def test_list_evaluation_results_empty(self, mock_get):
|
|
32
31
|
self.mock_response.json.return_value = []
|
|
33
32
|
mock_get.return_value = self.mock_response
|
|
@@ -37,7 +36,7 @@ class TestEvaluationResultClient(unittest.TestCase):
|
|
|
37
36
|
mock_get.assert_called_once()
|
|
38
37
|
self.assertEqual(result, [])
|
|
39
38
|
|
|
40
|
-
@patch('pygeai.core.services.rest.
|
|
39
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
41
40
|
def test_get_evaluation_result_success(self, mock_get):
|
|
42
41
|
self.mock_response.json.return_value = {"id": "result-123", "status": "completed", "score": 0.95}
|
|
43
42
|
mock_get.return_value = self.mock_response
|
|
@@ -49,7 +48,7 @@ class TestEvaluationResultClient(unittest.TestCase):
|
|
|
49
48
|
self.assertEqual(result["status"], "completed")
|
|
50
49
|
self.assertEqual(result["score"], 0.95)
|
|
51
50
|
|
|
52
|
-
@patch('pygeai.core.services.rest.
|
|
51
|
+
@patch('pygeai.core.services.rest.GEAIApiService.get')
|
|
53
52
|
def test_get_evaluation_result_with_details(self, mock_get):
|
|
54
53
|
self.mock_response.json.return_value = {"id": "result-789", "status": "failed", "error": "Test error"}
|
|
55
54
|
mock_get.return_value = self.mock_response
|
|
@@ -15,7 +15,7 @@ class TestHealthClient(unittest.TestCase):
|
|
|
15
15
|
def setUp(self):
|
|
16
16
|
self.client = HealthClient()
|
|
17
17
|
|
|
18
|
-
@patch("pygeai.core.services.rest.
|
|
18
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
19
19
|
def test_check_api_status_success(self, mock_get):
|
|
20
20
|
expected_response = {"status": "healthy", "version": "1.0.0"}
|
|
21
21
|
mock_response = mock_get.return_value
|
|
@@ -27,7 +27,7 @@ class TestHealthClient(unittest.TestCase):
|
|
|
27
27
|
self.assertEqual(result, expected_response)
|
|
28
28
|
mock_get.assert_called_once_with(endpoint=STATUS_CHECK_V1)
|
|
29
29
|
|
|
30
|
-
@patch("pygeai.core.services.rest.
|
|
30
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
31
31
|
def test_check_api_status_json_decode_error(self, mock_get):
|
|
32
32
|
mock_response = mock_get.return_value
|
|
33
33
|
mock_response.status_code = 200
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
from unittest import TestCase
|
|
2
|
-
import unittest
|
|
3
2
|
import uuid
|
|
4
3
|
from pygeai.lab.managers import AILabManager
|
|
5
4
|
from pygeai.lab.models import Agent, AgentData, Prompt, LlmConfig, Model, Sampling, PromptExample, PromptOutput
|
|
6
|
-
from
|
|
7
|
-
from pygeai.core.common.exceptions import APIError, InvalidAPIResponseException
|
|
5
|
+
from pygeai.core.common.exceptions import APIError
|
|
8
6
|
|
|
9
7
|
|
|
10
8
|
class TestAILabCreateAgentIntegration(TestCase):
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from unittest import TestCase
|
|
2
2
|
from pygeai.lab.managers import AILabManager
|
|
3
3
|
from pygeai.lab.models import Agent, FilterSettings
|
|
4
|
-
from pygeai.core.common.exceptions import
|
|
4
|
+
from pygeai.core.common.exceptions import APIError
|
|
5
5
|
import copy
|
|
6
6
|
|
|
7
7
|
ai_lab_manager: AILabManager
|
|
@@ -4,9 +4,9 @@ import uuid
|
|
|
4
4
|
from pygeai.lab.managers import AILabManager
|
|
5
5
|
from pygeai.lab.models import (
|
|
6
6
|
AgenticProcess, KnowledgeBase, AgenticActivity, ArtifactSignal, Task,
|
|
7
|
-
UserSignal, Event, SequenceFlow
|
|
7
|
+
UserSignal, Event, SequenceFlow
|
|
8
8
|
)
|
|
9
|
-
from pygeai.core.common.exceptions import
|
|
9
|
+
from pygeai.core.common.exceptions import APIError
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class TestAILabCreateProcessIntegration(TestCase):
|