pygeai 0.5.0__py3-none-any.whl → 0.6.0b3__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 -1
- pygeai/auth/__init__.py +0 -0
- pygeai/auth/clients.py +55 -0
- pygeai/auth/endpoints.py +2 -0
- pygeai/cli/__init__.py +0 -1
- pygeai/cli/commands/auth.py +123 -0
- pygeai/cli/commands/base.py +22 -1
- pygeai/cli/commands/docs.py +105 -0
- pygeai/cli/texts/help.py +157 -24
- pygeai/core/files/responses.py +4 -3
- pygeai/lab/clients.py +3 -3
- pygeai/lab/tools/clients.py +4 -4
- pygeai/tests/admin/test_clients.py +143 -0
- pygeai/tests/auth/__init__.py +0 -0
- pygeai/tests/auth/test_clients.py +105 -0
- pygeai/tests/cli/commands/lab/test_ai_lab.py +41 -35
- pygeai/tests/cli/commands/lab/test_spec.py +24 -56
- pygeai/tests/cli/commands/test_chat.py +21 -3
- pygeai/tests/cli/commands/test_evaluation.py +649 -0
- pygeai/tests/cli/commands/test_secrets.py +171 -0
- pygeai/tests/core/base/data/models.py +7 -0
- pygeai/tests/core/base/test_mappers.py +43 -11
- pygeai/tests/core/base/test_models.py +3 -1
- pygeai/tests/core/base/test_responses.py +53 -0
- pygeai/tests/core/common/test_config.py +2 -3
- pygeai/tests/core/files/test_mappers.py +137 -0
- pygeai/tests/core/plugins/__init__.py +0 -0
- pygeai/tests/core/plugins/test_clients.py +64 -0
- pygeai/tests/evaluation/__init__.py +0 -0
- pygeai/tests/evaluation/dataset/__init__.py +0 -0
- pygeai/tests/evaluation/dataset/test_clients.py +263 -0
- pygeai/tests/evaluation/plan/__init__.py +0 -0
- pygeai/tests/evaluation/plan/test_clients.py +193 -0
- pygeai/tests/evaluation/result/__init__.py +0 -0
- pygeai/tests/evaluation/result/test_clients.py +64 -0
- pygeai/tests/integration/assistants/rag/test_create_rag.py +1 -1
- pygeai/tests/integration/chat/test_generate_image.py +1 -1
- pygeai/tests/integration/lab/agents/test_agents_list.py +1 -1
- pygeai/tests/integration/lab/agents/test_create_agent.py +3 -3
- pygeai/tests/integration/lab/agents/test_create_sharing_link.py +1 -1
- pygeai/tests/integration/lab/agents/test_delete_agent.py +2 -2
- pygeai/tests/integration/lab/agents/test_get_agent.py +1 -1
- pygeai/tests/integration/lab/agents/test_publish_agent_revision.py +2 -2
- pygeai/tests/integration/lab/agents/test_update_agent.py +3 -3
- pygeai/tests/integration/lab/processes/test_create_process.py +1 -1
- pygeai/tests/integration/lab/processes/test_create_task.py +211 -0
- pygeai/tests/integration/lab/processes/test_delete_process.py +111 -0
- pygeai/tests/integration/lab/processes/test_get_process.py +1 -1
- pygeai/tests/integration/lab/processes/test_list_process_instances.py +91 -0
- pygeai/tests/integration/lab/processes/test_list_processes.py +138 -0
- pygeai/tests/integration/lab/processes/test_publish_process_revision.py +232 -0
- pygeai/tests/integration/lab/processes/test_update_process.py +1 -1
- pygeai/tests/integration/lab/reasoning_strategies/test_get_reasoning_strategy.py +1 -1
- pygeai/tests/integration/lab/reasoning_strategies/test_list_reasoning_strategies.py +1 -1
- pygeai/tests/integration/lab/reasoning_strategies/test_update_reasoning_strategy.py +1 -1
- pygeai/tests/integration/lab/tools/test_create_tool.py +1 -1
- pygeai/tests/integration/lab/tools/test_delete_tool.py +1 -1
- pygeai/tests/integration/lab/tools/test_get_parameter.py +1 -1
- pygeai/tests/integration/lab/tools/test_get_tool.py +1 -1
- pygeai/tests/integration/lab/tools/test_list_tools.py +1 -1
- pygeai/tests/integration/lab/tools/test_publish_tool_revision.py +1 -1
- pygeai/tests/integration/lab/tools/test_set_parameter.py +1 -1
- pygeai/tests/integration/lab/tools/test_update_tool.py +1 -1
- pygeai/tests/lab/agents/test_clients.py +17 -34
- pygeai/tests/lab/processes/test_clients.py +30 -93
- pygeai/tests/lab/processes/test_mappers.py +12 -71
- pygeai/tests/lab/strategies/test_clients.py +63 -63
- pygeai/tests/lab/test_managers.py +3 -6
- pygeai/tests/lab/test_models.py +9 -8
- pygeai/tests/lab/tools/test_clients.py +22 -45
- pygeai/tests/migration/test_strategies.py +16 -16
- pygeai/tests/organization/test_mappers.py +11 -4
- pygeai/tests/organization/test_responses.py +137 -0
- {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/METADATA +1 -1
- {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/RECORD +79 -53
- {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/WHEEL +0 -0
- {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/entry_points.txt +0 -0
- {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/top_level.txt +0 -0
|
@@ -15,7 +15,7 @@ class TestAILabCreateProcessIntegration(TestCase):
|
|
|
15
15
|
"""
|
|
16
16
|
Set up the test environment.
|
|
17
17
|
"""
|
|
18
|
-
self.ai_lab_manager = AILabManager(
|
|
18
|
+
self.ai_lab_manager = AILabManager()
|
|
19
19
|
self.new_process = self.__load_process()
|
|
20
20
|
self.created_process: AgenticProcess = None
|
|
21
21
|
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
from unittest import TestCase
|
|
2
|
+
import unittest
|
|
3
|
+
import uuid
|
|
4
|
+
from pygeai.lab.managers import AILabManager
|
|
5
|
+
from pygeai.lab.models import Task, Prompt, ArtifactTypeList, ArtifactType
|
|
6
|
+
from pygeai.core.common.exceptions import APIResponseError, APIError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TestAILabCreateTaskIntegration(TestCase):
|
|
10
|
+
|
|
11
|
+
def setUp(self):
|
|
12
|
+
"""
|
|
13
|
+
Set up the test environment.
|
|
14
|
+
"""
|
|
15
|
+
self.ai_lab_manager = AILabManager()
|
|
16
|
+
self.new_task = self.__load_task()
|
|
17
|
+
self.created_task: Task = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def tearDown(self):
|
|
21
|
+
"""
|
|
22
|
+
Clean up after each test if necessary.
|
|
23
|
+
This can be used to delete the created task
|
|
24
|
+
"""
|
|
25
|
+
if isinstance(self.created_task, Task):
|
|
26
|
+
self.ai_lab_manager.delete_task(task_id=self.created_task.id)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def __load_task(self):
|
|
30
|
+
"""
|
|
31
|
+
Helper to load a complete task configuration for testing.
|
|
32
|
+
"""
|
|
33
|
+
unique_key = str(uuid.uuid4())
|
|
34
|
+
task = Task(
|
|
35
|
+
name=f"test_task_{unique_key[:8]}",
|
|
36
|
+
description=f"This is a sample task for testing 'test_task_{unique_key[:8]}'"
|
|
37
|
+
)
|
|
38
|
+
return task
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def __create_task(self, task=None, automatic_publish=False):
|
|
42
|
+
"""
|
|
43
|
+
Helper to create a task using ai_lab_manager.
|
|
44
|
+
"""
|
|
45
|
+
return self.ai_lab_manager.create_task(
|
|
46
|
+
task=self.new_task if task is None else task,
|
|
47
|
+
automatic_publish=automatic_publish
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_create_task(self):
|
|
52
|
+
"""
|
|
53
|
+
Test creating a task with all available fields populated.
|
|
54
|
+
"""
|
|
55
|
+
self.created_task = self.__create_task()
|
|
56
|
+
created_task = self.created_task
|
|
57
|
+
task = self.new_task
|
|
58
|
+
|
|
59
|
+
self.assertTrue(isinstance(created_task, Task), "Expected a created task")
|
|
60
|
+
|
|
61
|
+
# Assert the main fields of the created task
|
|
62
|
+
self.assertIsNotNone(created_task.id)
|
|
63
|
+
self.assertEqual(created_task.name, task.name)
|
|
64
|
+
self.assertEqual(created_task.description, task.description)
|
|
65
|
+
|
|
66
|
+
# Assert revision and status
|
|
67
|
+
self.assertEqual(self.created_task.revision, 1)
|
|
68
|
+
self.assertEqual(self.created_task.status, 'active')
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def test_create_task_with_prompt_data(self):
|
|
72
|
+
"""
|
|
73
|
+
Test creating a task with prompt data.
|
|
74
|
+
"""
|
|
75
|
+
unique_key = str(uuid.uuid4())
|
|
76
|
+
self.new_task = task = Task(
|
|
77
|
+
name=f"test_task_{unique_key[:8]}",
|
|
78
|
+
description=f"This is a sample task for testing 'test_task_{unique_key[:8]}'",
|
|
79
|
+
title_template="Test Task: {{issue}}",
|
|
80
|
+
prompt_data=Prompt(
|
|
81
|
+
instructions="Analyze the provided data and generate a summary.",
|
|
82
|
+
inputs=["input_data"],
|
|
83
|
+
outputs=[]
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
self.created_task = self.__create_task()
|
|
87
|
+
|
|
88
|
+
# Assert prompt data
|
|
89
|
+
self.assertIsNotNone(self.created_task.prompt_data)
|
|
90
|
+
self.assertEqual(self.created_task.prompt_data.instructions, "Analyze the provided data and generate a summary.")
|
|
91
|
+
self.assertEqual(self.created_task.prompt_data.inputs, ["input_data"])
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_create_task_with_custom_id(self):
|
|
95
|
+
"""
|
|
96
|
+
Test creating a task with a custom ID.
|
|
97
|
+
"""
|
|
98
|
+
unique_key = str(uuid.uuid4())
|
|
99
|
+
custom_id = unique_key
|
|
100
|
+
self.new_task = Task(
|
|
101
|
+
name=f"task_with_custom_id_{unique_key[:8]}",
|
|
102
|
+
id=custom_id
|
|
103
|
+
)
|
|
104
|
+
self.created_task = self.__create_task()
|
|
105
|
+
|
|
106
|
+
self.assertTrue(isinstance(self.created_task, Task), "Expected a created task")
|
|
107
|
+
self.assertEqual(self.created_task.id, custom_id)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def test_create_task_empty_name(self):
|
|
111
|
+
"""
|
|
112
|
+
Test creating a task with empty name should raise an error.
|
|
113
|
+
"""
|
|
114
|
+
test_params = [True, False]
|
|
115
|
+
|
|
116
|
+
for auto_publish in test_params:
|
|
117
|
+
with self.subTest(auto_publish=auto_publish):
|
|
118
|
+
self.new_task.name = ""
|
|
119
|
+
with self.assertRaises((APIError, ValueError)) as exception:
|
|
120
|
+
self.__create_task(automatic_publish=auto_publish)
|
|
121
|
+
|
|
122
|
+
self.assertTrue(
|
|
123
|
+
"Task name cannot be empty" in str(exception.exception),
|
|
124
|
+
f"Expected an error about empty task name with autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def test_create_task_duplicated_name(self):
|
|
129
|
+
"""
|
|
130
|
+
Test creating a task with a duplicate name should raise an error.
|
|
131
|
+
"""
|
|
132
|
+
test_params = [True, False]
|
|
133
|
+
created_task = self.__create_task()
|
|
134
|
+
|
|
135
|
+
for auto_publish in test_params:
|
|
136
|
+
with self.subTest(auto_publish=auto_publish):
|
|
137
|
+
loaded_task = self.__load_task()
|
|
138
|
+
loaded_task.name = created_task.name
|
|
139
|
+
with self.assertRaises(APIError) as exception:
|
|
140
|
+
self.__create_task(task=loaded_task, automatic_publish=auto_publish)
|
|
141
|
+
|
|
142
|
+
self.assertIn(
|
|
143
|
+
"already exists",
|
|
144
|
+
str(exception.exception).lower(),
|
|
145
|
+
f"Expected an error about duplicated task name with autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def test_create_task_invalid_name_characters(self):
|
|
150
|
+
"""
|
|
151
|
+
Test creating a task with invalid characters in name should raise a validation error.
|
|
152
|
+
"""
|
|
153
|
+
test_params = [True, False]
|
|
154
|
+
|
|
155
|
+
for auto_publish in test_params:
|
|
156
|
+
with self.subTest(auto_publish=auto_publish):
|
|
157
|
+
invalid_names = [
|
|
158
|
+
f"task_{str(uuid.uuid4())[:8]}:invalid",
|
|
159
|
+
f"task_{str(uuid.uuid4())[:8]}/invalid"
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
for invalid_name in invalid_names:
|
|
163
|
+
new_task = self.__load_task()
|
|
164
|
+
new_task.name = invalid_name
|
|
165
|
+
|
|
166
|
+
with self.assertRaises((APIError, ValueError)) as exception:
|
|
167
|
+
self.__create_task(task=new_task, automatic_publish=auto_publish)
|
|
168
|
+
|
|
169
|
+
self.assertTrue(
|
|
170
|
+
f"Invalid character in name ({':' if ':' in invalid_name else '/'} is not allowed).",
|
|
171
|
+
f"Expected an error about invalid character in task name with autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def test_create_task_autopublish_disabled(self):
|
|
176
|
+
"""
|
|
177
|
+
Test creating a task without automatic publish (default behavior).
|
|
178
|
+
"""
|
|
179
|
+
self.created_task = self.__create_task(automatic_publish=False)
|
|
180
|
+
|
|
181
|
+
# Task should be created as draft by default
|
|
182
|
+
self.assertTrue(
|
|
183
|
+
self.created_task.is_draft is True or
|
|
184
|
+
self.created_task.is_draft is None,
|
|
185
|
+
"Expected the task to be created as draft when autopublish is disabled"
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def test_create_task_with_complex_prompt_data(self):
|
|
190
|
+
"""
|
|
191
|
+
Test creating a task with complex prompt data including outputs.
|
|
192
|
+
"""
|
|
193
|
+
unique_key = str(uuid.uuid4())
|
|
194
|
+
self.new_task = Task(
|
|
195
|
+
name=f"task_complex_prompt_{unique_key[:8]}",
|
|
196
|
+
prompt_data=Prompt(
|
|
197
|
+
instructions="Analyze the provided data and generate multiple outputs.",
|
|
198
|
+
inputs=["input_data", "parameters"],
|
|
199
|
+
outputs=[
|
|
200
|
+
{"key": "summary", "description": "Data summary"},
|
|
201
|
+
{"key": "analysis", "description": "Detailed analysis"}
|
|
202
|
+
]
|
|
203
|
+
)
|
|
204
|
+
)
|
|
205
|
+
self.created_task = self.__create_task()
|
|
206
|
+
|
|
207
|
+
self.assertIsNotNone(self.created_task.prompt_data)
|
|
208
|
+
self.assertEqual(len(self.created_task.prompt_data.inputs), 2)
|
|
209
|
+
self.assertIn("input_data", self.created_task.prompt_data.inputs)
|
|
210
|
+
self.assertIn("parameters", self.created_task.prompt_data.inputs)
|
|
211
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
from unittest import TestCase
|
|
2
|
+
import uuid
|
|
3
|
+
from pygeai.lab.managers import AILabManager
|
|
4
|
+
from pygeai.lab.models import AgenticProcess, KnowledgeBase, AgenticActivity, ArtifactSignal, UserSignal, Event, SequenceFlow
|
|
5
|
+
from pygeai.core.common.exceptions import InvalidAPIResponseException, MissingRequirementException
|
|
6
|
+
from pygeai.core.base.responses import EmptyResponse
|
|
7
|
+
|
|
8
|
+
ai_lab_manager: AILabManager
|
|
9
|
+
|
|
10
|
+
class TestAILabDeleteProcessIntegration(TestCase):
|
|
11
|
+
|
|
12
|
+
def setUp(self):
|
|
13
|
+
self.ai_lab_manager = AILabManager()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def __create_process(self):
|
|
17
|
+
"""
|
|
18
|
+
Helper to create a process with the current ai_lab_manager.
|
|
19
|
+
"""
|
|
20
|
+
unique_key = str(uuid.uuid4())
|
|
21
|
+
process = AgenticProcess(
|
|
22
|
+
key="product_def",
|
|
23
|
+
name=f"Test Process {unique_key[:8]}",
|
|
24
|
+
description="This is a sample process",
|
|
25
|
+
kb=KnowledgeBase(name="basic-sample", artifact_type_name=["sample-artifact"]),
|
|
26
|
+
agentic_activities=[
|
|
27
|
+
AgenticActivity(key="activityOne", name="First Step", task_name="basic-task", agent_name="GoogleSummarizer2", agent_revision_id=0)
|
|
28
|
+
],
|
|
29
|
+
artifact_signals=[
|
|
30
|
+
ArtifactSignal(key="artifact.upload.1", name="artifact.upload", handling_type="C", artifact_type_name=["sample-artifact"])
|
|
31
|
+
],
|
|
32
|
+
user_signals=[
|
|
33
|
+
UserSignal(key="signal_done", name="process-completed")
|
|
34
|
+
],
|
|
35
|
+
start_event=Event(key="artifact.upload.1", name="artifact.upload"),
|
|
36
|
+
end_event=Event(key="end", name="Done"),
|
|
37
|
+
sequence_flows=[
|
|
38
|
+
SequenceFlow(key="step1", source_key="artifact.upload.1", target_key="activityOne"),
|
|
39
|
+
SequenceFlow(key="step2", source_key="activityOne", target_key="signal_done"),
|
|
40
|
+
SequenceFlow(key="stepEnd", source_key="signal_done", target_key="end")
|
|
41
|
+
]
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return self.ai_lab_manager.create_process(
|
|
45
|
+
process=process,
|
|
46
|
+
automatic_publish=False
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def __delete_process(self, process_id: str = None, process_name: str = None):
|
|
51
|
+
return self.ai_lab_manager.delete_process(
|
|
52
|
+
process_id=process_id,
|
|
53
|
+
process_name=process_name
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def test_delete_process_by_id(self):
|
|
58
|
+
created_process = self.__create_process()
|
|
59
|
+
deleted_process = self.__delete_process(process_id=created_process.id)
|
|
60
|
+
print(deleted_process)
|
|
61
|
+
|
|
62
|
+
self.assertEqual(
|
|
63
|
+
deleted_process.content,
|
|
64
|
+
"Process deleted successfully",
|
|
65
|
+
"Expected confirmation message after deletion"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def test_delete_process_by_name(self):
|
|
70
|
+
created_process = self.__create_process()
|
|
71
|
+
deleted_process = self.__delete_process(process_id="",process_name=created_process.name)
|
|
72
|
+
|
|
73
|
+
self.assertEqual(
|
|
74
|
+
deleted_process.content,
|
|
75
|
+
"Process deleted successfully",
|
|
76
|
+
"Expected confirmation message after deletion"
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_delete_process_no_parameters(self):
|
|
81
|
+
with self.assertRaises(MissingRequirementException) as exception:
|
|
82
|
+
self.__delete_process()
|
|
83
|
+
self.assertIn(
|
|
84
|
+
"Either process_id or process_name must be provided",
|
|
85
|
+
str(exception.exception),
|
|
86
|
+
"Expected error message for missing parameters"
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_delete_process_invalid_process_id(self):
|
|
91
|
+
invalid_id = "0026e53d-ea78-4cac-af9f-12650invalid"
|
|
92
|
+
with self.assertRaises(InvalidAPIResponseException) as exception:
|
|
93
|
+
self.__delete_process(process_id=invalid_id)
|
|
94
|
+
|
|
95
|
+
self.assertIn(
|
|
96
|
+
f"Unable to delete process {invalid_id}",
|
|
97
|
+
str(exception.exception),
|
|
98
|
+
"Expected error message for invalid process id"
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def test_delete_process_invalid_process_name(self):
|
|
103
|
+
invalid_name = "NonExistentProcessName123"
|
|
104
|
+
with self.assertRaises(InvalidAPIResponseException) as exception:
|
|
105
|
+
self.__delete_process(process_name=invalid_name)
|
|
106
|
+
|
|
107
|
+
self.assertIn(
|
|
108
|
+
f"Unable to delete process {invalid_name}",
|
|
109
|
+
str(exception.exception),
|
|
110
|
+
"Expected error message for invalid process name"
|
|
111
|
+
)
|
|
@@ -13,7 +13,7 @@ class TestAILabGetProcessIntegration(TestCase):
|
|
|
13
13
|
"""
|
|
14
14
|
Set up the test environment.
|
|
15
15
|
"""
|
|
16
|
-
self.ai_lab_manager = AILabManager(
|
|
16
|
+
self.ai_lab_manager = AILabManager()
|
|
17
17
|
self.process_id = "7e28e9ab-b9a2-417e-9e87-ed7f6ec9534b"
|
|
18
18
|
self.process_name = "Test Process For Sdk Project"
|
|
19
19
|
self.filter_settings = FilterSettings(
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
from unittest import TestCase
|
|
2
|
+
import uuid
|
|
3
|
+
from pygeai.lab.managers import AILabManager
|
|
4
|
+
from pygeai.lab.models import FilterSettings, ProcessInstanceList, AgenticProcess, KnowledgeBase, AgenticActivity, ArtifactSignal, UserSignal, Event, SequenceFlow
|
|
5
|
+
from pygeai.core.common.exceptions import APIError, MissingRequirementException
|
|
6
|
+
import copy
|
|
7
|
+
|
|
8
|
+
ai_lab_manager: AILabManager
|
|
9
|
+
|
|
10
|
+
class TestAILabListProcessInstancesIntegration(TestCase):
|
|
11
|
+
|
|
12
|
+
def setUp(self):
|
|
13
|
+
self.ai_lab_manager = AILabManager()
|
|
14
|
+
# Using a known process ID that should have instances for testing
|
|
15
|
+
self.process_id = "6c9c99a0-9eb1-4647-9f2f-886cf6a51ac0"
|
|
16
|
+
self.filter_settings = FilterSettings(
|
|
17
|
+
start=0,
|
|
18
|
+
count=10,
|
|
19
|
+
is_active=False
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def __list_process_instances(self, process_id: str = None, filter_settings: FilterSettings = None):
|
|
24
|
+
process_id = process_id if process_id is not None else self.process_id
|
|
25
|
+
filter_settings = filter_settings if filter_settings is not None else self.filter_settings
|
|
26
|
+
return self.ai_lab_manager.list_process_instances(
|
|
27
|
+
process_id=process_id,
|
|
28
|
+
filter_settings=filter_settings
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_default_list_process_instances(self):
|
|
33
|
+
result = self.__list_process_instances()
|
|
34
|
+
self.assertIsInstance(result, ProcessInstanceList, "Expected a ProcessInstanceList")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_list_process_instances_completed(self):
|
|
38
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
39
|
+
filter_settings.status = "Completed"
|
|
40
|
+
result = self.__list_process_instances(filter_settings=filter_settings)
|
|
41
|
+
|
|
42
|
+
self.assertIsInstance(result, ProcessInstanceList, "Expected a ProcessInstanceList")
|
|
43
|
+
if result.instances:
|
|
44
|
+
for instance in result.instances:
|
|
45
|
+
self.assertTrue(
|
|
46
|
+
instance.status == 'Completed',
|
|
47
|
+
"Expected all instances to be completed"
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_list_process_instances_include_inactive(self):
|
|
52
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
53
|
+
filter_settings.is_active = True
|
|
54
|
+
result = self.__list_process_instances(filter_settings=filter_settings)
|
|
55
|
+
|
|
56
|
+
self.assertIsInstance(result, ProcessInstanceList, "Expected a ProcessInstanceList")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_list_process_instances_small_count(self):
|
|
60
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
61
|
+
filter_settings.count = 2
|
|
62
|
+
result = self.__list_process_instances(filter_settings=filter_settings)
|
|
63
|
+
|
|
64
|
+
self.assertIsInstance(result, ProcessInstanceList, "Expected a ProcessInstanceList")
|
|
65
|
+
self.assertLessEqual(
|
|
66
|
+
len(result.instances), 2,
|
|
67
|
+
"Expected list of process instances returned to be 2 or less"
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def test_list_process_instances_big_count(self):
|
|
72
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
73
|
+
filter_settings.count = 50
|
|
74
|
+
result = self.__list_process_instances(filter_settings=filter_settings)
|
|
75
|
+
|
|
76
|
+
self.assertIsInstance(result, ProcessInstanceList, "Expected a ProcessInstanceList")
|
|
77
|
+
self.assertLessEqual(
|
|
78
|
+
len(result.instances), 50,
|
|
79
|
+
"Expected list of process instances returned to be 50 or less"
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def test_list_process_instances_empty_process_id(self):
|
|
84
|
+
with self.assertRaises(ValueError) as exception:
|
|
85
|
+
self.__list_process_instances(process_id="")
|
|
86
|
+
|
|
87
|
+
# The specific error message will depend on implementation
|
|
88
|
+
self.assertTrue(
|
|
89
|
+
"Process ID must be provided" in str(exception.exception),
|
|
90
|
+
"Expected error message for empty process id"
|
|
91
|
+
)
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
from unittest import TestCase
|
|
2
|
+
import unittest
|
|
3
|
+
from pygeai.lab.managers import AILabManager
|
|
4
|
+
from pygeai.lab.models import FilterSettings, AgenticProcessList
|
|
5
|
+
import copy
|
|
6
|
+
|
|
7
|
+
ai_lab_manager: AILabManager
|
|
8
|
+
|
|
9
|
+
class TestAILabListProcessesIntegration(TestCase):
|
|
10
|
+
|
|
11
|
+
def setUp(self):
|
|
12
|
+
self.ai_lab_manager = AILabManager()
|
|
13
|
+
self.filter_settings = FilterSettings(
|
|
14
|
+
start=0,
|
|
15
|
+
count=100,
|
|
16
|
+
allow_drafts=False
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def __list_processes(self, filter_settings: FilterSettings = None):
|
|
21
|
+
return self.ai_lab_manager.list_processes(
|
|
22
|
+
filter_settings if filter_settings is not None else self.filter_settings
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_default_list_processes(self):
|
|
27
|
+
processes = self.__list_processes()
|
|
28
|
+
self.assertIsInstance(processes, AgenticProcessList, "Expected a list of processes")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_list_processes_with_id_filter(self):
|
|
32
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
33
|
+
filter_settings.id = "7e28e9ab-b9a2-417e-9e87-ed7f6ec9534b"
|
|
34
|
+
result = self.__list_processes(filter_settings=filter_settings)
|
|
35
|
+
print(result)
|
|
36
|
+
|
|
37
|
+
self.assertIsInstance(result, AgenticProcessList, "Expected a list of processes")
|
|
38
|
+
if result.processes:
|
|
39
|
+
for process in result.processes:
|
|
40
|
+
self.assertEqual(
|
|
41
|
+
process.id, filter_settings.id,
|
|
42
|
+
f"Expected process ID to match filter value: {filter_settings.id}"
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_list_processes_with_name_filter(self):
|
|
47
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
48
|
+
filter_settings.name = "ArithmeticProcess"
|
|
49
|
+
result = self.__list_processes(filter_settings=filter_settings)
|
|
50
|
+
print(result)
|
|
51
|
+
|
|
52
|
+
self.assertIsInstance(result, AgenticProcessList, "Expected a list of processes")
|
|
53
|
+
if result.processes:
|
|
54
|
+
for process in result.processes:
|
|
55
|
+
self.assertEqual(
|
|
56
|
+
"ArithmeticProcess",
|
|
57
|
+
process.name,
|
|
58
|
+
"Expected process name to contain filter value"
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_list_processes_with_status_filter_active(self):
|
|
63
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
64
|
+
filter_settings.status = "active"
|
|
65
|
+
result = self.__list_processes(filter_settings=filter_settings)
|
|
66
|
+
|
|
67
|
+
self.assertIsInstance(result, AgenticProcessList, "Expected a list of processes")
|
|
68
|
+
if result.processes:
|
|
69
|
+
for process in result.processes:
|
|
70
|
+
self.assertEqual(
|
|
71
|
+
process.status.lower(), "active",
|
|
72
|
+
"Expected all processes to have active status"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_list_processes_with_status_filter_inactive(self):
|
|
77
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
78
|
+
filter_settings.status = "inactive"
|
|
79
|
+
result = self.__list_processes(filter_settings=filter_settings)
|
|
80
|
+
|
|
81
|
+
self.assertIsInstance(result, AgenticProcessList, "Expected a list of processes")
|
|
82
|
+
if result.processes:
|
|
83
|
+
for process in result.processes:
|
|
84
|
+
self.assertEqual(
|
|
85
|
+
process.status.lower(), "inactive",
|
|
86
|
+
"Expected all processes to have inactive status"
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_list_processes_small_count(self):
|
|
91
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
92
|
+
filter_settings.count = 2
|
|
93
|
+
result = self.__list_processes(filter_settings=filter_settings)
|
|
94
|
+
|
|
95
|
+
self.assertIsInstance(result, AgenticProcessList, "Expected a list of processes")
|
|
96
|
+
self.assertLessEqual(
|
|
97
|
+
len(result.processes), 2,
|
|
98
|
+
"Expected list of processes returned to be 2 or less"
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def test_list_processes_big_count(self):
|
|
103
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
104
|
+
filter_settings.count = 500
|
|
105
|
+
result = self.__list_processes(filter_settings=filter_settings)
|
|
106
|
+
|
|
107
|
+
self.assertIsInstance(result, AgenticProcessList, "Expected a list of processes")
|
|
108
|
+
self.assertLessEqual(
|
|
109
|
+
len(result.processes), 500,
|
|
110
|
+
"Expected list of processes returned to be 500 or less"
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
@unittest.skip("Method is not returning drafts")
|
|
114
|
+
def test_list_processes_allow_drafts_true(self):
|
|
115
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
116
|
+
filter_settings.allow_drafts = True
|
|
117
|
+
result = self.__list_processes(filter_settings=filter_settings)
|
|
118
|
+
|
|
119
|
+
self.assertIsInstance(result, AgenticProcessList, "Expected a list of processes")
|
|
120
|
+
# Note: This test verifies that draft processes are included when allow_drafts=True
|
|
121
|
+
has_draft = any(p.is_draft for p in result.processes)
|
|
122
|
+
self.assertTrue(has_draft, "Expected at least one draft process")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def test_list_processes_allow_drafts_false(self):
|
|
126
|
+
filter_settings = copy.deepcopy(self.filter_settings)
|
|
127
|
+
filter_settings.allow_drafts = False
|
|
128
|
+
result = self.__list_processes(filter_settings=filter_settings)
|
|
129
|
+
|
|
130
|
+
self.assertIsInstance(result, AgenticProcessList, "Expected a list of processes")
|
|
131
|
+
# Note: This test verifies that draft processes are excluded when allow_drafts=False
|
|
132
|
+
has_draft = any(p.is_draft == False for p in result.processes)
|
|
133
|
+
self.assertTrue(has_draft, "Expected at least one draft process")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def test_list_processes_none_filter_settings(self):
|
|
137
|
+
result = self.__list_processes(filter_settings=None)
|
|
138
|
+
self.assertIsInstance(result, AgenticProcessList, "Expected a list of processes")
|