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.
Files changed (216) hide show
  1. pygeai/__init__.py +1 -2
  2. pygeai/_docs/source/content/api_reference/project.rst +392 -0
  3. pygeai/_docs/source/content/authentication.rst +130 -1
  4. pygeai/_docs/source/content/debugger.rst +327 -157
  5. pygeai/_docs/source/pygeai.core.common.rst +8 -0
  6. pygeai/_docs/source/pygeai.tests.auth.rst +56 -0
  7. pygeai/_docs/source/pygeai.tests.cli.rst +8 -0
  8. pygeai/admin/clients.py +1 -3
  9. pygeai/analytics/clients.py +1 -1
  10. pygeai/assistant/clients.py +2 -7
  11. pygeai/assistant/data/clients.py +0 -8
  12. pygeai/assistant/data_analyst/clients.py +0 -2
  13. pygeai/assistant/managers.py +1 -1
  14. pygeai/assistant/rag/clients.py +0 -2
  15. pygeai/assistant/rag/mappers.py +9 -11
  16. pygeai/auth/clients.py +26 -7
  17. pygeai/auth/endpoints.py +2 -1
  18. pygeai/chat/clients.py +2 -2
  19. pygeai/chat/managers.py +1 -1
  20. pygeai/cli/commands/admin.py +13 -25
  21. pygeai/cli/commands/analytics.py +31 -71
  22. pygeai/cli/commands/assistant.py +84 -138
  23. pygeai/cli/commands/auth.py +23 -46
  24. pygeai/cli/commands/base.py +0 -1
  25. pygeai/cli/commands/chat.py +218 -209
  26. pygeai/cli/commands/common.py +5 -5
  27. pygeai/cli/commands/configuration.py +79 -29
  28. pygeai/cli/commands/docs.py +3 -4
  29. pygeai/cli/commands/embeddings.py +13 -19
  30. pygeai/cli/commands/evaluation.py +133 -344
  31. pygeai/cli/commands/feedback.py +7 -15
  32. pygeai/cli/commands/files.py +26 -53
  33. pygeai/cli/commands/gam.py +28 -69
  34. pygeai/cli/commands/lab/ai_lab.py +96 -142
  35. pygeai/cli/commands/lab/common.py +1 -1
  36. pygeai/cli/commands/lab/spec.py +12 -32
  37. pygeai/cli/commands/llm.py +9 -18
  38. pygeai/cli/commands/migrate.py +43 -99
  39. pygeai/cli/commands/organization.py +223 -196
  40. pygeai/cli/commands/rag.py +35 -58
  41. pygeai/cli/commands/rerank.py +21 -25
  42. pygeai/cli/commands/secrets.py +39 -67
  43. pygeai/cli/commands/usage_limits.py +50 -136
  44. pygeai/cli/commands/validators.py +1 -1
  45. pygeai/cli/geai.py +32 -3
  46. pygeai/cli/geai_proxy.py +6 -2
  47. pygeai/cli/install_man.py +1 -1
  48. pygeai/cli/parsers.py +1 -1
  49. pygeai/core/base/clients.py +90 -21
  50. pygeai/core/base/mappers.py +39 -55
  51. pygeai/core/base/session.py +129 -18
  52. pygeai/core/common/config.py +50 -13
  53. pygeai/core/common/constants.py +8 -0
  54. pygeai/core/common/exceptions.py +6 -0
  55. pygeai/core/embeddings/clients.py +0 -1
  56. pygeai/core/embeddings/managers.py +0 -1
  57. pygeai/core/feedback/clients.py +0 -2
  58. pygeai/core/feedback/models.py +1 -1
  59. pygeai/core/files/clients.py +0 -3
  60. pygeai/core/files/managers.py +1 -1
  61. pygeai/core/files/mappers.py +4 -5
  62. pygeai/core/llm/clients.py +0 -1
  63. pygeai/core/models.py +4 -4
  64. pygeai/core/plugins/clients.py +0 -3
  65. pygeai/core/plugins/models.py +2 -2
  66. pygeai/core/rerank/clients.py +0 -2
  67. pygeai/core/secrets/clients.py +0 -2
  68. pygeai/core/services/rest.py +80 -14
  69. pygeai/core/singleton.py +24 -0
  70. pygeai/dbg/__init__.py +2 -2
  71. pygeai/dbg/debugger.py +276 -38
  72. pygeai/evaluation/clients.py +2 -4
  73. pygeai/evaluation/dataset/clients.py +0 -1
  74. pygeai/evaluation/plan/clients.py +0 -2
  75. pygeai/evaluation/result/clients.py +0 -2
  76. pygeai/gam/clients.py +1 -3
  77. pygeai/health/clients.py +1 -3
  78. pygeai/lab/clients.py +0 -1
  79. pygeai/lab/managers.py +0 -1
  80. pygeai/lab/models.py +0 -1
  81. pygeai/lab/strategies/clients.py +1 -2
  82. pygeai/lab/tools/clients.py +2 -2
  83. pygeai/lab/tools/mappers.py +1 -1
  84. pygeai/migration/strategies.py +5 -6
  85. pygeai/migration/tools.py +1 -1
  86. pygeai/organization/clients.py +118 -12
  87. pygeai/organization/endpoints.py +1 -0
  88. pygeai/organization/limits/clients.py +4 -6
  89. pygeai/organization/limits/managers.py +1 -4
  90. pygeai/organization/managers.py +2 -2
  91. pygeai/proxy/config.py +1 -0
  92. pygeai/proxy/managers.py +6 -5
  93. pygeai/tests/admin/test_clients.py +11 -11
  94. pygeai/tests/assistants/rag/test_clients.py +1 -1
  95. pygeai/tests/assistants/rag/test_models.py +1 -2
  96. pygeai/tests/assistants/test_clients.py +1 -1
  97. pygeai/tests/assistants/test_managers.py +1 -3
  98. pygeai/tests/auth/test_cli_configuration.py +252 -0
  99. pygeai/tests/auth/test_client_initialization.py +411 -0
  100. pygeai/tests/auth/test_clients.py +29 -27
  101. pygeai/tests/auth/test_config_manager.py +305 -0
  102. pygeai/tests/auth/test_header_injection.py +294 -0
  103. pygeai/tests/auth/test_oauth.py +3 -1
  104. pygeai/tests/auth/test_session_logging.py +119 -0
  105. pygeai/tests/auth/test_session_validation.py +408 -0
  106. pygeai/tests/auth/test_singleton_reset.py +201 -0
  107. pygeai/tests/chat/test_clients.py +1 -1
  108. pygeai/tests/chat/test_iris.py +1 -1
  109. pygeai/tests/chat/test_ui.py +0 -2
  110. pygeai/tests/cli/commands/lab/test_ai_lab.py +1 -3
  111. pygeai/tests/cli/commands/lab/test_common.py +0 -1
  112. pygeai/tests/cli/commands/test_chat.py +1 -1
  113. pygeai/tests/cli/commands/test_common.py +0 -1
  114. pygeai/tests/cli/commands/test_embeddings.py +2 -2
  115. pygeai/tests/cli/commands/test_evaluation.py +1 -9
  116. pygeai/tests/cli/commands/test_llm.py +1 -1
  117. pygeai/tests/cli/commands/test_migrate.py +1 -1
  118. pygeai/tests/cli/commands/test_rerank.py +0 -1
  119. pygeai/tests/cli/commands/test_secrets.py +1 -1
  120. pygeai/tests/cli/commands/test_show_help.py +0 -1
  121. pygeai/tests/cli/commands/test_validators.py +0 -1
  122. pygeai/tests/cli/test_credentials_flag.py +312 -0
  123. pygeai/tests/cli/test_error_handler.py +0 -1
  124. pygeai/tests/core/base/test_mappers.py +2 -2
  125. pygeai/tests/core/base/test_models.py +4 -4
  126. pygeai/tests/core/common/test_config.py +2 -7
  127. pygeai/tests/core/common/test_decorators.py +0 -1
  128. pygeai/tests/core/embeddings/test_managers.py +1 -1
  129. pygeai/tests/core/feedback/test_clients.py +2 -2
  130. pygeai/tests/core/files/test_clients.py +6 -6
  131. pygeai/tests/core/files/test_models.py +0 -1
  132. pygeai/tests/core/files/test_responses.py +0 -1
  133. pygeai/tests/core/llm/test_clients.py +1 -1
  134. pygeai/tests/core/plugins/test_clients.py +4 -4
  135. pygeai/tests/core/rerank/test_mappers.py +1 -3
  136. pygeai/tests/core/secrets/test_clients.py +2 -3
  137. pygeai/tests/core/services/test_rest.py +10 -10
  138. pygeai/tests/core/utils/test_console.py +0 -1
  139. pygeai/tests/dbg/test_debugger.py +95 -8
  140. pygeai/tests/evaluation/dataset/test_clients.py +24 -27
  141. pygeai/tests/evaluation/plan/test_clients.py +16 -18
  142. pygeai/tests/evaluation/result/test_clients.py +4 -5
  143. pygeai/tests/health/test_clients.py +2 -2
  144. pygeai/tests/integration/lab/agents/test_create_agent.py +1 -3
  145. pygeai/tests/integration/lab/agents/test_get_agent.py +1 -1
  146. pygeai/tests/integration/lab/processes/test_create_process.py +2 -2
  147. pygeai/tests/integration/lab/processes/test_create_task.py +2 -3
  148. pygeai/tests/integration/lab/processes/test_delete_process.py +0 -1
  149. pygeai/tests/integration/lab/processes/test_get_process.py +2 -4
  150. pygeai/tests/integration/lab/processes/test_list_process_instances.py +1 -3
  151. pygeai/tests/integration/lab/processes/test_update_process.py +3 -9
  152. pygeai/tests/integration/lab/reasoning_strategies/test_update_reasoning_strategy.py +1 -2
  153. pygeai/tests/integration/lab/tools/test_delete_tool.py +1 -1
  154. pygeai/tests/integration/lab/tools/test_list_tools.py +1 -1
  155. pygeai/tests/integration/lab/tools/test_update_tool.py +1 -1
  156. pygeai/tests/lab/agents/test_clients.py +17 -17
  157. pygeai/tests/lab/processes/test_clients.py +67 -67
  158. pygeai/tests/lab/processes/test_mappers.py +23 -23
  159. pygeai/tests/lab/spec/test_loader.py +0 -2
  160. pygeai/tests/lab/spec/test_parsers.py +1 -2
  161. pygeai/tests/lab/strategies/test_clients.py +10 -10
  162. pygeai/tests/lab/test_managers.py +3 -5
  163. pygeai/tests/lab/test_mappers.py +1 -4
  164. pygeai/tests/lab/tools/test_clients.py +21 -21
  165. pygeai/tests/lab/tools/test_mappers.py +0 -1
  166. pygeai/tests/organization/limits/test_clients.py +33 -33
  167. pygeai/tests/organization/limits/test_managers.py +7 -7
  168. pygeai/tests/organization/test_clients.py +78 -60
  169. pygeai/tests/proxy/test_clients.py +1 -1
  170. pygeai/tests/proxy/test_integration.py +1 -4
  171. pygeai/tests/proxy/test_managers.py +1 -2
  172. pygeai/tests/proxy/test_servers.py +1 -2
  173. pygeai/tests/snippets/assistants/rag/delete_rag_assistant.py +0 -1
  174. pygeai/tests/snippets/assistants/rag/get_documents.py +0 -1
  175. pygeai/tests/snippets/assistants/rag/get_rag_assistant_data.py +0 -1
  176. pygeai/tests/snippets/chat/get_request_status.py +0 -1
  177. pygeai/tests/snippets/dbg/file_debugging.py +72 -0
  178. pygeai/tests/snippets/dbg/module_debugging.py +60 -0
  179. pygeai/tests/snippets/embeddings/cohere_example.py +2 -2
  180. pygeai/tests/snippets/embeddings/openai_base64_example.py +1 -1
  181. pygeai/tests/snippets/evaluation/dataset/complete_workflow_example.py +8 -8
  182. pygeai/tests/snippets/evaluation/plan/complete_workflow_example.py +5 -5
  183. pygeai/tests/snippets/evaluation/result/complete_workflow_example.py +3 -3
  184. pygeai/tests/snippets/lab/agentic_flow_example_1.py +1 -1
  185. pygeai/tests/snippets/lab/agentic_flow_example_2.py +3 -4
  186. pygeai/tests/snippets/lab/agents/create_agent_with_permissions.py +2 -2
  187. pygeai/tests/snippets/lab/agents/delete_agent.py +1 -2
  188. pygeai/tests/snippets/lab/agents/get_agent.py +1 -1
  189. pygeai/tests/snippets/lab/agents/get_agent_with_new_fields.py +10 -10
  190. pygeai/tests/snippets/lab/agents/get_sharing_link.py +0 -1
  191. pygeai/tests/snippets/lab/agents/list_agents.py +1 -1
  192. pygeai/tests/snippets/lab/agents/publish_agent_revision.py +0 -1
  193. pygeai/tests/snippets/lab/agents/update_agent_properties.py +1 -1
  194. pygeai/tests/snippets/lab/crud_ui.py +3 -5
  195. pygeai/tests/snippets/lab/processes/kbs/get_kb.py +0 -1
  196. pygeai/tests/snippets/lab/processes/kbs/list_kbs.py +0 -1
  197. pygeai/tests/snippets/lab/processes/list_processes.py +1 -1
  198. pygeai/tests/snippets/lab/samples/summarize_files.py +0 -3
  199. pygeai/tests/snippets/lab/strategies/get_reasoning_strategy.py +0 -1
  200. pygeai/tests/snippets/lab/strategies/list_reasoning_strategies.py +1 -1
  201. pygeai/tests/snippets/lab/tools/get_tool.py +1 -1
  202. pygeai/tests/snippets/lab/tools/publish_tool_revision.py +0 -1
  203. pygeai/tests/snippets/lab/tools/set_parameters.py +1 -2
  204. pygeai/tests/snippets/lab/use_cases/c_code_fixer_agent_flow.py +2 -3
  205. pygeai/tests/snippets/lab/use_cases/file_summarizer_example_2.py +1 -1
  206. pygeai/tests/snippets/lab/use_cases/update_cli_expert.py +0 -1
  207. pygeai/tests/snippets/lab/use_cases/update_lab_expert.py +0 -1
  208. pygeai/tests/snippets/lab/use_cases/update_web_designer.py +0 -1
  209. pygeai/tests/snippets/lab/use_cases/update_web_reader.py +0 -1
  210. pygeai/tests/snippets/migrate/orchestrator_examples.py +1 -1
  211. {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/METADATA +32 -7
  212. {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/RECORD +216 -205
  213. {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/WHEEL +0 -0
  214. {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/entry_points.txt +0 -0
  215. {pygeai-0.6.0b14.dist-info → pygeai-0.7.0b1.dist-info}/licenses/LICENSE +0 -0
  216. {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, APIError
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.ApiService.post")
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.ApiService.post")
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.ApiService.post")
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.ApiService.get")
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.ApiService.get")
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.ApiService.get")
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.ApiService.get")
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.ApiService.delete")
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.ApiService.delete")
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.ApiService.put")
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.ApiService.put")
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.ApiService.put")
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.ApiService.put")
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.ApiService.put")
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.ApiService.put")
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.ApiService.post")
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.ApiService.post")
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.ApiService.post")
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.ApiService.get")
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.ApiService.get")
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.ApiService.get")
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.ApiService.get")
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.ApiService.get")
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.ApiService.get")
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.ApiService.delete")
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.ApiService.delete")
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.ApiService.put")
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.ApiService.put")
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.ApiService.put")
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.ApiService.put")
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.ApiService.put")
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.ApiService.put")
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, ErrorMapper
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=datetime(2025, 2, 20, 19, 33, 0),
31
- valid_until=datetime(2025, 3, 1, 0, 0, 0)
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=datetime(2025, 2, 20, 19, 33, 0),
158
- valid_until=datetime(2025, 3, 1, 0, 0, 0)
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=datetime(2025, 2, 20, 19, 33, 0),
387
- valid_until=datetime(2025, 3, 1, 0, 0, 0)
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