pygeai 0.4.0b12__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/base/session.py +1 -1
- 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/cli/docker/__init__.py +0 -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 +24 -5
- pygeai/tests/integration/chat/test_generate_image.py +2 -6
- pygeai/tests/integration/lab/agents/test_agents_list.py +1 -1
- pygeai/tests/integration/lab/agents/test_create_agent.py +16 -10
- pygeai/tests/integration/lab/agents/test_create_sharing_link.py +5 -2
- 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 +18 -21
- pygeai/tests/integration/lab/processes/__init__.py +0 -0
- pygeai/tests/integration/lab/processes/test_create_process.py +345 -0
- 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 +201 -0
- 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 +289 -0
- pygeai/tests/integration/lab/reasoning_strategies/__init__.py +0 -0
- pygeai/tests/integration/lab/reasoning_strategies/test_get_reasoning_strategy.py +70 -0
- pygeai/tests/integration/lab/reasoning_strategies/test_list_reasoning_strategies.py +93 -0
- pygeai/tests/integration/lab/reasoning_strategies/test_update_reasoning_strategy.py +149 -0
- pygeai/tests/integration/lab/tools/test_create_tool.py +13 -17
- pygeai/tests/integration/lab/tools/test_delete_tool.py +4 -4
- pygeai/tests/integration/lab/tools/test_get_parameter.py +1 -1
- pygeai/tests/integration/lab/tools/test_get_tool.py +4 -4
- 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 +9 -10
- 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/tests/snippets/lab/agentic_flow_example_4.py +23 -23
- pygeai/tests/snippets/lab/samples/summarize_files.py +3 -3
- pygeai/tests/snippets/lab/use_cases/file_summarizer_example.py +3 -3
- pygeai/tests/snippets/lab/use_cases/file_summarizer_example_2.py +11 -11
- pygeai/tests/snippets/lab/use_cases/update_web_reader.py +1 -2
- {pygeai-0.4.0b12.dist-info → pygeai-0.6.0b3.dist-info}/METADATA +44 -16
- {pygeai-0.4.0b12.dist-info → pygeai-0.6.0b3.dist-info}/RECORD +88 -53
- {pygeai-0.4.0b12.dist-info → pygeai-0.6.0b3.dist-info}/WHEEL +0 -0
- {pygeai-0.4.0b12.dist-info → pygeai-0.6.0b3.dist-info}/entry_points.txt +0 -0
- {pygeai-0.4.0b12.dist-info → pygeai-0.6.0b3.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.4.0b12.dist-info → pygeai-0.6.0b3.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from unittest import TestCase
|
|
2
|
+
import unittest
|
|
2
3
|
from pygeai.lab.managers import AILabManager
|
|
3
4
|
from pygeai.lab.models import SharingLink
|
|
4
5
|
from pygeai.core.common.exceptions import APIError, MissingRequirementException
|
|
@@ -8,7 +9,7 @@ ai_lab_manager: AILabManager
|
|
|
8
9
|
class TestAILabCreateSharingLinkIntegration(TestCase):
|
|
9
10
|
|
|
10
11
|
def setUp(self):
|
|
11
|
-
self.ai_lab_manager = AILabManager(
|
|
12
|
+
self.ai_lab_manager = AILabManager()
|
|
12
13
|
self.agent_id = "0026e53d-ea78-4cac-af9f-12650e5bb6d9"
|
|
13
14
|
|
|
14
15
|
def __create_sharing_link(self, agent_id=None):
|
|
@@ -16,7 +17,7 @@ class TestAILabCreateSharingLinkIntegration(TestCase):
|
|
|
16
17
|
agent_id=self.agent_id if agent_id is None else agent_id
|
|
17
18
|
)
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
@unittest.skip("Endpoint is not found. Validate if it was deleted")
|
|
20
21
|
def test_create_sharing_link(self):
|
|
21
22
|
shared_link = self.__create_sharing_link()
|
|
22
23
|
self.assertIsInstance(shared_link, SharingLink, "Expected response to be an instance of SharingLink")
|
|
@@ -46,6 +47,7 @@ class TestAILabCreateSharingLinkIntegration(TestCase):
|
|
|
46
47
|
)
|
|
47
48
|
|
|
48
49
|
|
|
50
|
+
@unittest.skip("Endpoint is not found. Validate if it was deleted")
|
|
49
51
|
def test_create_sharing_link_no_agent_id(self):
|
|
50
52
|
with self.assertRaises(MissingRequirementException) as context:
|
|
51
53
|
self.__create_sharing_link(agent_id="")
|
|
@@ -56,6 +58,7 @@ class TestAILabCreateSharingLinkIntegration(TestCase):
|
|
|
56
58
|
)
|
|
57
59
|
|
|
58
60
|
|
|
61
|
+
@unittest.skip("Endpoint is not found. Validate if it was deleted")
|
|
59
62
|
def test_create_sharing_link_invalid_agent_id(self):
|
|
60
63
|
with self.assertRaises(APIError) as exception:
|
|
61
64
|
invalid_id = "0026e53d-ea78-4cac-af9f-12650invalid"
|
|
@@ -9,7 +9,7 @@ ai_lab_manager: AILabManager
|
|
|
9
9
|
class TestAILabDeleteAgentIntegration(TestCase):
|
|
10
10
|
|
|
11
11
|
def setUp(self):
|
|
12
|
-
self.ai_lab_manager = AILabManager(
|
|
12
|
+
self.ai_lab_manager = AILabManager()
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
def __create_agent(self):
|
|
@@ -29,7 +29,7 @@ class TestAILabDeleteAgentIntegration(TestCase):
|
|
|
29
29
|
max_tokens=1800,
|
|
30
30
|
timeout=0
|
|
31
31
|
),
|
|
32
|
-
models=[Model(name="gpt-
|
|
32
|
+
models=[Model(name="gpt-4o")]
|
|
33
33
|
)
|
|
34
34
|
)
|
|
35
35
|
|
|
@@ -14,7 +14,7 @@ class TestAILabGetAgentIntegration(TestCase):
|
|
|
14
14
|
]
|
|
15
15
|
|
|
16
16
|
def setUp(self):
|
|
17
|
-
self.ai_lab_manager = AILabManager(
|
|
17
|
+
self.ai_lab_manager = AILabManager()
|
|
18
18
|
self.agent_id = "0026e53d-ea78-4cac-af9f-12650e5bb6d9"
|
|
19
19
|
self.filter_settings = FilterSettings(
|
|
20
20
|
revision="0",
|
|
@@ -9,7 +9,7 @@ ai_lab_manager: AILabManager
|
|
|
9
9
|
class TestAILabPublishAgentRevisionIntegration(TestCase):
|
|
10
10
|
|
|
11
11
|
def setUp(self):
|
|
12
|
-
self.ai_lab_manager = AILabManager(
|
|
12
|
+
self.ai_lab_manager = AILabManager()
|
|
13
13
|
self.agent_id = "b4b09935-2ad2-42c0-bd55-1ee6fa4b6034"
|
|
14
14
|
|
|
15
15
|
|
|
@@ -46,7 +46,7 @@ class TestAILabPublishAgentRevisionIntegration(TestCase):
|
|
|
46
46
|
timeout=0,
|
|
47
47
|
sampling=Sampling(temperature=0.3, top_k=0, top_p=0)
|
|
48
48
|
),
|
|
49
|
-
models=[Model(name="openai/gpt-
|
|
49
|
+
models=[Model(name="openai/gpt-4o")]
|
|
50
50
|
)
|
|
51
51
|
)
|
|
52
52
|
|
|
@@ -11,7 +11,7 @@ class TestAILabUpdateAgentIntegration(TestCase):
|
|
|
11
11
|
"""
|
|
12
12
|
Set up the test environment.
|
|
13
13
|
"""
|
|
14
|
-
self.ai_lab_manager = AILabManager(
|
|
14
|
+
self.ai_lab_manager = AILabManager()
|
|
15
15
|
|
|
16
16
|
load_agent = self.__load_agent()
|
|
17
17
|
self.agent_to_update = load_agent["agent"]
|
|
@@ -43,7 +43,7 @@ class TestAILabUpdateAgentIntegration(TestCase):
|
|
|
43
43
|
timeout=0,
|
|
44
44
|
sampling=Sampling(temperature=0.3, top_k=0, top_p=0)
|
|
45
45
|
),
|
|
46
|
-
models=[Model(name="openai/gpt-
|
|
46
|
+
models=[Model(name="openai/gpt-4o")]
|
|
47
47
|
)
|
|
48
48
|
)
|
|
49
49
|
|
|
@@ -81,7 +81,7 @@ class TestAILabUpdateAgentIntegration(TestCase):
|
|
|
81
81
|
self.assertEqual(updated_agent.agent_data.models[0].name, "gemini/gemini-1.5-flash-8b-exp-0827")
|
|
82
82
|
self.assertTrue(updated_agent.is_draft, "gemini/gemini-1.5-flash-8b-exp-0827")
|
|
83
83
|
|
|
84
|
-
self.agent_to_update.agent_data.models[0].name = "openai/gpt-
|
|
84
|
+
self.agent_to_update.agent_data.models[0].name = "openai/gpt-4o"
|
|
85
85
|
self.__update_agent()
|
|
86
86
|
|
|
87
87
|
|
|
@@ -191,23 +191,21 @@ class TestAILabUpdateAgentIntegration(TestCase):
|
|
|
191
191
|
self.agent_to_update.agent_data.prompt.instructions = ""
|
|
192
192
|
|
|
193
193
|
for auto_publish in test_params:
|
|
194
|
-
with self.subTest(input=auto_publish):
|
|
195
|
-
|
|
196
|
-
self.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
f"Expected a validation error about allowed values for instructions when autopublish is {'enabled' if auto_publish else 'disabled'}"
|
|
207
|
-
)
|
|
194
|
+
with self.subTest(input=auto_publish):
|
|
195
|
+
if auto_publish == True:
|
|
196
|
+
with self.assertRaises(ValidationError) as exception:
|
|
197
|
+
self.__update_agent(automatic_publish=auto_publish)
|
|
198
|
+
self.assertIn(
|
|
199
|
+
"agent_data.prompt must have at least instructions for publication",
|
|
200
|
+
str(exception.exception),
|
|
201
|
+
f"Expected a validation error about allowed values for instructions when autopublish is {'enabled' if auto_publish else 'disabled'}"
|
|
202
|
+
)
|
|
203
|
+
else:
|
|
204
|
+
updated_agent = self.__update_agent(automatic_publish=auto_publish)
|
|
205
|
+
self.assertTrue(isinstance(updated_agent, Agent))
|
|
208
206
|
|
|
209
|
-
|
|
210
|
-
def test_update_agent_no_model(self):
|
|
207
|
+
|
|
208
|
+
def test_update_agent_no_model(self):
|
|
211
209
|
test_params = [ True, False ]
|
|
212
210
|
self.agent_to_update.agent_data.models[0].name = ""
|
|
213
211
|
|
|
@@ -217,9 +215,8 @@ class TestAILabUpdateAgentIntegration(TestCase):
|
|
|
217
215
|
# If the agent is not published, the API returns a warning message for invalid model name. However, the sdk mapping is not returning it.
|
|
218
216
|
if auto_publish == False:
|
|
219
217
|
updated_agent = self.__update_agent(automatic_publish=auto_publish)
|
|
220
|
-
error_msg = str(exception.exception)
|
|
221
218
|
|
|
222
|
-
self.assertTrue(
|
|
219
|
+
self.assertTrue(isinstance(updated_agent, Agent))
|
|
223
220
|
else:
|
|
224
221
|
with self.assertRaises(APIError) as exception:
|
|
225
222
|
self.__update_agent(automatic_publish=auto_publish)
|
|
File without changes
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
from unittest import TestCase
|
|
2
|
+
import unittest
|
|
3
|
+
import uuid
|
|
4
|
+
from pygeai.lab.managers import AILabManager
|
|
5
|
+
from pygeai.lab.models import (
|
|
6
|
+
AgenticProcess, KnowledgeBase, AgenticActivity, ArtifactSignal, Task,
|
|
7
|
+
UserSignal, Event, SequenceFlow, Variable
|
|
8
|
+
)
|
|
9
|
+
from pygeai.core.common.exceptions import APIResponseError, APIError
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TestAILabCreateProcessIntegration(TestCase):
|
|
13
|
+
|
|
14
|
+
def setUp(self):
|
|
15
|
+
"""
|
|
16
|
+
Set up the test environment.
|
|
17
|
+
"""
|
|
18
|
+
self.ai_lab_manager = AILabManager()
|
|
19
|
+
self.new_process = self.__load_process()
|
|
20
|
+
self.created_process: AgenticProcess = None
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def tearDown(self):
|
|
24
|
+
"""
|
|
25
|
+
Clean up after each test if necessary.
|
|
26
|
+
This can be used to delete the created process
|
|
27
|
+
"""
|
|
28
|
+
if isinstance(self.created_process, AgenticProcess):
|
|
29
|
+
self.ai_lab_manager.delete_process(self.created_process.id)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def __load_process(self):
|
|
33
|
+
"""
|
|
34
|
+
Helper to load a complete process configuration for testing.
|
|
35
|
+
"""
|
|
36
|
+
unique_key = str(uuid.uuid4())
|
|
37
|
+
process = AgenticProcess(
|
|
38
|
+
key="product_def",
|
|
39
|
+
name=f"Test Process {unique_key[:8]}",
|
|
40
|
+
description="This is a sample process",
|
|
41
|
+
kb=KnowledgeBase(name="basic-sample", artifact_type_name=["sample-artifact"]),
|
|
42
|
+
agentic_activities=[
|
|
43
|
+
AgenticActivity(key="activityOne", name="First Step", task_name="basic-task", agent_name="GoogleSummarizer2", agent_revision_id=0)
|
|
44
|
+
],
|
|
45
|
+
artifact_signals=[
|
|
46
|
+
ArtifactSignal(key="artifact.upload.1", name="artifact.upload", handling_type="C", artifact_type_name=["sample-artifact"])
|
|
47
|
+
],
|
|
48
|
+
user_signals=[
|
|
49
|
+
UserSignal(key="signal_done", name="process-completed")
|
|
50
|
+
],
|
|
51
|
+
start_event=Event(key="artifact.upload.1", name="artifact.upload"),
|
|
52
|
+
end_event=Event(key="end", name="Done"),
|
|
53
|
+
sequence_flows=[
|
|
54
|
+
SequenceFlow(key="step1", source_key="artifact.upload.1", target_key="activityOne"),
|
|
55
|
+
SequenceFlow(key="step2", source_key="activityOne", target_key="signal_done"),
|
|
56
|
+
SequenceFlow(key="stepEnd", source_key="signal_done", target_key="end")
|
|
57
|
+
]
|
|
58
|
+
)
|
|
59
|
+
return process
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def __create_process(self, process=None, automatic_publish=False):
|
|
63
|
+
"""
|
|
64
|
+
Helper to create a process using ai_lab_manager.
|
|
65
|
+
"""
|
|
66
|
+
return self.ai_lab_manager.create_process(
|
|
67
|
+
process=self.new_process if process is None else process,
|
|
68
|
+
automatic_publish=automatic_publish
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_create_process_full_data(self):
|
|
73
|
+
"""
|
|
74
|
+
Test creating a process with all available fields populated.
|
|
75
|
+
"""
|
|
76
|
+
self.created_process = self.__create_process()
|
|
77
|
+
created_process = self.created_process
|
|
78
|
+
process = self.new_process
|
|
79
|
+
|
|
80
|
+
self.assertTrue(isinstance(created_process, AgenticProcess), "Expected a created process")
|
|
81
|
+
|
|
82
|
+
# Assert the main fields of the created process
|
|
83
|
+
self.assertIsNotNone(created_process.id)
|
|
84
|
+
#self.assertEqual(created_process.key, process.key)
|
|
85
|
+
self.assertEqual(created_process.name, process.name)
|
|
86
|
+
self.assertEqual(created_process.description, process.description)
|
|
87
|
+
self.assertEqual(created_process.status, "active")
|
|
88
|
+
|
|
89
|
+
# Assert knowledge base
|
|
90
|
+
self.assertIsNotNone(created_process.kb)
|
|
91
|
+
self.assertEqual(created_process.kb.name, process.kb.name)
|
|
92
|
+
|
|
93
|
+
# Assert agentic activities
|
|
94
|
+
created_activity = created_process.agentic_activities[0]
|
|
95
|
+
original_activity = process.agentic_activities[0]
|
|
96
|
+
self.assertTrue(isinstance(created_activity, AgenticActivity))
|
|
97
|
+
self.assertEqual(created_activity.key.lower(), original_activity.key.lower())
|
|
98
|
+
self.assertEqual(created_activity.name, original_activity.name)
|
|
99
|
+
|
|
100
|
+
# Assert artifact signals
|
|
101
|
+
created_signal = created_process.artifact_signals[0]
|
|
102
|
+
original_signal = process.artifact_signals[0]
|
|
103
|
+
self.assertTrue(isinstance(created_signal, ArtifactSignal))
|
|
104
|
+
self.assertEqual(created_signal.key.lower(), original_signal.key.lower())
|
|
105
|
+
self.assertEqual(created_signal.name, original_signal.name)
|
|
106
|
+
self.assertEqual(created_signal.handling_type, original_signal.handling_type)
|
|
107
|
+
|
|
108
|
+
# Assert user signals
|
|
109
|
+
created_user_signal = created_process.user_signals[0]
|
|
110
|
+
self.assertTrue(isinstance(created_user_signal, UserSignal))
|
|
111
|
+
|
|
112
|
+
# Assert events
|
|
113
|
+
self.assertIsNotNone(created_process.start_event)
|
|
114
|
+
self.assertEqual(created_process.start_event.key.lower(), process.start_event.key.lower())
|
|
115
|
+
self.assertEqual(created_process.start_event.name, process.start_event.name)
|
|
116
|
+
|
|
117
|
+
self.assertIsNotNone(created_process.end_event)
|
|
118
|
+
self.assertEqual(created_process.end_event.key.lower(), process.end_event.key.lower())
|
|
119
|
+
self.assertEqual(created_process.end_event.name, process.end_event.name)
|
|
120
|
+
|
|
121
|
+
# Assert sequence flows
|
|
122
|
+
created_flow = created_process.sequence_flows[0]
|
|
123
|
+
original_flow = process.sequence_flows[0]
|
|
124
|
+
self.assertIsNotNone(created_process.sequence_flows)
|
|
125
|
+
self.assertEqual(len(created_process.sequence_flows), len(process.sequence_flows))
|
|
126
|
+
|
|
127
|
+
self.assertEqual(created_flow.key.lower(), original_flow.key.lower())
|
|
128
|
+
self.assertEqual(created_flow.source_key.lower(), original_flow.source_key.lower())
|
|
129
|
+
self.assertEqual(created_flow.target_key.lower(), original_flow.target_key.lower())
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def test_create_process_minimum_required_data(self):
|
|
133
|
+
"""
|
|
134
|
+
Test creating a process with only minimum required fields (key and name).
|
|
135
|
+
"""
|
|
136
|
+
unique_key = str(uuid.uuid4())
|
|
137
|
+
self.new_process = AgenticProcess(
|
|
138
|
+
key=unique_key,
|
|
139
|
+
name=f"Minimal Process {unique_key[:8]}"
|
|
140
|
+
)
|
|
141
|
+
self.created_process = self.__create_process()
|
|
142
|
+
process = self.new_process
|
|
143
|
+
|
|
144
|
+
self.assertTrue(isinstance(self.created_process, AgenticProcess), "Expected a created process")
|
|
145
|
+
self.assertIsNotNone(self.created_process.id)
|
|
146
|
+
self.assertEqual(self.created_process.name, process.name)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def test_create_process_without_key(self):
|
|
150
|
+
"""
|
|
151
|
+
Test creating a process without a key should still work (key is optional).
|
|
152
|
+
"""
|
|
153
|
+
self.new_process = AgenticProcess(
|
|
154
|
+
name=f"Process Without Key {str(uuid.uuid4())[:8]}"
|
|
155
|
+
)
|
|
156
|
+
self.created_process = self.__create_process()
|
|
157
|
+
|
|
158
|
+
self.assertTrue(isinstance(self.created_process, AgenticProcess), "Expected a created process")
|
|
159
|
+
self.assertIsNotNone(self.created_process.id)
|
|
160
|
+
self.assertEqual(self.created_process.name, self.new_process.name)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def test_create_process_no_name(self):
|
|
164
|
+
"""
|
|
165
|
+
Test creating a process without a name should raise an error.
|
|
166
|
+
"""
|
|
167
|
+
test_params = [True, False]
|
|
168
|
+
|
|
169
|
+
for auto_publish in test_params:
|
|
170
|
+
with self.subTest(input=auto_publish):
|
|
171
|
+
self.new_process.name = ""
|
|
172
|
+
with self.assertRaises(APIError) as exception:
|
|
173
|
+
self.__create_process(automatic_publish=auto_publish)
|
|
174
|
+
|
|
175
|
+
self.assertIn(
|
|
176
|
+
"Process name cannot be empty",
|
|
177
|
+
str(exception.exception),
|
|
178
|
+
f"Expected an error about empty process name with autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def test_create_process_duplicated_name(self):
|
|
183
|
+
"""
|
|
184
|
+
Test creating a process with a duplicate name should raise an error.
|
|
185
|
+
"""
|
|
186
|
+
test_params = [True, False]
|
|
187
|
+
created_process = self.__create_process()
|
|
188
|
+
|
|
189
|
+
for auto_publish in test_params:
|
|
190
|
+
with self.subTest(input=auto_publish):
|
|
191
|
+
loaded_process = self.__load_process()
|
|
192
|
+
loaded_process.name = created_process.name
|
|
193
|
+
with self.assertRaises(APIError) as exception:
|
|
194
|
+
self.__create_process(process = loaded_process, automatic_publish=auto_publish)
|
|
195
|
+
|
|
196
|
+
self.assertIn(
|
|
197
|
+
f"A process with this name already exists [name={created_process.name}].",
|
|
198
|
+
str(exception.exception),
|
|
199
|
+
f"Expected an error about duplicated process name with autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def test_create_process_invalid_name_characters(self):
|
|
204
|
+
"""
|
|
205
|
+
Test creating a process with invalid characters in name should raise a validation error.
|
|
206
|
+
"""
|
|
207
|
+
test_params = [True, False]
|
|
208
|
+
|
|
209
|
+
for auto_publish in test_params:
|
|
210
|
+
with self.subTest(input=auto_publish):
|
|
211
|
+
invalid_names = [
|
|
212
|
+
f"{str(uuid.uuid4())[:8]}:invalid",
|
|
213
|
+
f"{str(uuid.uuid4())[:8]}/invalid"
|
|
214
|
+
]
|
|
215
|
+
|
|
216
|
+
for invalid_name in invalid_names:
|
|
217
|
+
new_process = self.__load_process()
|
|
218
|
+
new_process.name = invalid_name
|
|
219
|
+
|
|
220
|
+
with self.assertRaises(APIError) as exception:
|
|
221
|
+
self.__create_process(process=new_process, automatic_publish=auto_publish)
|
|
222
|
+
|
|
223
|
+
self.assertIn(
|
|
224
|
+
"Invalid character in name",
|
|
225
|
+
str(exception.exception),
|
|
226
|
+
f"Expected an error about invalid character in process name with autopublish {'enabled' if auto_publish else 'disabled'}"
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
@unittest.skip("Skipping test for now.KB is required but is marked as optional")
|
|
231
|
+
def test_create_process_with_no_kb(self):
|
|
232
|
+
"""
|
|
233
|
+
Test creating a process with knowledge base in JSON format.
|
|
234
|
+
"""
|
|
235
|
+
unique_key = str(uuid.uuid4())
|
|
236
|
+
self.new_process.kb = None
|
|
237
|
+
self.created_process = self.__create_process()
|
|
238
|
+
|
|
239
|
+
self.assertIsNotNone(self.created_process.kb)
|
|
240
|
+
self.assertEqual(self.created_process.kb.name, "basic-sample")
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def test_create_process_with_empty_agentic_activities_array(self):
|
|
244
|
+
"""
|
|
245
|
+
Test creating a process with empty agentic activities array (to clear all activities).
|
|
246
|
+
"""
|
|
247
|
+
self.new_process.agentic_activities = []
|
|
248
|
+
self.new_process.sequence_flows = [] # Clear sequence flows as well because they depend on activities
|
|
249
|
+
self.created_process = self.__create_process()
|
|
250
|
+
|
|
251
|
+
# Empty array should be handled gracefully
|
|
252
|
+
self.assertTrue(
|
|
253
|
+
self.created_process.agentic_activities is None or
|
|
254
|
+
len(self.created_process.agentic_activities) == 0
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def test_create_process_with_multiple_artifact_signals(self):
|
|
259
|
+
"""
|
|
260
|
+
Test creating a process with multiple artifact signals.
|
|
261
|
+
"""
|
|
262
|
+
self.new_process.artifact_signals=[
|
|
263
|
+
ArtifactSignal(key="artifact.upload.1", name="artifact.upload", handling_type="C", artifact_type_name=["sample-artifact"]),
|
|
264
|
+
ArtifactSignal(key="artifact.upload.2", name="artifact.upload.second", handling_type="C", artifact_type_name=["sample-artifact"])
|
|
265
|
+
]
|
|
266
|
+
self.created_process = self.__create_process()
|
|
267
|
+
|
|
268
|
+
self.assertIsNotNone(self.created_process.artifact_signals)
|
|
269
|
+
self.assertEqual(len(self.created_process.artifact_signals), 2)
|
|
270
|
+
|
|
271
|
+
first_signal = self.created_process.artifact_signals[0]
|
|
272
|
+
second_signal = self.created_process.artifact_signals[1]
|
|
273
|
+
|
|
274
|
+
self.assertEqual(first_signal.key.lower(), "artifact.upload.1")
|
|
275
|
+
self.assertEqual(second_signal.key.lower(), "artifact.upload.2")
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def test_create_process_with_multiple_user_signals(self):
|
|
279
|
+
"""
|
|
280
|
+
Test creating a process with multiple user signals.
|
|
281
|
+
"""
|
|
282
|
+
self.new_process.user_signals=[
|
|
283
|
+
UserSignal(key="signal_done", name="process-completed"),
|
|
284
|
+
UserSignal(key="signal_cancel", name="process-cancelled")
|
|
285
|
+
]
|
|
286
|
+
self.created_process = self.__create_process()
|
|
287
|
+
|
|
288
|
+
self.assertIsNotNone(self.created_process.user_signals)
|
|
289
|
+
self.assertEqual(len(self.created_process.user_signals)-1, 2)
|
|
290
|
+
keys = [signal.key for signal in self.created_process.user_signals]
|
|
291
|
+
|
|
292
|
+
assert "SIGNAL_CANCEL" in keys
|
|
293
|
+
assert "SIGNAL_DONE" in keys
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def test_create_process_autopublish_disabled(self):
|
|
297
|
+
"""
|
|
298
|
+
Test creating a process without automatic publish (default behavior).
|
|
299
|
+
"""
|
|
300
|
+
self.created_process = self.__create_process(automatic_publish=False)
|
|
301
|
+
|
|
302
|
+
# Process should be created as draft by default
|
|
303
|
+
self.assertTrue(
|
|
304
|
+
self.created_process.is_draft is True or
|
|
305
|
+
self.created_process.is_draft is None, # API might not return this field for drafts
|
|
306
|
+
"Expected the process to be created as draft when autopublish is disabled"
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def test_create_process_autopublish_without_task(self):
|
|
311
|
+
"""
|
|
312
|
+
Test creating a process with automatic publish enabled.
|
|
313
|
+
"""
|
|
314
|
+
|
|
315
|
+
with self.assertRaises(APIError) as exception:
|
|
316
|
+
self.__create_process(automatic_publish=True)
|
|
317
|
+
|
|
318
|
+
self.assertIn(
|
|
319
|
+
"Failure on process publication",
|
|
320
|
+
str(exception.exception),
|
|
321
|
+
"Expected an error about failure on process publication"
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
self.assertIn(
|
|
325
|
+
"Task is required",
|
|
326
|
+
str(exception.exception),
|
|
327
|
+
"Expected an error about task being required"
|
|
328
|
+
)
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def test_create_process_autopublish_enabled(self):
|
|
332
|
+
"""
|
|
333
|
+
Test creating a process with automatic publish enabled.
|
|
334
|
+
"""
|
|
335
|
+
unique_key = str(uuid.uuid4())
|
|
336
|
+
task = Task(name=unique_key, description="Basic task for process", title_template="Basic Task")
|
|
337
|
+
self.ai_lab_manager.create_task(task=task, automatic_publish=True)
|
|
338
|
+
self.new_process.agentic_activities[0].task_name = unique_key
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
self.created_process = self.__create_process(automatic_publish=True)
|
|
342
|
+
self.assertTrue(
|
|
343
|
+
self.created_process.is_draft is False,
|
|
344
|
+
"Expected the process to be created no draft when autopublish is enabled"
|
|
345
|
+
)
|