pygeai 0.6.0b14__py3-none-any.whl → 0.7.0b1__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/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 +31 -71
- 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 +129 -18
- 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.0b14.dist-info → pygeai-0.7.0b1.dist-info}/METADATA +32 -7
- {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/RECORD +216 -205
- {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/WHEEL +0 -0
- {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/entry_points.txt +0 -0
- {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ from unittest.mock import patch
|
|
|
4
4
|
from pydantic import ValidationError
|
|
5
5
|
|
|
6
6
|
from pygeai.organization.limits.clients import UsageLimitClient
|
|
7
|
-
from pygeai.core.common.exceptions import InvalidAPIResponseException
|
|
7
|
+
from pygeai.core.common.exceptions import InvalidAPIResponseException
|
|
8
8
|
from pygeai.core.models import UsageLimit
|
|
9
9
|
from pygeai.organization.limits.endpoints import SET_ORGANIZATION_USAGE_LIMIT_V2, GET_ORGANIZATION_LATEST_USAGE_LIMIT_V2, \
|
|
10
10
|
GET_ALL_ORGANIZATION_USAGE_LIMITS_V2, DELETE_ORGANIZATION_USAGE_LIMIT_V2, SET_ORGANIZATION_HARD_LIMIT_V2, \
|
|
@@ -43,7 +43,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
43
43
|
"validUntil": "2025-06-28T12:00:00Z"
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
@patch("pygeai.core.services.rest.
|
|
46
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
47
47
|
def test_set_organization_usage_limit_success(self, mock_post):
|
|
48
48
|
mock_response = mock_post.return_value
|
|
49
49
|
mock_response.json.return_value = self.valid_response
|
|
@@ -58,7 +58,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
58
58
|
self.assertEqual(result, self.valid_response)
|
|
59
59
|
UsageLimit.model_validate(result)
|
|
60
60
|
|
|
61
|
-
@patch("pygeai.core.services.rest.
|
|
61
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
62
62
|
def test_set_organization_usage_limit_json_decode_error(self, mock_post):
|
|
63
63
|
mock_response = mock_post.return_value
|
|
64
64
|
mock_response.status_code = 200
|
|
@@ -74,7 +74,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
74
74
|
)
|
|
75
75
|
self.assertEqual(str(context.exception), f"Unable to set usage limit for organization '{self.organization}': Invalid JSON response")
|
|
76
76
|
|
|
77
|
-
@patch("pygeai.core.services.rest.
|
|
77
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
78
78
|
def test_set_organization_usage_limit_invalid_usage_limit(self, mock_post):
|
|
79
79
|
invalid_usage_limit = self.valid_usage_limit.copy()
|
|
80
80
|
invalid_usage_limit["renewalStatus"] = "InvalidStatus"
|
|
@@ -92,7 +92,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
92
92
|
with self.assertRaises(ValidationError):
|
|
93
93
|
UsageLimit.model_validate(invalid_usage_limit)
|
|
94
94
|
|
|
95
|
-
@patch("pygeai.core.services.rest.
|
|
95
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
96
96
|
def test_get_organization_latest_usage_limit_success(self, mock_get):
|
|
97
97
|
mock_response = mock_get.return_value
|
|
98
98
|
mock_response.json.return_value = self.valid_response
|
|
@@ -106,7 +106,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
106
106
|
self.assertEqual(result, self.valid_response)
|
|
107
107
|
UsageLimit.model_validate(result)
|
|
108
108
|
|
|
109
|
-
@patch("pygeai.core.services.rest.
|
|
109
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
110
110
|
def test_get_organization_latest_usage_limit_json_decode_error(self, mock_get):
|
|
111
111
|
mock_response = mock_get.return_value
|
|
112
112
|
mock_response.status_code = 200
|
|
@@ -121,7 +121,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
121
121
|
)
|
|
122
122
|
self.assertEqual(str(context.exception), f"Unable to get latest usage limit for organization '{self.organization}': Invalid JSON response")
|
|
123
123
|
|
|
124
|
-
@patch("pygeai.core.services.rest.
|
|
124
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
125
125
|
def test_get_all_usage_limits_from_organization_success(self, mock_get):
|
|
126
126
|
response = {"limits": [self.valid_response]}
|
|
127
127
|
mock_response = mock_get.return_value
|
|
@@ -137,7 +137,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
137
137
|
for limit in result["limits"]:
|
|
138
138
|
UsageLimit.model_validate(limit)
|
|
139
139
|
|
|
140
|
-
@patch("pygeai.core.services.rest.
|
|
140
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
141
141
|
def test_get_all_usage_limits_from_organization_json_decode_error(self, mock_get):
|
|
142
142
|
mock_response = mock_get.return_value
|
|
143
143
|
mock_response.status_code = 200
|
|
@@ -152,7 +152,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
152
152
|
)
|
|
153
153
|
self.assertEqual(str(context.exception), f"Unable to get all usage limits for organization '{self.organization}': Invalid JSON response")
|
|
154
154
|
|
|
155
|
-
@patch("pygeai.core.services.rest.
|
|
155
|
+
@patch("pygeai.core.services.rest.GEAIApiService.delete")
|
|
156
156
|
def test_delete_usage_limit_from_organization_success(self, mock_delete):
|
|
157
157
|
response = {"status": "deleted"}
|
|
158
158
|
mock_response = mock_delete.return_value
|
|
@@ -166,7 +166,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
166
166
|
)
|
|
167
167
|
self.assertEqual(result, response)
|
|
168
168
|
|
|
169
|
-
@patch("pygeai.core.services.rest.
|
|
169
|
+
@patch("pygeai.core.services.rest.GEAIApiService.delete")
|
|
170
170
|
def test_delete_usage_limit_from_organization_json_decode_error(self, mock_delete):
|
|
171
171
|
mock_response = mock_delete.return_value
|
|
172
172
|
mock_response.status_code = 200
|
|
@@ -181,7 +181,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
181
181
|
)
|
|
182
182
|
self.assertEqual(str(context.exception), f"Unable to delete usage limit with ID '{self.limit_id}' from organization '{self.organization}': Invalid JSON response")
|
|
183
183
|
|
|
184
|
-
@patch("pygeai.core.services.rest.
|
|
184
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
185
185
|
def test_set_organization_hard_limit_success(self, mock_put):
|
|
186
186
|
hard_limit = 3000.0
|
|
187
187
|
response = self.valid_response.copy()
|
|
@@ -199,7 +199,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
199
199
|
self.assertEqual(result, response)
|
|
200
200
|
UsageLimit.model_validate(result)
|
|
201
201
|
|
|
202
|
-
@patch("pygeai.core.services.rest.
|
|
202
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
203
203
|
def test_set_organization_hard_limit_json_decode_error(self, mock_put):
|
|
204
204
|
hard_limit = 3000.0
|
|
205
205
|
mock_response = mock_put.return_value
|
|
@@ -216,7 +216,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
216
216
|
)
|
|
217
217
|
self.assertEqual(str(context.exception), f"Unable to set hard limit for usage limit ID '{self.limit_id}' in organization '{self.organization}': Invalid JSON response")
|
|
218
218
|
|
|
219
|
-
@patch("pygeai.core.services.rest.
|
|
219
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
220
220
|
def test_set_organization_soft_limit_success(self, mock_put):
|
|
221
221
|
soft_limit = 1500.0
|
|
222
222
|
response = self.valid_response.copy()
|
|
@@ -234,7 +234,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
234
234
|
self.assertEqual(result, response)
|
|
235
235
|
UsageLimit.model_validate(result)
|
|
236
236
|
|
|
237
|
-
@patch("pygeai.core.services.rest.
|
|
237
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
238
238
|
def test_set_organization_soft_limit_json_decode_error(self, mock_put):
|
|
239
239
|
soft_limit = 1500.0
|
|
240
240
|
mock_response = mock_put.return_value
|
|
@@ -251,7 +251,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
251
251
|
)
|
|
252
252
|
self.assertEqual(str(context.exception), f"Unable to set soft limit for usage limit ID '{self.limit_id}' in organization '{self.organization}': Invalid JSON response")
|
|
253
253
|
|
|
254
|
-
@patch("pygeai.core.services.rest.
|
|
254
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
255
255
|
def test_set_organization_renewal_status_success(self, mock_put):
|
|
256
256
|
renewal_status = "NonRenewable"
|
|
257
257
|
response = self.valid_response.copy()
|
|
@@ -269,7 +269,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
269
269
|
self.assertEqual(result, response)
|
|
270
270
|
UsageLimit.model_validate(result)
|
|
271
271
|
|
|
272
|
-
@patch("pygeai.core.services.rest.
|
|
272
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
273
273
|
def test_set_organization_renewal_status_json_decode_error(self, mock_put):
|
|
274
274
|
renewal_status = "NonRenewable"
|
|
275
275
|
mock_response = mock_put.return_value
|
|
@@ -286,7 +286,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
286
286
|
)
|
|
287
287
|
self.assertEqual(str(context.exception), f"Unable to set renewal status for usage limit ID '{self.limit_id}' in organization '{self.organization}': Invalid JSON response")
|
|
288
288
|
|
|
289
|
-
@patch("pygeai.core.services.rest.
|
|
289
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
290
290
|
def test_set_project_usage_limit_success(self, mock_post):
|
|
291
291
|
mock_response = mock_post.return_value
|
|
292
292
|
mock_response.json.return_value = self.valid_response
|
|
@@ -301,7 +301,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
301
301
|
self.assertEqual(result, self.valid_response)
|
|
302
302
|
UsageLimit.model_validate(result)
|
|
303
303
|
|
|
304
|
-
@patch("pygeai.core.services.rest.
|
|
304
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
305
305
|
def test_set_project_usage_limit_json_decode_error(self, mock_post):
|
|
306
306
|
mock_response = mock_post.return_value
|
|
307
307
|
mock_response.status_code = 200
|
|
@@ -317,7 +317,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
317
317
|
)
|
|
318
318
|
self.assertEqual(str(context.exception), f"Unable to set usage limit for project '{self.project}' in organization '{self.organization}': Invalid JSON response")
|
|
319
319
|
|
|
320
|
-
@patch("pygeai.core.services.rest.
|
|
320
|
+
@patch("pygeai.core.services.rest.GEAIApiService.post")
|
|
321
321
|
def test_set_project_usage_limit_invalid_usage_limit(self, mock_post):
|
|
322
322
|
invalid_usage_limit = self.valid_usage_limit.copy()
|
|
323
323
|
invalid_usage_limit["subscriptionType"] = "InvalidType"
|
|
@@ -335,7 +335,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
335
335
|
with self.assertRaises(ValidationError):
|
|
336
336
|
UsageLimit.model_validate(invalid_usage_limit)
|
|
337
337
|
|
|
338
|
-
@patch("pygeai.core.services.rest.
|
|
338
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
339
339
|
def test_get_all_usage_limits_from_project_success(self, mock_get):
|
|
340
340
|
response = {"limits": [self.valid_response]}
|
|
341
341
|
mock_response = mock_get.return_value
|
|
@@ -351,7 +351,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
351
351
|
for limit in result["limits"]:
|
|
352
352
|
UsageLimit.model_validate(limit)
|
|
353
353
|
|
|
354
|
-
@patch("pygeai.core.services.rest.
|
|
354
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
355
355
|
def test_get_all_usage_limits_from_project_json_decode_error(self, mock_get):
|
|
356
356
|
mock_response = mock_get.return_value
|
|
357
357
|
mock_response.status_code = 200
|
|
@@ -366,7 +366,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
366
366
|
)
|
|
367
367
|
self.assertEqual(str(context.exception), f"Unable to get all usage limits for project '{self.project}' in organization '{self.organization}': Invalid JSON response")
|
|
368
368
|
|
|
369
|
-
@patch("pygeai.core.services.rest.
|
|
369
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
370
370
|
def test_get_latest_usage_limit_from_project_success(self, mock_get):
|
|
371
371
|
mock_response = mock_get.return_value
|
|
372
372
|
mock_response.json.return_value = self.valid_response
|
|
@@ -380,7 +380,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
380
380
|
self.assertEqual(result, self.valid_response)
|
|
381
381
|
UsageLimit.model_validate(result)
|
|
382
382
|
|
|
383
|
-
@patch("pygeai.core.services.rest.
|
|
383
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
384
384
|
def test_get_latest_usage_limit_from_project_json_decode_error(self, mock_get):
|
|
385
385
|
mock_response = mock_get.return_value
|
|
386
386
|
mock_response.status_code = 200
|
|
@@ -395,7 +395,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
395
395
|
)
|
|
396
396
|
self.assertEqual(str(context.exception), f"Unable to get latest usage limit for project '{self.project}' in organization '{self.organization}': Invalid JSON response")
|
|
397
397
|
|
|
398
|
-
@patch("pygeai.core.services.rest.
|
|
398
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
399
399
|
def test_get_active_usage_limit_from_project_success(self, mock_get):
|
|
400
400
|
mock_response = mock_get.return_value
|
|
401
401
|
mock_response.json.return_value = self.valid_response
|
|
@@ -409,7 +409,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
409
409
|
self.assertEqual(result, self.valid_response)
|
|
410
410
|
UsageLimit.model_validate(result)
|
|
411
411
|
|
|
412
|
-
@patch("pygeai.core.services.rest.
|
|
412
|
+
@patch("pygeai.core.services.rest.GEAIApiService.get")
|
|
413
413
|
def test_get_active_usage_limit_from_project_json_decode_error(self, mock_get):
|
|
414
414
|
mock_response = mock_get.return_value
|
|
415
415
|
mock_response.status_code = 200
|
|
@@ -424,7 +424,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
424
424
|
)
|
|
425
425
|
self.assertEqual(str(context.exception), f"Unable to get active usage limit for project '{self.project}' in organization '{self.organization}': Invalid JSON response")
|
|
426
426
|
|
|
427
|
-
@patch("pygeai.core.services.rest.
|
|
427
|
+
@patch("pygeai.core.services.rest.GEAIApiService.delete")
|
|
428
428
|
def test_delete_usage_limit_from_project_success(self, mock_delete):
|
|
429
429
|
response = {"status": "deleted"}
|
|
430
430
|
mock_response = mock_delete.return_value
|
|
@@ -438,7 +438,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
438
438
|
)
|
|
439
439
|
self.assertEqual(result, response)
|
|
440
440
|
|
|
441
|
-
@patch("pygeai.core.services.rest.
|
|
441
|
+
@patch("pygeai.core.services.rest.GEAIApiService.delete")
|
|
442
442
|
def test_delete_usage_limit_from_project_json_decode_error(self, mock_delete):
|
|
443
443
|
mock_response = mock_delete.return_value
|
|
444
444
|
mock_response.status_code = 200
|
|
@@ -453,7 +453,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
453
453
|
)
|
|
454
454
|
self.assertEqual(str(context.exception), f"Unable to delete usage limit with ID '{self.limit_id}' for project '{self.project}' in organization '{self.organization}': Invalid JSON response")
|
|
455
455
|
|
|
456
|
-
@patch("pygeai.core.services.rest.
|
|
456
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
457
457
|
def test_set_hard_limit_for_active_usage_limit_from_project_success(self, mock_put):
|
|
458
458
|
hard_limit = 4000.0
|
|
459
459
|
response = self.valid_response.copy()
|
|
@@ -473,7 +473,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
473
473
|
self.assertEqual(result, response)
|
|
474
474
|
UsageLimit.model_validate(result)
|
|
475
475
|
|
|
476
|
-
@patch("pygeai.core.services.rest.
|
|
476
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
477
477
|
def test_set_hard_limit_for_active_usage_limit_from_project_json_decode_error(self, mock_put):
|
|
478
478
|
hard_limit = 4000.0
|
|
479
479
|
mock_response = mock_put.return_value
|
|
@@ -492,7 +492,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
492
492
|
)
|
|
493
493
|
self.assertEqual(str(context.exception), f"Unable to set hard limit for usage limit ID '{self.limit_id}' for project '{self.project}' in organization '{self.organization}': Invalid JSON response")
|
|
494
494
|
|
|
495
|
-
@patch("pygeai.core.services.rest.
|
|
495
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
496
496
|
def test_set_soft_limit_for_active_usage_limit_from_project_success(self, mock_put):
|
|
497
497
|
soft_limit = 2000.0
|
|
498
498
|
response = self.valid_response.copy()
|
|
@@ -512,7 +512,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
512
512
|
self.assertEqual(result, response)
|
|
513
513
|
UsageLimit.model_validate(result)
|
|
514
514
|
|
|
515
|
-
@patch("pygeai.core.services.rest.
|
|
515
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
516
516
|
def test_set_soft_limit_for_active_usage_limit_from_project_json_decode_error(self, mock_put):
|
|
517
517
|
soft_limit = 2000.0
|
|
518
518
|
mock_response = mock_put.return_value
|
|
@@ -531,7 +531,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
531
531
|
)
|
|
532
532
|
self.assertEqual(str(context.exception), f"Unable to set soft limit for usage limit ID '{self.limit_id}' for project '{self.project}' in organization '{self.organization}': Invalid JSON response")
|
|
533
533
|
|
|
534
|
-
@patch("pygeai.core.services.rest.
|
|
534
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
535
535
|
def test_set_project_renewal_status_success(self, mock_put):
|
|
536
536
|
renewal_status = "Renewable"
|
|
537
537
|
response = self.valid_response.copy()
|
|
@@ -549,7 +549,7 @@ class TestUsageLimitClient(unittest.TestCase):
|
|
|
549
549
|
self.assertEqual(result, response)
|
|
550
550
|
UsageLimit.model_validate(result)
|
|
551
551
|
|
|
552
|
-
@patch("pygeai.core.services.rest.
|
|
552
|
+
@patch("pygeai.core.services.rest.GEAIApiService.put")
|
|
553
553
|
def test_set_project_renewal_status_json_decode_error(self, mock_put):
|
|
554
554
|
renewal_status = "Renewable"
|
|
555
555
|
mock_response = mock_put.return_value
|
|
@@ -2,7 +2,7 @@ import unittest
|
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
from unittest.mock import patch
|
|
4
4
|
|
|
5
|
-
from pygeai.core.base.mappers import ModelMapper
|
|
5
|
+
from pygeai.core.base.mappers import ModelMapper
|
|
6
6
|
from pygeai.core.common.exceptions import APIError
|
|
7
7
|
from pygeai.core.models import UsageLimit
|
|
8
8
|
from pygeai.organization.limits.managers import UsageLimitManager
|
|
@@ -27,8 +27,8 @@ class TestUsageLimitManager(unittest.TestCase):
|
|
|
27
27
|
subscription_type="Monthly",
|
|
28
28
|
usage_unit="Cost",
|
|
29
29
|
used_amount=0.0,
|
|
30
|
-
valid_from=
|
|
31
|
-
valid_until=
|
|
30
|
+
valid_from="2025-02-20T19:33:00",
|
|
31
|
+
valid_until="2025-03-01T00:00:00"
|
|
32
32
|
)
|
|
33
33
|
self.project_id = "1956c032-3c66-4435-acb8-6a06e52f819f"
|
|
34
34
|
self.error_response = {"errors": [{"code": "400", "message": "Invalid request"}]}
|
|
@@ -154,8 +154,8 @@ class TestUsageLimitManager(unittest.TestCase):
|
|
|
154
154
|
status=1,
|
|
155
155
|
subscription_type="Monthly",
|
|
156
156
|
usage_unit="Cost",
|
|
157
|
-
valid_from=
|
|
158
|
-
valid_until=
|
|
157
|
+
valid_from="2025-02-20T19:33:00",
|
|
158
|
+
valid_until="2025-03-01T00:00:00"
|
|
159
159
|
)
|
|
160
160
|
mock_hard.return_value = self.error_response
|
|
161
161
|
|
|
@@ -383,8 +383,8 @@ class TestUsageLimitManager(unittest.TestCase):
|
|
|
383
383
|
status=1,
|
|
384
384
|
subscription_type="Monthly",
|
|
385
385
|
usage_unit="Cost",
|
|
386
|
-
valid_from=
|
|
387
|
-
valid_until=
|
|
386
|
+
valid_from="2025-02-20T19:33:00",
|
|
387
|
+
valid_until="2025-03-01T00:00:00"
|
|
388
388
|
)
|
|
389
389
|
mock_hard.return_value = self.error_response
|
|
390
390
|
|