alita-sdk 0.3.188__py3-none-any.whl → 0.3.190__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,53 @@ 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
+ plan_id: str
120
+ suite_id: str
121
+ title: str
122
+ description: str
123
+ test_steps: str
124
+ test_steps_format: str
125
+ {'}'}
126
+ ...
127
+ ]
128
+ Where:
129
+ plan_id - ID of the test plan to which test cases are to be added;
130
+ suite_id - ID of the test suite to which test cases are to be added
131
+ title - Test case title;
132
+ description - Test case description;
133
+ test_steps - {test_steps_description}
134
+ test_steps_format - Format of provided test steps. Possible values: json, xml
135
+ """))
136
+ )
137
+
99
138
  TestCaseCreateModel = create_model(
100
139
  "TestCaseCreateModel",
101
140
  plan_id=(int, Field(description="ID of the test plan to which test cases are to be added")),
102
141
  suite_id=(int, Field(description="ID of the test suite to which test cases are to be added")),
103
142
  title=(str, Field(description="Test case title")),
104
143
  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"},...]""")),
144
+ test_steps=(str, Field(description=test_steps_description)),
145
+ test_steps_format=(Optional[str], Field(description="Format of provided test steps. Possible values: json, xml", default='json'))
106
146
  )
107
147
 
108
148
  TestCaseGetModel = create_model(
@@ -217,31 +257,38 @@ class TestPlanApiWrapper(BaseToolApiWrapper):
217
257
  logger.error(f"Error adding test case: {e}")
218
258
  return ToolException(f"Error adding test case: {e}")
219
259
 
220
- def create_test_case(self, plan_id: int, suite_id: int, title: str, description: str, test_steps: str):
260
+ def create_test_cases(self, create_test_cases_parameters):
261
+ """Creates new test cases in specified suite in Azure DevOps."""
262
+ test_cases = json.loads(create_test_cases_parameters)
263
+ return [self.create_test_case(
264
+ plan_id=test_case['plan_id'],
265
+ suite_id=test_case['suite_id'],
266
+ title=test_case['title'],
267
+ description=test_case['description'],
268
+ test_steps=test_case['test_steps'],
269
+ test_steps_format=test_case['test_steps_format']) for test_case in test_cases]
270
+
271
+
272
+ def create_test_case(self, plan_id: int, suite_id: int, title: str, description: str, test_steps: str, test_steps_format: str = 'json'):
221
273
  """Creates a new test case in specified suite in Azure DevOps."""
222
274
  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))
275
+ if test_steps_format == 'json':
276
+ steps_xml = self.get_test_steps_xml(json.loads(test_steps))
277
+ elif test_steps_format == 'xml':
278
+ steps_xml = self.convert_steps_tag_to_ado_steps(test_steps)
279
+ else:
280
+ return ToolException("Unknown test steps format: " + test_steps_format)
281
+ work_item_json = self.build_ado_test_case(title, description, steps_xml)
224
282
  created_work_item_id = work_item_wrapper.create_work_item(work_item_json=json.dumps(work_item_json), wi_type="Test Case")['id']
225
283
  return self.add_test_case([{"work_item":{"id":created_work_item_id}}], plan_id, suite_id)
226
284
 
227
- def build_ado_test_case(self, title, description, steps):
285
+ def build_ado_test_case(self, title, description, steps_xml):
228
286
  """
229
287
  :param title: test title
230
288
  :param description: test description
231
- :param steps: steps [(action, expected result), ...]
289
+ :param steps_xml: steps xml
232
290
  :return: JSON with ADO fields
233
291
  """
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
292
  return {
246
293
  "fields": {
247
294
  "System.Title": title,
@@ -250,6 +297,42 @@ class TestPlanApiWrapper(BaseToolApiWrapper):
250
297
  }
251
298
  }
252
299
 
300
+ def get_test_steps_xml(self, steps: dict):
301
+ steps_elem = ET.Element("steps")
302
+ for step in steps:
303
+ step_number = step.get("stepNumber", 1)
304
+ action = step.get("action", "")
305
+ expected_result = step.get("expectedResult", "")
306
+ steps_elem.append(self.build_step_element(step_number, action, expected_result))
307
+ return ET.tostring(steps_elem, encoding="unicode")
308
+
309
+ def convert_steps_tag_to_ado_steps(self, input_xml: str) -> str:
310
+ """
311
+ Converts input XML from format:
312
+ <Steps><Step><Action>...</Action><ExpectedResult>...</ExpectedResult></Step></Steps>
313
+ to Azure DevOps test case format:
314
+ <steps><step id="1" type="Action">...</step>...</steps>
315
+ """
316
+ input_root = ET.fromstring(input_xml)
317
+ steps_elem = ET.Element("steps")
318
+ for step_node in input_root.findall("Step"):
319
+ step_number = step_node.findtext("StepNumber", default="1")
320
+ action = step_node.findtext("Action", default="")
321
+ expected_result = step_node.findtext("ExpectedResult", default="")
322
+ steps_elem.append(self.build_step_element(step_number, action, expected_result))
323
+ return ET.tostring(steps_elem, encoding="unicode")
324
+
325
+ def build_step_element(self, step_number: str, action: str, expected_result: str) -> ET.Element:
326
+ """
327
+ Creates an individual <step> element for Azure DevOps.
328
+ """
329
+ step_elem = ET.Element("step", id=str(step_number), type="Action")
330
+ action_elem = ET.SubElement(step_elem, "parameterizedString", isformatted="true")
331
+ action_elem.text = action or ""
332
+ expected_elem = ET.SubElement(step_elem, "parameterizedString", isformatted="true")
333
+ expected_elem.text = expected_result or ""
334
+ return step_elem
335
+
253
336
  def get_test_case(self, plan_id: int, suite_id: int, test_case_id: str):
254
337
  """Get a test case from a suite in Azure DevOps."""
255
338
  try:
@@ -323,6 +406,12 @@ class TestPlanApiWrapper(BaseToolApiWrapper):
323
406
  "args_schema": TestCaseCreateModel,
324
407
  "ref": self.create_test_case,
325
408
  },
409
+ {
410
+ "name": "create_test_cases",
411
+ "description": self.create_test_cases.__doc__,
412
+ "args_schema": TestCasesCreateModel,
413
+ "ref": self.create_test_cases,
414
+ },
326
415
  {
327
416
  "name": "get_test_case",
328
417
  "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.190
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=p1Mptd_1J6bmkyrvf2M-FB79s8THzEesBlfgaOnRXb8,18152
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.190.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
301
+ alita_sdk-0.3.190.dist-info/METADATA,sha256=MN0y_jtRArmOL_VWmdUm7HG9aOJyI7tSmrtaS6x0fsQ,18804
302
+ alita_sdk-0.3.190.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
303
+ alita_sdk-0.3.190.dist-info/top_level.txt,sha256=0vJYy5p_jK6AwVb1aqXr7Kgqgk3WDtQ6t5C-XI9zkmg,10
304
+ alita_sdk-0.3.190.dist-info/RECORD,,