alita-sdk 0.3.188__py3-none-any.whl → 0.3.189__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.
@@ -35,9 +35,10 @@ def create_llm_input_with_messages(
35
35
  input_messages = []
36
36
 
37
37
  # Add system message from prompt if available
38
- if prompt and prompt.get('template'):
38
+ if prompt:
39
39
  try:
40
- system_content = prompt['template'].format(**params) if params else prompt['template']
40
+ # Format the system message using the prompt template or value and params
41
+ system_content = (prompt['template'] if 'template' in prompt else prompt['value']).format(**params) if params else prompt['template']
41
42
  input_messages.append(SystemMessage(content=system_content))
42
43
  except KeyError as e:
43
44
  error_msg = f"KeyError in prompt formatting: {e}. Available params: {list(params.keys())}"
@@ -96,13 +96,55 @@ TestCaseAddModel = create_model(
96
96
  suite_id=(int, Field(description="ID of the test suite to which test cases are to be added"))
97
97
  )
98
98
 
99
+
100
+ test_steps_description = """Json or XML array string with test steps.
101
+ Json example: [{"stepNumber": 1, "action": "Some action", "expectedResult": "Some expectation"},...]
102
+ XML example:
103
+ <Steps>
104
+ <Step>
105
+ <StepNumber>1</StepNumber>
106
+ <Action>Some action</Action>
107
+ <ExpectedResult>Some expectation</ExpectedResult>
108
+ </Step>
109
+ ...
110
+ </Steps>
111
+ """
112
+
113
+ TestCasesCreateModel = create_model(
114
+ "TestCasesCreateModel",
115
+ create_test_cases_parameters=(str, Field(description=f"""Json array where each object is separate test case to be created.
116
+ Input format:
117
+ [
118
+ {'{'}
119
+ project: str
120
+ plan_id: str
121
+ suite_id: str
122
+ title: str
123
+ description: str
124
+ test_steps: str
125
+ test_steps_format: str
126
+ {'}'}
127
+ ...
128
+ ]
129
+ Where:
130
+ project - Project ID or project name;
131
+ plan_id - ID of the test plan to which test cases are to be added;
132
+ suite_id - ID of the test suite to which test cases are to be added
133
+ title - Test case title;
134
+ description - Test case description;
135
+ test_steps - {test_steps_description}
136
+ test_steps_format - Format of provided test steps. Possible values: json, xml
137
+ """))
138
+ )
139
+
99
140
  TestCaseCreateModel = create_model(
100
141
  "TestCaseCreateModel",
101
142
  plan_id=(int, Field(description="ID of the test plan to which test cases are to be added")),
102
143
  suite_id=(int, Field(description="ID of the test suite to which test cases are to be added")),
103
144
  title=(str, Field(description="Test case title")),
104
145
  description=(str, Field(description="Test case description")),
105
- test_steps=(str, Field(description="""Json array with test steps. Example: [{"action": "Some action", "expectedResult": "Some expectation"},...]""")),
146
+ test_steps=(str, Field(description=test_steps_description)),
147
+ test_steps_format=(Optional[str], Field(description="Format of provided test steps. Possible values: json, xml", default='json'))
106
148
  )
107
149
 
108
150
  TestCaseGetModel = create_model(
@@ -217,31 +259,39 @@ class TestPlanApiWrapper(BaseToolApiWrapper):
217
259
  logger.error(f"Error adding test case: {e}")
218
260
  return ToolException(f"Error adding test case: {e}")
219
261
 
220
- def create_test_case(self, plan_id: int, suite_id: int, title: str, description: str, test_steps: str):
262
+ def create_test_cases(self, create_test_cases_parameters):
263
+ """Creates new test cases in specified suite in Azure DevOps."""
264
+ test_cases = json.loads(create_test_cases_parameters)
265
+ return [self.create_test_case(
266
+ project=test_case['project'],
267
+ plan_id=test_case['plan_id'],
268
+ suite_id=test_case['suite_id'],
269
+ title=test_case['title'],
270
+ description=test_case['description'],
271
+ test_steps=test_case['test_steps'],
272
+ test_steps_format=test_case['test_steps_format']) for test_case in test_cases]
273
+
274
+
275
+ def create_test_case(self, plan_id: int, suite_id: int, title: str, description: str, test_steps: str, test_steps_format: str = 'json'):
221
276
  """Creates a new test case in specified suite in Azure DevOps."""
222
277
  work_item_wrapper = AzureDevOpsApiWrapper(organization_url=self.organization_url, token=self.token.get_secret_value(), project=self.project)
223
- work_item_json = self.build_ado_test_case(title, description, json.loads(test_steps))
278
+ if test_steps_format == 'json':
279
+ steps_xml = self.get_test_steps_xml(json.loads(test_steps))
280
+ elif test_steps_format == 'xml':
281
+ steps_xml = self.convert_steps_tag_to_ado_steps(test_steps)
282
+ else:
283
+ return ToolException("Unknown test steps format: " + test_steps_format)
284
+ work_item_json = self.build_ado_test_case(title, description, steps_xml)
224
285
  created_work_item_id = work_item_wrapper.create_work_item(work_item_json=json.dumps(work_item_json), wi_type="Test Case")['id']
225
286
  return self.add_test_case([{"work_item":{"id":created_work_item_id}}], plan_id, suite_id)
226
287
 
227
- def build_ado_test_case(self, title, description, steps):
288
+ def build_ado_test_case(self, title, description, steps_xml):
228
289
  """
229
290
  :param title: test title
230
291
  :param description: test description
231
- :param steps: steps [(action, expected result), ...]
292
+ :param steps: steps xml
232
293
  :return: JSON with ADO fields
233
294
  """
234
- steps_elem = ET.Element("steps")
235
-
236
- for idx, step in enumerate(steps, start=1):
237
- step_elem = ET.SubElement(steps_elem, "step", id=str(idx), type="Action")
238
- action_elem = ET.SubElement(step_elem, "parameterizedString", isformatted="true")
239
- action_elem.text = step["action"]
240
- expected_elem = ET.SubElement(step_elem, "parameterizedString", isformatted="true")
241
- expected_elem.text = step["expectedResult"]
242
-
243
- steps_xml = ET.tostring(steps_elem, encoding="unicode")
244
-
245
295
  return {
246
296
  "fields": {
247
297
  "System.Title": title,
@@ -250,6 +300,42 @@ class TestPlanApiWrapper(BaseToolApiWrapper):
250
300
  }
251
301
  }
252
302
 
303
+ def get_test_steps_xml(self, steps: dict):
304
+ steps_elem = ET.Element("steps")
305
+ for step in steps:
306
+ step_number = step.get("stepNumber", 1)
307
+ action = step.get("action", "")
308
+ expected_result = step.get("expectedResult", "")
309
+ steps_elem.append(self.build_step_element(step_number, action, expected_result))
310
+ return ET.tostring(steps_elem, encoding="unicode")
311
+
312
+ def convert_steps_tag_to_ado_steps(self, input_xml: str) -> str:
313
+ """
314
+ Converts input XML from format:
315
+ <Steps><Step><Action>...</Action><ExpectedResult>...</ExpectedResult></Step></Steps>
316
+ to Azure DevOps test case format:
317
+ <steps><step id="1" type="Action">...</step>...</steps>
318
+ """
319
+ input_root = ET.fromstring(input_xml)
320
+ steps_elem = ET.Element("steps")
321
+ for step_node in input_root.findall("Step"):
322
+ step_number = step_node.findtext("StepNumber", default="1")
323
+ action = step_node.findtext("Action", default="")
324
+ expected_result = step_node.findtext("ExpectedResult", default="")
325
+ steps_elem.append(self.build_step_element(step_number, action, expected_result))
326
+ return ET.tostring(steps_elem, encoding="unicode")
327
+
328
+ def build_step_element(self, step_number: str, action: str, expected_result: str) -> ET.Element:
329
+ """
330
+ Creates an individual <step> element for Azure DevOps.
331
+ """
332
+ step_elem = ET.Element("step", id=str(step_number), type="Action")
333
+ action_elem = ET.SubElement(step_elem, "parameterizedString", isformatted="true")
334
+ action_elem.text = action or ""
335
+ expected_elem = ET.SubElement(step_elem, "parameterizedString", isformatted="true")
336
+ expected_elem.text = expected_result or ""
337
+ return step_elem
338
+
253
339
  def get_test_case(self, plan_id: int, suite_id: int, test_case_id: str):
254
340
  """Get a test case from a suite in Azure DevOps."""
255
341
  try:
@@ -323,6 +409,12 @@ class TestPlanApiWrapper(BaseToolApiWrapper):
323
409
  "args_schema": TestCaseCreateModel,
324
410
  "ref": self.create_test_case,
325
411
  },
412
+ {
413
+ "name": "create_test_cases",
414
+ "description": self.create_test_cases.__doc__,
415
+ "args_schema": TestCasesCreateModel,
416
+ "ref": self.create_test_cases,
417
+ },
326
418
  {
327
419
  "name": "get_test_case",
328
420
  "description": self.get_test_case.__doc__,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alita_sdk
3
- Version: 0.3.188
3
+ Version: 0.3.189
4
4
  Summary: SDK for building langchain agents using resources from Alita
5
5
  Author-email: Artem Rozumenko <artyom.rozumenko@gmail.com>, Mikalai Biazruchka <mikalai_biazruchka@epam.com>, Roman Mitusov <roman_mitusov@epam.com>, Ivan Krakhmaliuk <lifedjik@gmail.com>, Artem Dubrovskiy <ad13box@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -81,7 +81,7 @@ alita_sdk/runtime/tools/datasource.py,sha256=pvbaSfI-ThQQnjHG-QhYNSTYRnZB0rYtZFp
81
81
  alita_sdk/runtime/tools/echo.py,sha256=spw9eCweXzixJqHnZofHE1yWiSUa04L4VKycf3KCEaM,486
82
82
  alita_sdk/runtime/tools/function.py,sha256=ZFpd7TGwIawze2e7BHlKwP0NHwNw42wwrmmnXyJQJhk,2600
83
83
  alita_sdk/runtime/tools/indexer_tool.py,sha256=whSLPevB4WD6dhh2JDXEivDmTvbjiMV1MrPl9cz5eLA,4375
84
- alita_sdk/runtime/tools/llm.py,sha256=qy3-TYhV-rvT4PzSNMw0vvJTMmgZI9nAmvW4NNhL5QU,14937
84
+ alita_sdk/runtime/tools/llm.py,sha256=OD-oFxg_axZitb_zL-O1hAT5UhBvqiw0XOMy5EPva-o,15043
85
85
  alita_sdk/runtime/tools/loop.py,sha256=uds0WhZvwMxDVFI6MZHrcmMle637cQfBNg682iLxoJA,8335
86
86
  alita_sdk/runtime/tools/loop_output.py,sha256=U4hO9PCQgWlXwOq6jdmCGbegtAxGAPXObSxZQ3z38uk,8069
87
87
  alita_sdk/runtime/tools/mcp_server_tool.py,sha256=eI8QUt497xblwF4Zhbvi8wCg17yh2yoWjcw_AIzHwGE,2819
@@ -105,7 +105,7 @@ alita_sdk/tools/ado/utils.py,sha256=PTCludvaQmPLakF2EbCGy66Mro4-rjDtavVP-xcB2Wc,
105
105
  alita_sdk/tools/ado/repos/__init__.py,sha256=bzVSEAPwBoH4sY3cNj5_FNXIC3yY8lkofaonNKhwhRk,6286
106
106
  alita_sdk/tools/ado/repos/repos_wrapper.py,sha256=_OWKAls7VFfFtEPTwqj_DxE1MSvpC0ivxdTIULEz3Tk,48206
107
107
  alita_sdk/tools/ado/test_plan/__init__.py,sha256=K-jhCT7D7bxXbiat3GCP_qDVg_ipcBlnh9r3JhmAubM,4408
108
- alita_sdk/tools/ado/test_plan/test_plan_wrapper.py,sha256=uUaxXPxz2NiwzNEXtR31pPGe77f-p0sj7VL-zZnfTqI,14529
108
+ alita_sdk/tools/ado/test_plan/test_plan_wrapper.py,sha256=J7A2etGa3MTcYpdDhejSM0pLSiXF5xSO74sGihynHCw,18257
109
109
  alita_sdk/tools/ado/wiki/__init__.py,sha256=5QlISwHbfBl_0he7miv6WbK-Kc2mS-t46d9UFJZqY8A,4308
110
110
  alita_sdk/tools/ado/wiki/ado_wrapper.py,sha256=l4bc2QoKSUXg9UqNcx0ylv7YL9JPPQd35Ti5MXyEgC4,12690
111
111
  alita_sdk/tools/ado/work_item/__init__.py,sha256=vZTTLh-dcefOPCkNOehcmXiPLZrD6n-tg8fKoKWrgJE,4411
@@ -297,8 +297,8 @@ alita_sdk/tools/zephyr_scale/api_wrapper.py,sha256=UHVQUVqcBc3SZvDfO78HSuBzwAsRw
297
297
  alita_sdk/tools/zephyr_squad/__init__.py,sha256=rq4jOb3lRW2GXvAguk4H1KinO5f-zpygzhBJf-E1Ucw,2773
298
298
  alita_sdk/tools/zephyr_squad/api_wrapper.py,sha256=iOMxyE7vOc_LwFB_nBMiSFXkNtvbptA4i-BrTlo7M0A,5854
299
299
  alita_sdk/tools/zephyr_squad/zephyr_squad_cloud_client.py,sha256=IYUJoMFOMA70knLhLtAnuGoy3OK80RuqeQZ710oyIxE,3631
300
- alita_sdk-0.3.188.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
301
- alita_sdk-0.3.188.dist-info/METADATA,sha256=i1rCgEanmynBNJEsIjDaLlBJhYVq7pp242X8TZJXHMA,18804
302
- alita_sdk-0.3.188.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
303
- alita_sdk-0.3.188.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
304
- alita_sdk-0.3.188.dist-info/RECORD,,
300
+ alita_sdk-0.3.189.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
301
+ alita_sdk-0.3.189.dist-info/METADATA,sha256=5os2tSZvdoNwZboxU24vXSEqoAHqkZRAendJI1yYJFY,18804
302
+ alita_sdk-0.3.189.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
303
+ alita_sdk-0.3.189.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
304
+ alita_sdk-0.3.189.dist-info/RECORD,,