1+ from json import dumps
2+
13from ...zephyr_session import ZephyrSession
24
35
@@ -7,25 +9,99 @@ class AutomationEndpoints:
79 def __init__ (self , session : ZephyrSession ):
810 self .session = session
911
10- def post_custom_format (self ):
12+ def _post_reports (self ,
13+ path ,
14+ project_key ,
15+ file_path ,
16+ auto_create = False ,
17+ test_cycle = None ,
18+ ** kwargs ):
19+ """
20+ Post various reports logic.
21+
22+ :param path: str with resource path
23+ :param project_key: str with project key
24+ :param file_path: str with path to .zip archive with report files
25+ :param auto_create: indicate if test cases should be created if non existent
26+ :param test_cycle: dict with test cycle description data
27+ """
28+ params = {'projectKey' : project_key }
29+ to_files = None
30+
31+ if auto_create :
32+ params .update ({'autoCreateTestCases' : True })
33+
34+ if test_cycle :
35+ to_files = {'testCycle' : (None , dumps (test_cycle ), 'application/json' )}
36+
37+ return self .session .post_file (path ,
38+ file_path ,
39+ to_files = to_files ,
40+ params = params ,
41+ ** kwargs )
42+
43+ def post_custom_format (self ,
44+ project_key ,
45+ file_path ,
46+ auto_create = False ,
47+ test_cycle = None ,
48+ ** kwargs ):
1149 """
1250 Create results using Zephyr Scale's custom results format.
51+
52+ :param project_key: str with project key
53+ :param file_path: str with path to .zip archive with report files
54+ :param auto_create: indicate if test cases should be created if non existent
55+ :param test_cycle: dict with test cycle description data
1356 """
14- raise NotImplementedError
57+ return self ._post_reports ('automations/executions/custom' ,
58+ project_key = project_key ,
59+ file_path = file_path ,
60+ auto_create = auto_create ,
61+ test_cycle = test_cycle ,
62+ ** kwargs )
1563
16- def post_cucumber_format (self ):
64+ def post_cucumber_format (self ,
65+ project_key ,
66+ file_path ,
67+ auto_create = False ,
68+ test_cycle = None ,
69+ ** kwargs ):
1770 """
1871 Create results using the Cucumber results format.
72+
73+ :param project_key: str with project key
74+ :param file_path: str with path to .zip archive with report files
75+ :param auto_create: indicate if test cases should be created if non existent
76+ :param test_cycle: dict with test cycle description data
1977 """
20- raise NotImplementedError
78+ return self ._post_reports ('automations/executions/cucumber' ,
79+ project_key = project_key ,
80+ file_path = file_path ,
81+ auto_create = auto_create ,
82+ test_cycle = test_cycle ,
83+ ** kwargs )
2184
22- def post_junit_xml_format (self ):
85+ def post_junit_xml_format (self ,
86+ project_key ,
87+ file_path ,
88+ auto_create = False ,
89+ test_cycle = None ,
90+ ** kwargs ):
2391 """
24- Create results using the JUnit XML results format. Optionally,
25- you can send a 'testCycle' part in your form data to customize
26- the created test cycle.
92+ Create results using the JUnit XML results format.
93+
94+ :param project_key: str with project key
95+ :param file_path: str with path to .zip archive with report files
96+ :param auto_create: indicate if test cases should be created if non existent
97+ :param test_cycle: dict with test cycle description data
2798 """
28- raise NotImplementedError
99+ return self ._post_reports ('automations/executions/junit' ,
100+ project_key = project_key ,
101+ file_path = file_path ,
102+ auto_create = auto_create ,
103+ test_cycle = test_cycle ,
104+ ** kwargs )
29105
30106 def get_testcases_zip (self , project_key ):
31107 """
0 commit comments