Skip to content

Commit b99bcbc

Browse files
author
Gonchik Tsymzhitov
committed
Xray: review the code and set mutable method defaukt variable into immutable
1 parent eb7ad58 commit b99bcbc

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.16.1
1+
1.17.0

atlassian/jira.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,7 @@ def get_project_issue_security_scheme(self, project_id_or_key, only_levels=False
17501750
reason=e)
17511751
elif e.response.status_code == 403:
17521752
raise ApiPermissionError(
1753-
"Returned if the project is visible for calling user, but the user doesn't have administrative permissions",
1753+
"User doesn't have administrative permissions",
17541754
reason=e)
17551755
elif e.response.status_code == 404:
17561756
raise ApiNotFoundError(

atlassian/xray.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def create_test_step(self, test_key, step, data, result):
122122
:param test_key: Test key (eg. 'TEST-001').
123123
:param step: Test Step name (eg. 'Example step').
124124
:param data: Test Step data (eg. 'Example data').
125-
:param results: Test Step results (eg. 'Example results').
125+
:param result: Test Step results (eg. 'Example results').
126126
:return:
127127
"""
128128
create = {'step': step, 'data': data, 'result': result, 'attachments': []}
@@ -137,7 +137,7 @@ def update_test_step(self, test_key, test_step_id, step, data, result):
137137
:param test_step_id: ID of the test step.
138138
:param step: Test Step name (eg. 'Example step').
139139
:param data: Test Step data (eg. 'Example data').
140-
:param results: Test Step results (eg. 'Example results').
140+
:param result: Test Step results (eg. 'Example results').
141141
:return:
142142
"""
143143
update = {'step': step, 'data': data, 'result': result, 'attachments': {'add': [], 'remove': []}}
@@ -164,14 +164,18 @@ def get_tests_with_precondition(self, precondition_key):
164164
url = 'rest/raven/1.0/api/precondition/{0}/test'.format(precondition_key)
165165
return self.get(url)
166166

167-
def update_precondition(self, precondition_key, add=[], remove=[]):
167+
def update_precondition(self, precondition_key, add=None, remove=None):
168168
"""
169169
Associate tests with the given pre-condition.
170170
:param precondition_key: Precondition key (eg. 'TEST-001').
171-
:param add: OPTIONAL List of Test Keys to associate with the pre-condition (eg. ['TEST-002', 'TEST-003'])
172-
:param add: OPTIONAL List of Test Keys no longer associate with the pre-condition (eg. ['TEST-004', 'TEST-005'])
171+
:param add: OPTIONAL List of Test Keys to associate with the pre-condition (eg. ['TEST-2', 'TEST-3'])
172+
:param remove: OPTIONAL List of Test Keys no longer associate with the pre-condition (eg. ['TEST-4', 'TEST-5'])
173173
:return:
174174
"""
175+
if remove is None:
176+
remove = []
177+
if add is None:
178+
add = []
175179
update = {'add': add, 'remove': remove}
176180
url = 'rest/raven/1.0/api/precondition/{0}/test'.format(precondition_key)
177181
return self.post(url, update)
@@ -196,14 +200,18 @@ def get_tests_with_test_set(self, test_set_key):
196200
url = 'rest/raven/1.0/api/testset/{0}/test'.format(test_set_key)
197201
return self.get(url)
198202

199-
def update_test_set(self, test_set_key, add=[], remove=[]):
203+
def update_test_set(self, test_set_key, add=None, remove=None):
200204
"""
201205
Associate tests with the given test set.
202206
:param test_set_key: Test set key (eg. 'SET-001').
203207
:param add: OPTIONAL List of Test Keys to associate with the test set (eg. ['TEST-002', 'TEST-003'])
204-
:param add: OPTIONAL List of Test Keys no longer associate with the test set (eg. ['TEST-004', 'TEST-005'])
208+
:param remove: OPTIONAL List of Test Keys no longer associate with the test set (eg. ['TEST-004', 'TEST-005'])
205209
:return:
206210
"""
211+
if add is None:
212+
add = []
213+
if remove is None:
214+
remove = []
207215
update = {'add': add, 'remove': remove}
208216
url = 'rest/raven/1.0/api/testset/{0}/test'.format(test_set_key)
209217
return self.post(url, update)
@@ -228,14 +236,18 @@ def get_tests_with_test_plan(self, test_plan_key):
228236
url = 'rest/raven/1.0/api/testplan/{0}/test'.format(test_plan_key)
229237
return self.get(url)
230238

231-
def update_test_plan(self, test_plan_key, add=[], remove=[]):
239+
def update_test_plan(self, test_plan_key, add=None, remove=None):
232240
"""
233241
Associate tests with the given test plan.
234242
:param test_plan_key: Test plan key (eg. 'PLAN-001').
235243
:param add: OPTIONAL List of Test Keys to associate with the test plan (eg. ['TEST-002', 'TEST-003'])
236-
:param add: OPTIONAL List of Test Keys no longer associate with the test plan (eg. ['TEST-004', 'TEST-005'])
244+
:param remove: OPTIONAL List of Test Keys no longer associate with the test plan (eg. ['TEST-004', 'TEST-005'])
237245
:return:
238246
"""
247+
if add is None:
248+
add = []
249+
if remove is None:
250+
remove = []
239251
update = {'add': add, 'remove': remove}
240252
url = 'rest/raven/1.0/api/testplan/{0}/test'.format(test_plan_key)
241253
return self.post(url, update)
@@ -260,14 +272,18 @@ def get_tests_with_test_execution(self, test_exec_key):
260272
url = 'rest/raven/1.0/api/testexec/{0}/test'.format(test_exec_key)
261273
return self.get(url)
262274

263-
def update_test_execution(self, test_exec_key, add=[], remove=[]):
275+
def update_test_execution(self, test_exec_key, add=None, remove=None):
264276
"""
265277
Associate tests with the given test execution.
266278
:param test_exec_key: Test execution key (eg. 'EXEC-001').
267-
:param add: OPTIONAL List of Test Keys to associate with the test execution (eg. ['TEST-002', 'TEST-003'])
268-
:param add: OPTIONAL List of Test Keys no longer associate with the test execution (eg. ['TEST-004', 'TEST-005'])
279+
:param add: OPTIONAL List of Test Keys to associate with the test execution (eg. ['TEST-2', 'TEST-3'])
280+
:param remove: OPTIONAL List of Test Keys no longer associate with the test execution (eg. ['TEST-4', 'TEST-5'])
269281
:return:
270282
"""
283+
if add is None:
284+
add = []
285+
if remove is None:
286+
remove = []
271287
update = {'add': add, 'remove': remove}
272288
url = 'rest/raven/1.0/api/testexec/{0}/test'.format(test_exec_key)
273289
return self.post(url, update)
@@ -325,7 +341,7 @@ def update_test_run_status(self, test_run_id, status):
325341
"""
326342
Update the status for the given test run.
327343
:param test_run_id: ID of the test run (eg. 100).
328-
:param assignee: Assignee id (eg. 'PASS')
344+
:param status: Status id (eg. 'PASS')
329345
:return:
330346
"""
331347
update = {'status': status}
@@ -341,14 +357,18 @@ def get_test_run_defects(self, test_run_id):
341357
url = 'rest/raven/1.0/api/testrun/{0}/defect'.format(test_run_id)
342358
return self.get(url)
343359

344-
def update_test_run_defects(self, test_run_id, add=[], remove=[]):
360+
def update_test_run_defects(self, test_run_id, add=None, remove=None):
345361
"""
346362
Update the defects associated with the given test run.
347363
:param test_run_id: ID of the test run (eg. 100).
348364
:param add: OPTIONAL List of defects to associate to the test run (eg. ['BUG-001', 'BUG-002'])
349365
:param remove: OPTIONAL List of defects which no longer need to be associated to the test run (eg. ['BUG-003'])
350366
:return:
351367
"""
368+
if add is None:
369+
add = []
370+
if remove is None:
371+
remove = []
352372
update = {'defects': {'add': add, 'remove': remove}}
353373
url = 'rest/raven/1.0/api/testrun/{0}'.format(test_run_id)
354374
return self.put(url, update)

0 commit comments

Comments
 (0)