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.
Files changed (79) hide show
  1. pygeai/__init__.py +1 -1
  2. pygeai/auth/__init__.py +0 -0
  3. pygeai/auth/clients.py +55 -0
  4. pygeai/auth/endpoints.py +2 -0
  5. pygeai/cli/__init__.py +0 -1
  6. pygeai/cli/commands/auth.py +123 -0
  7. pygeai/cli/commands/base.py +22 -1
  8. pygeai/cli/commands/docs.py +105 -0
  9. pygeai/cli/texts/help.py +157 -24
  10. pygeai/core/files/responses.py +4 -3
  11. pygeai/lab/clients.py +3 -3
  12. pygeai/lab/tools/clients.py +4 -4
  13. pygeai/tests/admin/test_clients.py +143 -0
  14. pygeai/tests/auth/__init__.py +0 -0
  15. pygeai/tests/auth/test_clients.py +105 -0
  16. pygeai/tests/cli/commands/lab/test_ai_lab.py +41 -35
  17. pygeai/tests/cli/commands/lab/test_spec.py +24 -56
  18. pygeai/tests/cli/commands/test_chat.py +21 -3
  19. pygeai/tests/cli/commands/test_evaluation.py +649 -0
  20. pygeai/tests/cli/commands/test_secrets.py +171 -0
  21. pygeai/tests/core/base/data/models.py +7 -0
  22. pygeai/tests/core/base/test_mappers.py +43 -11
  23. pygeai/tests/core/base/test_models.py +3 -1
  24. pygeai/tests/core/base/test_responses.py +53 -0
  25. pygeai/tests/core/common/test_config.py +2 -3
  26. pygeai/tests/core/files/test_mappers.py +137 -0
  27. pygeai/tests/core/plugins/__init__.py +0 -0
  28. pygeai/tests/core/plugins/test_clients.py +64 -0
  29. pygeai/tests/evaluation/__init__.py +0 -0
  30. pygeai/tests/evaluation/dataset/__init__.py +0 -0
  31. pygeai/tests/evaluation/dataset/test_clients.py +263 -0
  32. pygeai/tests/evaluation/plan/__init__.py +0 -0
  33. pygeai/tests/evaluation/plan/test_clients.py +193 -0
  34. pygeai/tests/evaluation/result/__init__.py +0 -0
  35. pygeai/tests/evaluation/result/test_clients.py +64 -0
  36. pygeai/tests/integration/assistants/rag/test_create_rag.py +1 -1
  37. pygeai/tests/integration/chat/test_generate_image.py +1 -1
  38. pygeai/tests/integration/lab/agents/test_agents_list.py +1 -1
  39. pygeai/tests/integration/lab/agents/test_create_agent.py +3 -3
  40. pygeai/tests/integration/lab/agents/test_create_sharing_link.py +1 -1
  41. pygeai/tests/integration/lab/agents/test_delete_agent.py +2 -2
  42. pygeai/tests/integration/lab/agents/test_get_agent.py +1 -1
  43. pygeai/tests/integration/lab/agents/test_publish_agent_revision.py +2 -2
  44. pygeai/tests/integration/lab/agents/test_update_agent.py +3 -3
  45. pygeai/tests/integration/lab/processes/test_create_process.py +1 -1
  46. pygeai/tests/integration/lab/processes/test_create_task.py +211 -0
  47. pygeai/tests/integration/lab/processes/test_delete_process.py +111 -0
  48. pygeai/tests/integration/lab/processes/test_get_process.py +1 -1
  49. pygeai/tests/integration/lab/processes/test_list_process_instances.py +91 -0
  50. pygeai/tests/integration/lab/processes/test_list_processes.py +138 -0
  51. pygeai/tests/integration/lab/processes/test_publish_process_revision.py +232 -0
  52. pygeai/tests/integration/lab/processes/test_update_process.py +1 -1
  53. pygeai/tests/integration/lab/reasoning_strategies/test_get_reasoning_strategy.py +1 -1
  54. pygeai/tests/integration/lab/reasoning_strategies/test_list_reasoning_strategies.py +1 -1
  55. pygeai/tests/integration/lab/reasoning_strategies/test_update_reasoning_strategy.py +1 -1
  56. pygeai/tests/integration/lab/tools/test_create_tool.py +1 -1
  57. pygeai/tests/integration/lab/tools/test_delete_tool.py +1 -1
  58. pygeai/tests/integration/lab/tools/test_get_parameter.py +1 -1
  59. pygeai/tests/integration/lab/tools/test_get_tool.py +1 -1
  60. pygeai/tests/integration/lab/tools/test_list_tools.py +1 -1
  61. pygeai/tests/integration/lab/tools/test_publish_tool_revision.py +1 -1
  62. pygeai/tests/integration/lab/tools/test_set_parameter.py +1 -1
  63. pygeai/tests/integration/lab/tools/test_update_tool.py +1 -1
  64. pygeai/tests/lab/agents/test_clients.py +17 -34
  65. pygeai/tests/lab/processes/test_clients.py +30 -93
  66. pygeai/tests/lab/processes/test_mappers.py +12 -71
  67. pygeai/tests/lab/strategies/test_clients.py +63 -63
  68. pygeai/tests/lab/test_managers.py +3 -6
  69. pygeai/tests/lab/test_models.py +9 -8
  70. pygeai/tests/lab/tools/test_clients.py +22 -45
  71. pygeai/tests/migration/test_strategies.py +16 -16
  72. pygeai/tests/organization/test_mappers.py +11 -4
  73. pygeai/tests/organization/test_responses.py +137 -0
  74. {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/METADATA +1 -1
  75. {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/RECORD +79 -53
  76. {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/WHEEL +0 -0
  77. {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/entry_points.txt +0 -0
  78. {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/licenses/LICENSE +0 -0
  79. {pygeai-0.5.0.dist-info → pygeai-0.6.0b3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,649 @@
1
+ import unittest
2
+ from unittest.mock import patch, Mock, MagicMock
3
+ import json
4
+
5
+ from pygeai.cli.commands.evaluation import (
6
+ show_help,
7
+ list_datasets,
8
+ create_dataset,
9
+ get_dataset,
10
+ update_dataset,
11
+ delete_dataset,
12
+ create_dataset_row,
13
+ list_dataset_rows,
14
+ get_dataset_row,
15
+ update_dataset_row,
16
+ delete_dataset_row,
17
+ create_dataset_row_expected_source,
18
+ list_dataset_row_expected_sources,
19
+ get_dataset_row_expected_source,
20
+ update_dataset_row_expected_source,
21
+ delete_dataset_row_expected_source,
22
+ create_dataset_row_filter_variable,
23
+ list_dataset_row_filter_variables,
24
+ get_dataset_row_filter_variable,
25
+ update_dataset_row_filter_variable,
26
+ delete_dataset_row_filter_variable,
27
+ update_dataset_rows_file,
28
+ list_evaluation_plans,
29
+ create_evaluation_plan,
30
+ get_evaluation_plan,
31
+ update_evaluation_plan,
32
+ delete_evaluation_plan,
33
+ list_evaluation_plan_system_metrics,
34
+ add_evaluation_plan_system_metric,
35
+ get_evaluation_plan_system_metric,
36
+ update_evaluation_plan_system_metric,
37
+ delete_evaluation_plan_system_metric,
38
+ list_system_metrics,
39
+ get_system_metric,
40
+ execute_evaluation_plan,
41
+ list_evaluation_results,
42
+ get_evaluation_result
43
+ )
44
+ from pygeai.core.common.exceptions import MissingRequirementException, WrongArgumentError
45
+
46
+
47
+ class TestEvaluationCommands(unittest.TestCase):
48
+ """
49
+ python -m unittest pygeai.tests.cli.commands.test_evaluation.TestEvaluationCommands
50
+ """
51
+
52
+ def test_show_help(self):
53
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
54
+ show_help()
55
+ mock_stdout.assert_called_once()
56
+
57
+ # Dataset Commands Tests
58
+ def test_list_datasets(self):
59
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.list_datasets', return_value="Datasets list") as mock_list:
60
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
61
+ list_datasets()
62
+ mock_list.assert_called_once()
63
+ mock_stdout.assert_called_once_with("Feedback detail: \nDatasets list")
64
+
65
+ def test_create_dataset_with_name(self):
66
+ option_list = [
67
+ (Mock(spec=['name'], name="dataset_name"), "Test Dataset"),
68
+ (Mock(spec=['name'], name="dataset_description"), "Test Description"),
69
+ (Mock(spec=['name'], name="dataset_type"), "T"),
70
+ (Mock(spec=['name'], name="dataset_active"), "1")
71
+ ]
72
+ for opt, _ in option_list:
73
+ opt.name = opt._mock_name
74
+
75
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.create_dataset', return_value="Created dataset") as mock_create:
76
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
77
+ create_dataset(option_list)
78
+ mock_create.assert_called_once()
79
+ mock_stdout.assert_called_once_with("New dataset detail: \nCreated dataset")
80
+
81
+ def test_create_dataset_with_file(self):
82
+ option_list = [
83
+ (Mock(spec=['name'], name="dataset_file"), "/path/to/file.json")
84
+ ]
85
+ option_list[0][0].name = "dataset_file"
86
+
87
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.create_dataset_from_file', return_value="Created from file") as mock_create:
88
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
89
+ create_dataset(option_list)
90
+ mock_create.assert_called_once_with(file_path="/path/to/file.json")
91
+ mock_stdout.assert_called_once_with("New dataset detail: \nCreated from file")
92
+
93
+ def test_create_dataset_with_rows_dict(self):
94
+ row_data = {
95
+ "dataSetRowExpectedAnswer": "answer",
96
+ "dataSetRowContextDocument": "context",
97
+ "dataSetRowInput": "input"
98
+ }
99
+ option_list = [
100
+ (Mock(spec=['name'], name="dataset_name"), "Test Dataset"),
101
+ (Mock(spec=['name'], name="row"), json.dumps(row_data))
102
+ ]
103
+ for opt, _ in option_list:
104
+ opt.name = opt._mock_name
105
+
106
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.create_dataset', return_value="Created dataset") as mock_create:
107
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
108
+ create_dataset(option_list)
109
+ mock_create.assert_called_once()
110
+
111
+ def test_create_dataset_with_rows_list(self):
112
+ row_data = [
113
+ {
114
+ "dataSetRowExpectedAnswer": "answer",
115
+ "dataSetRowContextDocument": "context",
116
+ "dataSetRowInput": "input"
117
+ }
118
+ ]
119
+ option_list = [
120
+ (Mock(spec=['name'], name="dataset_name"), "Test Dataset"),
121
+ (Mock(spec=['name'], name="row"), json.dumps(row_data))
122
+ ]
123
+ for opt, _ in option_list:
124
+ opt.name = opt._mock_name
125
+
126
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.create_dataset', return_value="Created dataset") as mock_create:
127
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
128
+ create_dataset(option_list)
129
+ mock_create.assert_called_once()
130
+
131
+ def test_create_dataset_invalid_row_json(self):
132
+ option_list = [
133
+ (Mock(spec=['name'], name="dataset_name"), "Test Dataset"),
134
+ (Mock(spec=['name'], name="row"), "invalid json")
135
+ ]
136
+ for opt, _ in option_list:
137
+ opt.name = opt._mock_name
138
+
139
+ with self.assertRaises(WrongArgumentError):
140
+ create_dataset(option_list)
141
+
142
+ def test_create_dataset_missing_name(self):
143
+ option_list = []
144
+ with self.assertRaises(MissingRequirementException) as context:
145
+ create_dataset(option_list)
146
+ self.assertEqual(str(context.exception), "Cannot create dataset without specifying dataset name")
147
+
148
+ def test_get_dataset_success(self):
149
+ option_list = [
150
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123")
151
+ ]
152
+ option_list[0][0].name = "dataset_id"
153
+
154
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.get_dataset', return_value="Dataset detail") as mock_get:
155
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
156
+ get_dataset(option_list)
157
+ mock_get.assert_called_once_with(dataset_id="dataset-123")
158
+ mock_stdout.assert_called_once_with("Dataset detail: \nDataset detail")
159
+
160
+ def test_get_dataset_missing_id(self):
161
+ option_list = []
162
+ with self.assertRaises(MissingRequirementException) as context:
163
+ get_dataset(option_list)
164
+ self.assertEqual(str(context.exception), "Cannot retrieve dataset without specifying id.")
165
+
166
+ def test_update_dataset_success(self):
167
+ option_list = [
168
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123"),
169
+ (Mock(spec=['name'], name="dataset_name"), "Updated Name"),
170
+ (Mock(spec=['name'], name="dataset_description"), "Updated Description")
171
+ ]
172
+ for opt, _ in option_list:
173
+ opt.name = opt._mock_name
174
+
175
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.update_dataset', return_value="Updated dataset") as mock_update:
176
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
177
+ update_dataset(option_list)
178
+ mock_update.assert_called_once()
179
+ mock_stdout.assert_called_once_with("Updated dataset detail: \nUpdated dataset")
180
+
181
+ def test_update_dataset_missing_id(self):
182
+ option_list = [
183
+ (Mock(spec=['name'], name="dataset_name"), "Updated Name")
184
+ ]
185
+ option_list[0][0].name = "dataset_name"
186
+
187
+ with self.assertRaises(MissingRequirementException) as context:
188
+ update_dataset(option_list)
189
+ self.assertEqual(str(context.exception), "Cannot update dataset without specifying id.")
190
+
191
+ def test_delete_dataset_success(self):
192
+ option_list = [
193
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123")
194
+ ]
195
+ option_list[0][0].name = "dataset_id"
196
+
197
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.delete_dataset', return_value="Deleted") as mock_delete:
198
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
199
+ delete_dataset(option_list)
200
+ mock_delete.assert_called_once_with(dataset_id="dataset-123")
201
+ mock_stdout.assert_called_once_with("Deleted dataset detail: \nDeleted")
202
+
203
+ def test_delete_dataset_missing_id(self):
204
+ option_list = []
205
+ with self.assertRaises(MissingRequirementException) as context:
206
+ delete_dataset(option_list)
207
+ self.assertEqual(str(context.exception), "Cannot delete dataset without specifying id.")
208
+
209
+ # Dataset Row Commands Tests
210
+ def test_create_dataset_row_success(self):
211
+ row_data = {
212
+ "dataSetRowExpectedAnswer": "answer",
213
+ "dataSetRowContextDocument": "context",
214
+ "dataSetRowInput": "input"
215
+ }
216
+ option_list = [
217
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123"),
218
+ (Mock(spec=['name'], name="row"), json.dumps(row_data))
219
+ ]
220
+ for opt, _ in option_list:
221
+ opt.name = opt._mock_name
222
+
223
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.create_dataset_row', return_value="Created row") as mock_create:
224
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
225
+ create_dataset_row(option_list)
226
+ mock_create.assert_called_once()
227
+
228
+ def test_create_dataset_row_invalid_json(self):
229
+ option_list = [
230
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123"),
231
+ (Mock(spec=['name'], name="row"), "invalid json")
232
+ ]
233
+ for opt, _ in option_list:
234
+ opt.name = opt._mock_name
235
+
236
+ with self.assertRaises(WrongArgumentError):
237
+ create_dataset_row(option_list)
238
+
239
+ def test_create_dataset_row_missing_id(self):
240
+ row_data = {"dataSetRowExpectedAnswer": "answer"}
241
+ option_list = [
242
+ (Mock(spec=['name'], name="row"), json.dumps(row_data))
243
+ ]
244
+ option_list[0][0].name = "row"
245
+
246
+ with self.assertRaises(MissingRequirementException) as context:
247
+ create_dataset_row(option_list)
248
+ self.assertEqual(str(context.exception), "Cannot create dataset row without specifying id.")
249
+
250
+ def test_list_dataset_rows_success(self):
251
+ option_list = [
252
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123")
253
+ ]
254
+ option_list[0][0].name = "dataset_id"
255
+
256
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.list_dataset_rows', return_value="Rows list") as mock_list:
257
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
258
+ list_dataset_rows(option_list)
259
+ mock_list.assert_called_once_with(dataset_id="dataset-123")
260
+
261
+ def test_list_dataset_rows_missing_id(self):
262
+ option_list = []
263
+ with self.assertRaises(MissingRequirementException) as context:
264
+ list_dataset_rows(option_list)
265
+ self.assertEqual(str(context.exception), "Cannot list dataset rows without specifying id.")
266
+
267
+ def test_get_dataset_row_success(self):
268
+ option_list = [
269
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123"),
270
+ (Mock(spec=['name'], name="row_id"), "row-456")
271
+ ]
272
+ for opt, _ in option_list:
273
+ opt.name = opt._mock_name
274
+
275
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.get_dataset_row', return_value="Row detail") as mock_get:
276
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
277
+ get_dataset_row(option_list)
278
+ mock_get.assert_called_once_with(dataset_id="dataset-123", dataset_row_id="row-456")
279
+
280
+ def test_get_dataset_row_missing_dataset_id(self):
281
+ option_list = [
282
+ (Mock(spec=['name'], name="row_id"), "row-456")
283
+ ]
284
+ option_list[0][0].name = "row_id"
285
+
286
+ with self.assertRaises(MissingRequirementException) as context:
287
+ get_dataset_row(option_list)
288
+ self.assertEqual(str(context.exception), "Cannot get dataset row without specifying id of dataset and row.")
289
+
290
+ def test_get_dataset_row_missing_row_id(self):
291
+ option_list = [
292
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123")
293
+ ]
294
+ option_list[0][0].name = "dataset_id"
295
+
296
+ with self.assertRaises(MissingRequirementException) as context:
297
+ get_dataset_row(option_list)
298
+ self.assertEqual(str(context.exception), "Cannot get dataset row without specifying id of dataset and row.")
299
+
300
+ def test_update_dataset_row_success(self):
301
+ row_data = {
302
+ "dataSetRowExpectedAnswer": "updated answer",
303
+ "dataSetRowContextDocument": "updated context",
304
+ "dataSetRowInput": "updated input"
305
+ }
306
+ option_list = [
307
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123"),
308
+ (Mock(spec=['name'], name="row_id"), "row-456"),
309
+ (Mock(spec=['name'], name="row"), json.dumps(row_data))
310
+ ]
311
+ for opt, _ in option_list:
312
+ opt.name = opt._mock_name
313
+
314
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.update_dataset_row', return_value="Updated row") as mock_update:
315
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
316
+ update_dataset_row(option_list)
317
+ mock_update.assert_called_once()
318
+
319
+ def test_update_dataset_row_missing_dataset_id(self):
320
+ option_list = [
321
+ (Mock(spec=['name'], name="row_id"), "row-456")
322
+ ]
323
+ option_list[0][0].name = "row_id"
324
+
325
+ with self.assertRaises(MissingRequirementException) as context:
326
+ update_dataset_row(option_list)
327
+ self.assertEqual(str(context.exception), "Cannot update dataset row without specifying id of dataset and row.")
328
+
329
+ def test_delete_dataset_row_success(self):
330
+ option_list = [
331
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123"),
332
+ (Mock(spec=['name'], name="row_id"), "row-456")
333
+ ]
334
+ for opt, _ in option_list:
335
+ opt.name = opt._mock_name
336
+
337
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.delete_dataset_row', return_value="Deleted row") as mock_delete:
338
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
339
+ delete_dataset_row(option_list)
340
+ mock_delete.assert_called_once_with(dataset_id="dataset-123", dataset_row_id="row-456")
341
+
342
+ def test_delete_dataset_row_missing_dataset_id(self):
343
+ option_list = [
344
+ (Mock(spec=['name'], name="row_id"), "row-456")
345
+ ]
346
+ option_list[0][0].name = "row_id"
347
+
348
+ with self.assertRaises(MissingRequirementException) as context:
349
+ delete_dataset_row(option_list)
350
+ self.assertEqual(str(context.exception), "Cannot delete dataset row without specifying id of dataset and row.")
351
+
352
+ # Dataset Row Expected Source Tests
353
+ def test_create_dataset_row_expected_source(self):
354
+ source_data = {
355
+ "dataSetExpectedSourceName": "source1",
356
+ "dataSetExpectedSourceValue": "value1"
357
+ }
358
+ option_list = [
359
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123"),
360
+ (Mock(spec=['name'], name="row_id"), "row-456"),
361
+ (Mock(spec=['name'], name="expected_source"), json.dumps(source_data))
362
+ ]
363
+ for opt, _ in option_list:
364
+ opt.name = opt._mock_name
365
+
366
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.create_expected_source', return_value="Created source") as mock_create:
367
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
368
+ create_dataset_row_expected_source(option_list)
369
+ mock_create.assert_called_once()
370
+
371
+ def test_list_dataset_row_expected_sources(self):
372
+ option_list = [
373
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123"),
374
+ (Mock(spec=['name'], name="row_id"), "row-456")
375
+ ]
376
+ for opt, _ in option_list:
377
+ opt.name = opt._mock_name
378
+
379
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.list_expected_sources', return_value="Sources list") as mock_list:
380
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
381
+ list_dataset_row_expected_sources(option_list)
382
+ mock_list.assert_called_once()
383
+
384
+ def test_update_dataset_rows_file(self):
385
+ option_list = [
386
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123"),
387
+ (Mock(spec=['name'], name="dataset_rows_file"), "/path/to/rows.json")
388
+ ]
389
+ for opt, _ in option_list:
390
+ opt.name = opt._mock_name
391
+
392
+ with patch('pygeai.evaluation.dataset.clients.EvaluationDatasetClient.upload_dataset_rows_file', return_value="Updated rows") as mock_update:
393
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
394
+ update_dataset_rows_file(option_list)
395
+ mock_update.assert_called_once()
396
+
397
+ # Evaluation Plan Commands Tests
398
+ def test_list_evaluation_plans(self):
399
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.list_evaluation_plans', return_value="Plans list") as mock_list:
400
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
401
+ list_evaluation_plans()
402
+ mock_list.assert_called_once()
403
+
404
+ def test_create_evaluation_plan_success(self):
405
+ option_list = [
406
+ (Mock(spec=['name'], name="evaluation_plan_name"), "Test Plan"),
407
+ (Mock(spec=['name'], name="evaluation_plan_type"), "Test Description"),
408
+ (Mock(spec=['name'], name="evaluation_plan_assistant_id"), "1")
409
+ ]
410
+ for opt, _ in option_list:
411
+ opt.name = opt._mock_name
412
+
413
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.create_evaluation_plan', return_value="Created plan") as mock_create:
414
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
415
+ create_evaluation_plan(option_list)
416
+ mock_create.assert_called_once()
417
+
418
+ def test_create_evaluation_plan_missing_name(self):
419
+ option_list = []
420
+ with self.assertRaises(MissingRequirementException) as context:
421
+ create_evaluation_plan(option_list)
422
+ self.assertEqual(str(context.exception), "Cannot create evaluation plan without specifying evaluation plan name and type")
423
+
424
+ def test_get_evaluation_plan_success(self):
425
+ option_list = [
426
+ (Mock(spec=['name'], name="evaluation_plan_id"), "plan-123")
427
+ ]
428
+ option_list[0][0].name = "evaluation_plan_id"
429
+
430
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.get_evaluation_plan', return_value="Plan detail") as mock_get:
431
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
432
+ get_evaluation_plan(option_list)
433
+ mock_get.assert_called_once_with(evaluation_plan_id="plan-123")
434
+
435
+ def test_get_evaluation_plan_missing_id(self):
436
+ option_list = []
437
+ with self.assertRaises(MissingRequirementException) as context:
438
+ get_evaluation_plan(option_list)
439
+ self.assertEqual(str(context.exception), "Cannot get evaluation plan without specifying id")
440
+
441
+ def test_update_evaluation_plan_success(self):
442
+ option_list = [
443
+ (Mock(spec=['name'], name="evaluation_plan_id"), "plan-123"),
444
+ (Mock(spec=['name'], name="evaluation_plan_name"), "Updated Plan")
445
+ ]
446
+ for opt, _ in option_list:
447
+ opt.name = opt._mock_name
448
+
449
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.update_evaluation_plan', return_value="Updated plan") as mock_update:
450
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
451
+ update_evaluation_plan(option_list)
452
+ mock_update.assert_called_once()
453
+
454
+ def test_update_evaluation_plan_missing_id(self):
455
+ option_list = [
456
+ (Mock(spec=['name'], name="evaluation_plan_name"), "Updated Plan")
457
+ ]
458
+ option_list[0][0].name = "plan_name"
459
+
460
+ with self.assertRaises(MissingRequirementException) as context:
461
+ update_evaluation_plan(option_list)
462
+ self.assertEqual(str(context.exception), "Cannot update evaluation plan without specifying id")
463
+
464
+ def test_delete_evaluation_plan_success(self):
465
+ option_list = [
466
+ (Mock(spec=['name'], name="evaluation_plan_id"), "plan-123")
467
+ ]
468
+ option_list[0][0].name = "evaluation_plan_id"
469
+
470
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.delete_evaluation_plan', return_value="Deleted") as mock_delete:
471
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
472
+ delete_evaluation_plan(option_list)
473
+ mock_delete.assert_called_once_with(evaluation_plan_id="plan-123")
474
+
475
+ def test_delete_evaluation_plan_missing_id(self):
476
+ option_list = []
477
+ with self.assertRaises(MissingRequirementException) as context:
478
+ delete_evaluation_plan(option_list)
479
+ self.assertEqual(str(context.exception), "Cannot delete evaluation plan without specifying id")
480
+
481
+ # Evaluation Plan System Metric Tests
482
+ def test_list_evaluation_plan_system_metrics_success(self):
483
+ option_list = [
484
+ (Mock(spec=['name'], name="evaluation_plan_id"), "plan-123")
485
+ ]
486
+ option_list[0][0].name = "evaluation_plan_id"
487
+
488
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.list_evaluation_plan_system_metrics', return_value="Metrics list") as mock_list:
489
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
490
+ list_evaluation_plan_system_metrics(option_list)
491
+ mock_list.assert_called_once_with(evaluation_plan_id="plan-123")
492
+
493
+ def test_list_evaluation_plan_system_metrics_missing_id(self):
494
+ option_list = []
495
+ with self.assertRaises(MissingRequirementException) as context:
496
+ list_evaluation_plan_system_metrics(option_list)
497
+ self.assertEqual(str(context.exception), "Cannot list evaluation plan's system metrics without specifying id")
498
+
499
+ def test_add_evaluation_plan_system_metric_success(self):
500
+ option_list = [
501
+ (Mock(spec=['name'], name="evaluation_plan_id"), "plan-123"),
502
+ (Mock(spec=['name'], name="system_metric_id"), "metric-456"),
503
+ (Mock(spec=['name'], name="system_metric_weight"), "1.0")
504
+ ]
505
+ for opt, _ in option_list:
506
+ opt.name = opt._mock_name
507
+
508
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.add_evaluation_plan_system_metric', return_value="Added metric") as mock_add:
509
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
510
+ add_evaluation_plan_system_metric(option_list)
511
+ mock_add.assert_called_once()
512
+
513
+ def test_add_evaluation_plan_system_metric_missing_plan_id(self):
514
+ option_list = [
515
+ (Mock(spec=['name'], name="system_metric_id"), "metric-456")
516
+ ]
517
+ option_list[0][0].name = "system_metric_id"
518
+
519
+ with self.assertRaises(MissingRequirementException) as context:
520
+ add_evaluation_plan_system_metric(option_list)
521
+ self.assertEqual(str(context.exception), "Cannot add evaluation plan's system metrics without specifying id")
522
+
523
+ def test_get_evaluation_plan_system_metric_success(self):
524
+ option_list = [
525
+ (Mock(spec=['name'], name="evaluation_plan_id"), "plan-123"),
526
+ (Mock(spec=['name'], name="system_metric_id"), "metric-456")
527
+ ]
528
+ for opt, _ in option_list:
529
+ opt.name = opt._mock_name
530
+
531
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.get_evaluation_plan_system_metric', return_value="Metric detail") as mock_get:
532
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
533
+ get_evaluation_plan_system_metric(option_list)
534
+ mock_get.assert_called_once_with(evaluation_plan_id="plan-123", system_metric_id="metric-456")
535
+
536
+ def test_get_evaluation_plan_system_metric_missing_plan_id(self):
537
+ option_list = [
538
+ (Mock(spec=['name'], name="system_metric_id"), "metric-456")
539
+ ]
540
+ option_list[0][0].name = "system_metric_id"
541
+
542
+ with self.assertRaises(MissingRequirementException) as context:
543
+ get_evaluation_plan_system_metric(option_list)
544
+ self.assertEqual(str(context.exception), "Cannot retrieve evaluation plan's system metric without specifying both ids")
545
+
546
+ def test_update_evaluation_plan_system_metric_success(self):
547
+ option_list = [
548
+ (Mock(spec=['name'], name="evaluation_plan_id"), "plan-123"),
549
+ (Mock(spec=['name'], name="system_metric_id"), "metric-456"),
550
+ (Mock(spec=['name'], name="system_metric_weight"), "2.0")
551
+ ]
552
+ for opt, _ in option_list:
553
+ opt.name = opt._mock_name
554
+
555
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.update_evaluation_plan_system_metric', return_value="Updated metric") as mock_update:
556
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
557
+ update_evaluation_plan_system_metric(option_list)
558
+ mock_update.assert_called_once()
559
+
560
+ def test_delete_evaluation_plan_system_metric_success(self):
561
+ option_list = [
562
+ (Mock(spec=['name'], name="evaluation_plan_id"), "plan-123"),
563
+ (Mock(spec=['name'], name="system_metric_id"), "metric-456")
564
+ ]
565
+ for opt, _ in option_list:
566
+ opt.name = opt._mock_name
567
+
568
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.delete_evaluation_plan_system_metric', return_value="Deleted metric") as mock_delete:
569
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
570
+ delete_evaluation_plan_system_metric(option_list)
571
+ mock_delete.assert_called_once_with(evaluation_plan_id="plan-123", system_metric_id="metric-456")
572
+
573
+ # System Metrics Tests
574
+ def test_list_system_metrics(self):
575
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.list_system_metrics', return_value="System metrics list") as mock_list:
576
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
577
+ list_system_metrics()
578
+ mock_list.assert_called_once()
579
+
580
+ def test_get_system_metric_success(self):
581
+ option_list = [
582
+ (Mock(spec=['name'], name="system_metric_id"), "metric-456")
583
+ ]
584
+ option_list[0][0].name = "system_metric_id"
585
+
586
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.get_system_metric', return_value="System metric detail") as mock_get:
587
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
588
+ get_system_metric(option_list)
589
+ mock_get.assert_called_once_with(system_metric_id="metric-456")
590
+
591
+ def test_get_system_metric_missing_id(self):
592
+ option_list = []
593
+ with self.assertRaises(MissingRequirementException) as context:
594
+ get_system_metric(option_list)
595
+ self.assertEqual(str(context.exception), "Cannot retrieve system metric without specifying id")
596
+
597
+ # Execution Tests
598
+ def test_execute_evaluation_plan_success(self):
599
+ option_list = [
600
+ (Mock(spec=['name'], name="evaluation_plan_id"), "plan-123"),
601
+ (Mock(spec=['name'], name="dataset_id"), "dataset-123"),
602
+ (Mock(spec=['name'], name="assistant_id"), "assistant-123")
603
+ ]
604
+ for opt, _ in option_list:
605
+ opt.name = opt._mock_name
606
+
607
+ with patch('pygeai.evaluation.plan.clients.EvaluationPlanClient.execute_evaluation_plan', return_value="Execution result") as mock_execute:
608
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
609
+ execute_evaluation_plan(option_list)
610
+ mock_execute.assert_called_once()
611
+
612
+ def test_execute_evaluation_plan_missing_plan_id(self):
613
+ option_list = []
614
+ with self.assertRaises(MissingRequirementException) as context:
615
+ execute_evaluation_plan(option_list)
616
+ self.assertEqual(str(context.exception), "Cannot execute evaluation plan without specifying id")
617
+
618
+ # Result Tests
619
+ def test_list_evaluation_results(self):
620
+ option_list = [
621
+ (Mock(spec=['name'], name="evaluation_plan_id"), "plan-123")
622
+ ]
623
+ option_list[0][0].name = "evaluation_plan_id"
624
+
625
+ with patch('pygeai.evaluation.result.clients.EvaluationResultClient.list_evaluation_results', return_value="Results list") as mock_list:
626
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
627
+ list_evaluation_results(option_list)
628
+ mock_list.assert_called_once()
629
+
630
+ def test_get_evaluation_result_success(self):
631
+ option_list = [
632
+ (Mock(spec=['name'], name="evaluation_result_id"), "result-123")
633
+ ]
634
+ option_list[0][0].name = "evaluation_result_id"
635
+
636
+ with patch('pygeai.evaluation.result.clients.EvaluationResultClient.get_evaluation_result', return_value="Result detail") as mock_get:
637
+ with patch('pygeai.core.utils.console.Console.write_stdout') as mock_stdout:
638
+ get_evaluation_result(option_list)
639
+ mock_get.assert_called_once_with(evaluation_result_id="result-123")
640
+
641
+ def test_get_evaluation_result_missing_id(self):
642
+ option_list = []
643
+ with self.assertRaises(MissingRequirementException) as context:
644
+ get_evaluation_result(option_list)
645
+ self.assertEqual(str(context.exception), "Cannot get evaluation results without specifying id")
646
+
647
+
648
+ if __name__ == '__main__':
649
+ unittest.main()