Skip to content

Commit d344c85

Browse files
committed
[Issue 5] Add implementations for cloud AutomationEndpoints
1 parent 180850a commit d344c85

File tree

1 file changed

+50
-14
lines changed

1 file changed

+50
-14
lines changed

zephyr/scale/cloud/endpoints/automations.py

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,76 @@ class AutomationEndpoints:
99
def __init__(self, session: ZephyrSession):
1010
self.session = session
1111

12-
def post_custom_format(self):
12+
def _post_reports(self, path, project_key, file_path, auto_create=False, test_cycle=None, **kwargs):
1313
"""
14-
Create results using Zephyr Scale's custom results format.
15-
"""
16-
raise NotImplementedError
17-
18-
def post_cucumber_format(self, project_key, file_path, auto_create=False, test_cycle=None, **kwargs):
19-
"""
20-
Create results using the Cucumber results format.
14+
Post various reports logic.
2115
16+
:param path: str with resource path
2217
:param project_key: str with project key
2318
:param file_path: str with path to .zip archive with report files
2419
:param auto_create: indicate if test cases should be created if non existent
2520
:param test_cycle: dict with test cycle description data
2621
"""
2722
params = {'projectKey': project_key}
23+
2824
if auto_create:
2925
params.update({'autoCreateTestCases': True})
3026

3127
to_files = {'testCycle': (None, dumps(test_cycle), 'application/json')} if test_cycle else None
3228

33-
return self.session.post_file('automations/executions/cucumber',
29+
return self.session.post_file(path,
3430
file_path,
3531
to_files=to_files,
3632
params=params,
3733
**kwargs)
3834

39-
def post_junit_xml_format(self):
35+
def post_custom_format(self, project_key, file_path, auto_create=False, test_cycle=None, **kwargs):
36+
"""
37+
Create results using Zephyr Scale's custom results format.
38+
39+
:param project_key: str with project key
40+
:param file_path: str with path to .zip archive with report files
41+
:param auto_create: indicate if test cases should be created if non existent
42+
:param test_cycle: dict with test cycle description data
4043
"""
41-
Create results using the JUnit XML results format. Optionally,
42-
you can send a 'testCycle' part in your form data to customize
43-
the created test cycle.
44+
return self._post_reports('automations/executions/custom',
45+
project_key=project_key,
46+
file_path=file_path,
47+
auto_create=auto_create,
48+
test_cycle=test_cycle,
49+
**kwargs)
50+
51+
def post_cucumber_format(self, project_key, file_path, auto_create=False, test_cycle=None, **kwargs):
52+
"""
53+
Create results using the Cucumber results format.
54+
55+
:param project_key: str with project key
56+
:param file_path: str with path to .zip archive with report files
57+
:param auto_create: indicate if test cases should be created if non existent
58+
:param test_cycle: dict with test cycle description data
59+
"""
60+
return self._post_reports('automations/executions/cucumber',
61+
project_key=project_key,
62+
file_path=file_path,
63+
auto_create=auto_create,
64+
test_cycle=test_cycle,
65+
**kwargs)
66+
67+
def post_junit_xml_format(self, project_key, file_path, auto_create=False, test_cycle=None, **kwargs):
68+
"""
69+
Create results using the JUnit XML results format.
70+
71+
:param project_key: str with project key
72+
:param file_path: str with path to .zip archive with report files
73+
:param auto_create: indicate if test cases should be created if non existent
74+
:param test_cycle: dict with test cycle description data
4475
"""
45-
raise NotImplementedError
76+
return self._post_reports('automations/executions/junit',
77+
project_key=project_key,
78+
file_path=file_path,
79+
auto_create=auto_create,
80+
test_cycle=test_cycle,
81+
**kwargs)
4682

4783
def get_testcases_zip(self, project_key):
4884
"""

0 commit comments

Comments
 (0)