atlassian-python-api 3.41.13__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.
Files changed (54) hide show
  1. atlassian/VERSION +1 -0
  2. atlassian/__init__.py +32 -0
  3. atlassian/bamboo.py +1343 -0
  4. atlassian/bitbucket/__init__.py +3572 -0
  5. atlassian/bitbucket/base.py +198 -0
  6. atlassian/bitbucket/cloud/__init__.py +24 -0
  7. atlassian/bitbucket/cloud/base.py +123 -0
  8. atlassian/bitbucket/cloud/common/__init__.py +1 -0
  9. atlassian/bitbucket/cloud/common/builds.py +85 -0
  10. atlassian/bitbucket/cloud/common/comments.py +50 -0
  11. atlassian/bitbucket/cloud/common/users.py +79 -0
  12. atlassian/bitbucket/cloud/repositories/__init__.py +437 -0
  13. atlassian/bitbucket/cloud/repositories/branchRestrictions.py +175 -0
  14. atlassian/bitbucket/cloud/repositories/commits.py +188 -0
  15. atlassian/bitbucket/cloud/repositories/defaultReviewers.py +94 -0
  16. atlassian/bitbucket/cloud/repositories/deploymentEnvironments.py +264 -0
  17. atlassian/bitbucket/cloud/repositories/diffstat.py +92 -0
  18. atlassian/bitbucket/cloud/repositories/groupPermissions.py +81 -0
  19. atlassian/bitbucket/cloud/repositories/hooks.py +117 -0
  20. atlassian/bitbucket/cloud/repositories/issues.py +164 -0
  21. atlassian/bitbucket/cloud/repositories/pipelines.py +274 -0
  22. atlassian/bitbucket/cloud/repositories/pullRequests.py +483 -0
  23. atlassian/bitbucket/cloud/repositories/refs.py +136 -0
  24. atlassian/bitbucket/cloud/repositories/repositoryVariables.py +146 -0
  25. atlassian/bitbucket/cloud/workspaces/__init__.py +146 -0
  26. atlassian/bitbucket/cloud/workspaces/members.py +62 -0
  27. atlassian/bitbucket/cloud/workspaces/permissions.py +125 -0
  28. atlassian/bitbucket/cloud/workspaces/projects.py +215 -0
  29. atlassian/bitbucket/server/__init__.py +46 -0
  30. atlassian/bitbucket/server/base.py +63 -0
  31. atlassian/bitbucket/server/common/__init__.py +1 -0
  32. atlassian/bitbucket/server/common/permissions.py +220 -0
  33. atlassian/bitbucket/server/globalPermissions.py +198 -0
  34. atlassian/bitbucket/server/projects/__init__.py +244 -0
  35. atlassian/bitbucket/server/projects/repos/__init__.py +327 -0
  36. atlassian/cloud_admin.py +32 -0
  37. atlassian/confluence.py +3336 -0
  38. atlassian/crowd.py +266 -0
  39. atlassian/errors.py +27 -0
  40. atlassian/insight.py +678 -0
  41. atlassian/jira.py +5324 -0
  42. atlassian/marketplace.py +84 -0
  43. atlassian/portfolio.py +108 -0
  44. atlassian/request_utils.py +39 -0
  45. atlassian/rest_client.py +558 -0
  46. atlassian/service_desk.py +911 -0
  47. atlassian/statuspage.py +3133 -0
  48. atlassian/utils.py +327 -0
  49. atlassian/xray.py +632 -0
  50. atlassian_python_api-3.41.13.dist-info/LICENSE +201 -0
  51. atlassian_python_api-3.41.13.dist-info/METADATA +261 -0
  52. atlassian_python_api-3.41.13.dist-info/RECORD +54 -0
  53. atlassian_python_api-3.41.13.dist-info/WHEEL +5 -0
  54. atlassian_python_api-3.41.13.dist-info/top_level.txt +1 -0
atlassian/xray.py ADDED
@@ -0,0 +1,632 @@
1
+ # coding=utf-8
2
+ import logging
3
+ import re
4
+ from .rest_client import AtlassianRestAPI
5
+
6
+ log = logging.getLogger(__name__)
7
+
8
+
9
+ class Xray(AtlassianRestAPI):
10
+ def __init__(self, *args, **kwargs):
11
+ if "api_version" not in kwargs:
12
+ kwargs["api_version"] = "1.0"
13
+ kwargs["api_root"] = "rest/raven"
14
+ super(Xray, self).__init__(*args, **kwargs)
15
+
16
+ def resource_url(self, resource, api_root=None, api_version=None):
17
+ """
18
+ Overloading the method from AtlassianRestAPI to be compatible with the "middle man" version used by Xray.
19
+ """
20
+ if api_root is None:
21
+ api_root = self.api_root
22
+ if api_version is None:
23
+ api_version = self.api_version
24
+ return "/".join(s.strip("/") for s in [api_root, api_version, "api", resource] if s is not None)
25
+
26
+ # Tests API
27
+ def get_tests(self, test_keys):
28
+ """
29
+ Retrieve information about the provided tests.
30
+ :param test_keys: list of tests (eg. `['TEST-001', 'TEST-002']`) to retrieve.
31
+ :return: Returns the retrieved tests.
32
+ """
33
+ url = self.resource_url("test?keys={0}".format(";".join(test_keys)))
34
+ return self.get(url)
35
+
36
+ def get_test_statuses(self):
37
+ """
38
+ Retrieve a list of all Test Statuses available in Xray sorted by rank.
39
+ :return: Returns the test statuses.
40
+ """
41
+ url = self.resource_url("settings/teststatuses")
42
+ return self.get(url)
43
+
44
+ def get_test_runs(self, test_key):
45
+ """
46
+ Retrieve test runs of a test.
47
+ :param test_key: Test key (eg. 'TEST-001').
48
+ :return: Returns the exported test runs.
49
+ """
50
+ url = self.resource_url("test/{0}/testruns".format(test_key))
51
+ return self.get(url)
52
+
53
+ def get_test_runs_in_context(
54
+ self,
55
+ test_exec_key=None,
56
+ test_key=None,
57
+ test_plan_key=None,
58
+ include_test_fields=None,
59
+ saved_filter_id=None,
60
+ limit=None,
61
+ page=None,
62
+ ):
63
+ """
64
+ Retrieves all the Test Runs from a given context.
65
+ With this endpoint you can obtain all the Test Runs (paginated)
66
+ in one of the following contexts:
67
+ * In a Test Execution issue (use testKey to limit to single test)
68
+ * In a Test Plan issue
69
+ * In a JQL filter that returns several Test Execution issue
70
+ In case the Test Run has iterations, steps will not appear.
71
+ However, if the Test has parameters but executed one time,
72
+ it will show the steps and the parameters' info
73
+ :param test_exec_key: The Test Execution issue key
74
+ :param test_key: The Test issue key
75
+ (may only be used when using the "test_exec_key" param)
76
+ :param test_plan_key: The Test Plan issue key
77
+ :param include_test_fields: List of custom fields of the Test issue
78
+ to be return in the responde
79
+ (several custom fields can be requested by separating them with ',')
80
+ :param saved_filter_id: The Jira JQL filter ID or
81
+ name containing Test Executions issues
82
+ :param limit: The number of maximum Test Runs to be returned
83
+ :param page: The number of the results page
84
+ :return: Returns the exported test runs.
85
+ """
86
+ if self.api_version == "1.0":
87
+ raise Exception("Not supported in API version 1.0")
88
+ params = {}
89
+ if test_exec_key:
90
+ params["testExecKey"] = test_exec_key
91
+ if test_key:
92
+ params["testKey"] = test_key
93
+ if test_plan_key:
94
+ params["testPlanKey"] = test_plan_key
95
+ if include_test_fields:
96
+ params["includeTestFields"] = include_test_fields
97
+ if saved_filter_id:
98
+ params["savedFilterId"] = saved_filter_id
99
+ if limit:
100
+ params["limit"] = limit
101
+ if page:
102
+ params["page"] = page
103
+ url = self.resource_url("testruns")
104
+ return self.get(url, params=params)
105
+
106
+ def get_test_runs_with_environment(self, test_key, test_environments):
107
+ # TODO
108
+ """
109
+ Retrieve test runs of a test filtered by tests environments.
110
+ :param test_key: Test key (eg. 'TEST-001').
111
+ :param test_environments: Test execution environments separated by ','.
112
+ :return: Returns the exported test runs.
113
+ """
114
+ env = "?testEnvironments={0}".format(",".join([re.escape(env) for env in test_environments]))
115
+ url = self.resource_url("test/{0}/testruns{1}".format(test_key, env))
116
+ return self.get(url)
117
+
118
+ def get_test_preconditions(self, test_key):
119
+ """
120
+ Retrieve pre-conditions of a test.
121
+ :param test_key: Test key (eg. 'TEST-001').
122
+ :return: Returns the test pre-conditions of a given test.
123
+ """
124
+ url = self.resource_url("test/{0}/preconditions".format(test_key))
125
+ return self.get(url)
126
+
127
+ def get_test_sets(self, test_key):
128
+ """
129
+ Retrieve test sets associated with a test.
130
+ :param test_key: Test key (eg. 'TEST-001').
131
+ :return: Returns the exported test sets.
132
+ """
133
+ url = self.resource_url("test/{0}/testsets".format(test_key))
134
+ return self.get(url)
135
+
136
+ def get_test_executions(self, test_key):
137
+ """
138
+ Retrieve test executions of a test.
139
+ :param test_key: Test key (eg. 'TEST-001').
140
+ :return: Returns the exported test executions.
141
+ """
142
+ url = self.resource_url("test/{0}/testexecutions".format(test_key))
143
+ return self.get(url)
144
+
145
+ def get_test_plans(self, test_key):
146
+ """
147
+ Retrieve test plans associated with a test.
148
+ :param test_key: Test key (eg. 'TEST-001').
149
+ :return: Returns the exported test plans.
150
+ """
151
+ url = self.resource_url("test/{0}/testplans".format(test_key))
152
+ return self.get(url)
153
+
154
+ # Test Steps API
155
+ def get_test_step_statuses(self):
156
+ """
157
+ Retrieve the test step statuses available in Xray sorted by rank.
158
+ :return: Returns the test step statuses available in Xray sorted by rank.
159
+ """
160
+ url = self.resource_url("settings/teststepstatuses")
161
+ return self.get(url)
162
+
163
+ def get_test_step(self, test_key, test_step_id):
164
+ """
165
+ Retrieve the specified test step of a given test.
166
+ :param test_key: Test key (eg. 'TEST-001').
167
+ :param test_step_id: ID of the test step.
168
+ :return: Return the test step with the given id.
169
+ """
170
+ url = self.resource_url("test/{0}/step/{1}".format(test_key, test_step_id))
171
+ return self.get(url)
172
+
173
+ def get_test_steps(self, test_key):
174
+ """
175
+ Retrieve the test steps of a given test.
176
+ :param test_key: Test key (eg. 'TEST-001').
177
+ :return: Return the test steps of a given test.
178
+ """
179
+ url = self.resource_url("test/{0}/step".format(test_key))
180
+ return self.get(url)
181
+
182
+ def create_test_step(self, test_key, step, data, result):
183
+ """
184
+ Create a new test steps for a given test.
185
+ NOTE: attachments are currently not supported!
186
+ :param test_key: Test key (eg. 'TEST-001').
187
+ :param step: Test Step name (eg. 'Example step').
188
+ :param data: Test Step data (eg. 'Example data').
189
+ :param result: Test Step results (eg. 'Example results').
190
+ :return:
191
+ """
192
+ create = {"step": step, "data": data, "result": result, "attachments": []}
193
+ url = self.resource_url("test/{0}/step".format(test_key))
194
+ return self.put(url, create)
195
+
196
+ def update_test_step(self, test_key, test_step_id, step, data, result):
197
+ """
198
+ Update the specified test steps for a given test.
199
+ NOTE: attachments are currently not supported!
200
+ :param test_key: Test key (eg. 'TEST-001').
201
+ :param test_step_id: ID of the test step.
202
+ :param step: Test Step name (eg. 'Example step').
203
+ :param data: Test Step data (eg. 'Example data').
204
+ :param result: Test Step results (eg. 'Example results').
205
+ :return:
206
+ """
207
+ update = {
208
+ "step": step,
209
+ "data": data,
210
+ "result": result,
211
+ "attachments": {"add": [], "remove": []},
212
+ }
213
+ url = self.resource_url("test/{0}/step/{1}".format(test_key, test_step_id))
214
+ return self.post(url, update)
215
+
216
+ def delete_test_step(self, test_key, test_step_id):
217
+ """
218
+ Remove the specified test steps from a given test.
219
+ :param test_key: Test key (eg. 'TEST-001').
220
+ :param test_step_id: ID of the test step.
221
+ :return:
222
+ """
223
+ url = self.resource_url("test/{0}/step/{1}".format(test_key, test_step_id))
224
+ return self.delete(url)
225
+
226
+ # Pre-Conditions API
227
+ def get_tests_with_precondition(self, precondition_key):
228
+ """
229
+ Retrieve the tests associated with the given pre-condition.
230
+ :param precondition_key: Precondition key (eg. 'TEST-001').
231
+ :return: Return a list of the test associated with the pre-condition.
232
+ """
233
+ url = self.resource_url("precondition/{0}/test".format(precondition_key))
234
+ return self.get(url)
235
+
236
+ def update_precondition(self, precondition_key, add=None, remove=None):
237
+ """
238
+ Associate tests with the given pre-condition.
239
+ :param precondition_key: Precondition key (eg. 'TEST-001').
240
+ :param add: OPTIONAL: List of Test Keys to associate with the pre-condition (eg. ['TEST-2', 'TEST-3'])
241
+ :param remove: OPTIONAL: List of Test Keys no longer associate with the pre-condition (eg. ['TEST-4', 'TEST-5'])
242
+ :return:
243
+ """
244
+ if remove is None:
245
+ remove = []
246
+ if add is None:
247
+ add = []
248
+ update = {"add": add, "remove": remove}
249
+ url = self.resource_url("precondition/{0}/test".format(precondition_key))
250
+ return self.post(url, update)
251
+
252
+ def delete_test_from_precondition(self, precondition_key, test_key):
253
+ """
254
+ Remove association of the specified tests from the given pre-condition.
255
+ :param precondition_key: Precondition key (eg. 'TEST-001').
256
+ :param test_key: Test Key which should no longer be associate with the pre-condition (eg. 'TEST-100')
257
+ :return:
258
+ """
259
+ url = self.resource_url("precondition/{0}/test/{1}".format(precondition_key, test_key))
260
+ return self.delete(url)
261
+
262
+ # Test Set API
263
+ def get_tests_with_test_set(self, test_set_key, limit=None, page=None):
264
+ """
265
+ Retrieve the tests associated with the given test set.
266
+ :param test_set_key: Test set key (eg. 'SET-001').
267
+ :param limit: OPTIONAL: Limits the number of results per page.
268
+ :param page: OPTIONAL: Number of the page to be returned.
269
+ :return: Return a list of the test associated with the test set.
270
+ """
271
+ url = self.resource_url("testset/{0}/test".format(test_set_key))
272
+ params = {}
273
+
274
+ if limit:
275
+ params["limit"] = limit
276
+ if page:
277
+ params["page"] = page
278
+
279
+ return self.get(url, params=params)
280
+
281
+ def update_test_set(self, test_set_key, add=None, remove=None):
282
+ """
283
+ Associate tests with the given test set.
284
+ :param test_set_key: Test set key (eg. 'SET-001').
285
+ :param add: OPTIONAL: List of Test Keys to associate with the test set (eg. ['TEST-002', 'TEST-003'])
286
+ :param remove: OPTIONAL: List of Test Keys no longer associate with the test set (eg. ['TEST-004', 'TEST-005'])
287
+ :return:
288
+ """
289
+ if add is None:
290
+ add = []
291
+ if remove is None:
292
+ remove = []
293
+ update = {"add": add, "remove": remove}
294
+ url = self.resource_url("testset/{0}/test".format(test_set_key))
295
+ return self.post(url, update)
296
+
297
+ def delete_test_from_test_set(self, test_set_key, test_key):
298
+ """
299
+ Remove association of the specified tests from the given test set.
300
+ :param test_set_key: Test set key (eg. 'SET-001').
301
+ :param test_key: Test Key which should no longer be associate with the test set (eg. 'TEST-100')
302
+ :return:
303
+ """
304
+ url = self.resource_url("testset/{0}/test/{1}".format(test_set_key, test_key))
305
+ return self.delete(url)
306
+
307
+ # Test Plans API
308
+ def get_tests_with_test_plan(self, test_plan_key, limit=None, page=None):
309
+ """
310
+ Retrieve the tests associated with the given test plan.
311
+ :param test_plan_key: Test set key (eg. 'PLAN-001').
312
+ :param limit: OPTIONAL: Limits the number of results per page.
313
+ :param page: OPTIONAL: Number of the page to be returned.
314
+ :return: Return a list of the test associated with the test plan.
315
+ """
316
+ url = self.resource_url("testplan/{0}/test".format(test_plan_key))
317
+ params = {}
318
+
319
+ if limit:
320
+ params["limit"] = limit
321
+ if page:
322
+ params["page"] = page
323
+
324
+ return self.get(url, params=params)
325
+
326
+ def update_test_plan(self, test_plan_key, add=None, remove=None):
327
+ """
328
+ Associate tests with the given test plan.
329
+ :param test_plan_key: Test plan key (eg. 'PLAN-001').
330
+ :param add: OPTIONAL: List of Test Keys to associate with the test plan (eg. ['TEST-002', 'TEST-003'])
331
+ :param remove: OPTIONAL: List of Test Keys no longer associate with the test plan (eg. ['TEST-004', 'TEST-005'])
332
+ :return:
333
+ """
334
+ if add is None:
335
+ add = []
336
+ if remove is None:
337
+ remove = []
338
+ update = {"add": add, "remove": remove}
339
+ url = self.resource_url("testplan/{0}/test".format(test_plan_key))
340
+ return self.post(url, update)
341
+
342
+ def delete_test_from_test_plan(self, test_plan_key, test_key):
343
+ """
344
+ Remove association of the specified tests from the given test plan.
345
+ :param test_plan_key: Test plan key (eg. 'PLAN-001').
346
+ :param test_key: Test Key which should no longer be associate with the test plan (eg. 'TEST-100')
347
+ :return:
348
+ """
349
+ url = self.resource_url("testplan/{0}/test/{1}".format(test_plan_key, test_key))
350
+ return self.delete(url)
351
+
352
+ def get_test_executions_with_test_plan(self, test_plan_key):
353
+ """
354
+ Retrieve test executions associated with the given test plan.
355
+ :param test_plan_key: Test plan key (eg. 'PLAN-001').
356
+ :return: Return a list of the test executions associated with the test plan.
357
+ """
358
+ url = self.resource_url("testplan/{0}/testexecution".format(test_plan_key))
359
+ return self.get(url)
360
+
361
+ def update_test_plan_test_executions(self, test_plan_key, add=None, remove=None):
362
+ """
363
+ Associate test executions with the given test plan.
364
+ :param test_plan_key: Test plan key (eg. 'PLAN-001').
365
+ :param add: OPTIONAL: List of Test Keys to associate with the test plan (eg. ['TEST-002', 'TEST-003'])
366
+ :param remove: OPTIONAL: List of Test Keys no longer associate with the test plan (eg. ['TEST-004', 'TEST-005'])
367
+ :return:
368
+ """
369
+ if add is None:
370
+ add = []
371
+ if remove is None:
372
+ remove = []
373
+ update = {"add": add, "remove": remove}
374
+ url = self.resource_url("testplan/{0}/testexecution".format(test_plan_key))
375
+ return self.post(url, update)
376
+
377
+ def delete_test_execution_from_test_plan(self, test_plan_key, test_exec_key):
378
+ """
379
+ Remove association of the specified tests execution from the given test plan.
380
+ :param test_plan_key: Test plan key (eg. 'PLAN-001').
381
+ :param test_exec_key: Test execution Key which should no longer be associate with the test plan (eg. 'TEST-100')
382
+ :return:
383
+ """
384
+ url = self.resource_url("testplan/{0}/testexecution/{1}".format(test_plan_key, test_exec_key))
385
+ return self.delete(url)
386
+
387
+ # Test Executions API
388
+ def get_tests_with_test_execution(self, test_exec_key, detailed=False, limit=None, page=None):
389
+ """
390
+ Retrieve the tests associated with the given test execution.
391
+ :param test_exec_key: Test execution key (eg. 'EXEC-001').
392
+ :param detailed: OPTIONAL: (bool) Retrieve detailed information about the testrun
393
+ :param limit: OPTIONAL: Limits the number of results per page.
394
+ :param page: OPTIONAL: Number of the page to be returned.
395
+ :return: Return a list of the test associated with the test execution.
396
+ """
397
+ url = self.resource_url("testexec/{0}/test".format(test_exec_key))
398
+ params = {}
399
+
400
+ if detailed:
401
+ params["detailed"] = detailed
402
+ if limit:
403
+ params["limit"] = limit
404
+ if page:
405
+ params["page"] = page
406
+
407
+ return self.get(url, params=params)
408
+
409
+ def update_test_execution(self, test_exec_key, add=None, remove=None):
410
+ """
411
+ Associate tests with the given test execution.
412
+ :param test_exec_key: Test execution key (eg. 'EXEC-001').
413
+ :param add: OPTIONAL: List of Test Keys to associate with the test execution (eg. ['TEST-2', 'TEST-3'])
414
+ :param remove: OPTIONAL:
415
+ List of Test Keys no longer associate with the test execution (eg. ['TEST-4', 'TEST-5'])
416
+ :return:
417
+ """
418
+ if add is None:
419
+ add = []
420
+ if remove is None:
421
+ remove = []
422
+ update = {"add": add, "remove": remove}
423
+ url = self.resource_url("testexec/{0}/test".format(test_exec_key))
424
+ return self.post(url, update)
425
+
426
+ def delete_test_from_test_execution(self, test_exec_key, test_key):
427
+ """
428
+ Remove association of the specified tests from the given test execution.
429
+ :param test_exec_key: Test execution key (eg. 'EXEC-001').
430
+ :param test_key: Test Key which should no longer be associate with the test execution (eg. 'TEST-100')
431
+ :return:
432
+ """
433
+ url = self.resource_url("testexec/{0}/test/{1}".format(test_exec_key, test_key))
434
+ return self.delete(url)
435
+
436
+ # Test Runs API
437
+ def get_test_run(self, test_run_id):
438
+ """
439
+ Retrieve detailed information about the given test run.
440
+ :param test_run_id: ID of the test run (e.g. 100).
441
+ :return: Returns detailed information about the test run.
442
+ """
443
+ url = self.resource_url("testrun/{0}".format(test_run_id))
444
+ return self.get(url)
445
+
446
+ def get_test_run_assignee(self, test_run_id):
447
+ """
448
+ Retrieve the assignee for the given test run.
449
+ :param test_run_id: ID of the test run (e.g. 100).
450
+ :return: Returns the assignee for the given test run
451
+ """
452
+ url = self.resource_url("testrun/{0}/assignee".format(test_run_id))
453
+ return self.get(url)
454
+
455
+ def update_test_run_assignee(self, test_run_id, assignee):
456
+ """
457
+ Update the assignee for the given test run.
458
+ :param test_run_id: ID of the test run (eg. 100).
459
+ :param assignee: Assignee id (eg. 'bob')
460
+ :return:
461
+ """
462
+ update = {"assignee": assignee}
463
+ url = self.resource_url("testrun/{0}".format(test_run_id))
464
+ return self.put(url, update)
465
+
466
+ def get_test_run_status(self, test_run_id):
467
+ """
468
+ Retrieve the status for the given test run.
469
+ :param test_run_id: ID of the test run (e.g. 100).
470
+ :return: Returns the status for the given test run
471
+ """
472
+ url = self.resource_url("testrun/{0}/status".format(test_run_id))
473
+ return self.get(url)
474
+
475
+ def update_test_run_status(self, test_run_id, status):
476
+ """
477
+ Update the status for the given test run.
478
+ :param test_run_id: ID of the test run (e.g. 100).
479
+ :param status: Status id (eg. 'PASS')
480
+ :return:
481
+ """
482
+ update = {"status": status}
483
+ url = self.resource_url("testrun/{0}".format(test_run_id))
484
+ return self.put(url, update)
485
+
486
+ def get_test_run_defects(self, test_run_id):
487
+ """
488
+ Retrieve the defects for the given test run.
489
+ :param test_run_id: ID of the test run (e.g. 100).
490
+ :return: Returns a list of defects for the given test run
491
+ """
492
+ url = self.resource_url("testrun/{0}/defect".format(test_run_id))
493
+ return self.get(url)
494
+
495
+ def update_test_run_defects(self, test_run_id, add=None, remove=None):
496
+ """
497
+ Update the defects associated with the given test run.
498
+ :param test_run_id: ID of the test run (eg. 100).
499
+ :param add: OPTIONAL: List of defects to associate to the test run (eg. ['BUG-001', 'BUG-002'])
500
+ :param remove: OPTIONAL: List of defects which no longer need to be associated to the test run (eg. ['BUG-003'])
501
+ :return:
502
+ """
503
+ if add is None:
504
+ add = []
505
+ if remove is None:
506
+ remove = []
507
+ update = {"defects": {"add": add, "remove": remove}}
508
+ url = self.resource_url("testrun/{0}".format(test_run_id))
509
+ return self.put(url, update)
510
+
511
+ def get_test_run_comment(self, test_run_id):
512
+ """
513
+ Retrieve the comment for the given test run.
514
+ :param test_run_id: ID of the test run (e.g. 100).
515
+ :return: Returns the comment for the given test run
516
+ """
517
+ url = self.resource_url("testrun/{0}/comment".format(test_run_id))
518
+ return self.get(url)
519
+
520
+ def update_test_run_comment(self, test_run_id, comment):
521
+ """
522
+ Update the comment for the given test run.
523
+ :param test_run_id: ID of the test run (eg. 100).
524
+ :param comment: Comment (e.g. 'Test needs to be reworked')
525
+ :return:
526
+ """
527
+ update = {"comment": comment}
528
+ url = self.resource_url("testrun/{0}".format(test_run_id))
529
+ return self.put(url, update)
530
+
531
+ def get_test_run_steps(self, test_run_id):
532
+ """
533
+ Retrieve the steps for the given test run.
534
+ :param test_run_id: ID of the test run (e.g. 100).
535
+ :return: Returns the steps for the given test run
536
+ """
537
+ url = self.resource_url("testrun/{0}/step".format(test_run_id))
538
+ return self.get(url)
539
+
540
+ def get_test_repo_folders(self, project_key):
541
+ """
542
+ Retrieve test repository folders of a project.
543
+ :param project_key: Project key (eg. 'FOO').
544
+ :return: Returns the list of test repository folders.
545
+ """
546
+ url = self.resource_url("testrepository/{0}/folders".format(project_key))
547
+ return self.get(url)
548
+
549
+ def get_test_repo_folder(self, project_key, folder_id):
550
+ """
551
+ Retrieve test repository folder of a project.
552
+ :param project_key: Project key (eg. 'FOO').
553
+ :param folder_id: Internal folder ID.
554
+ :return: Returns the test repository folder.
555
+ """
556
+ url = self.resource_url("testrepository/{0}/folders/{1}".format(project_key, folder_id))
557
+ return self.get(url)
558
+
559
+ def create_test_repo_folder(self, project_key, folder_name, parent_folder_id=-1):
560
+ """
561
+ Create test repository folder for a project.
562
+ :param project_key: Project key (eg. 'FOO').
563
+ :param folder_name: Name of folder.
564
+ :param parent_folder_id: Internal folder ID; "-1" corresponds to the root folder of the test repository.
565
+ :return: Returns the created test repository folder.
566
+ """
567
+ data = {"name": folder_name}
568
+ url = self.resource_url("testrepository/{0}/folders/{1}".format(project_key, parent_folder_id))
569
+ return self.post(url, data=data)
570
+
571
+ def update_test_repo_folder(self, project_key, folder_id, folder_name, rank=1):
572
+ """
573
+ Update test repository folder for a project.
574
+ :param project_key: Project key (eg. 'FOO').
575
+ :param folder_id: Internal folder ID.
576
+ :param folder_name: Name of folder.
577
+ :param rank: Rank within the parent folder.
578
+ :return: Returns the updated test repository folder.
579
+ """
580
+ data = {"name": folder_name, "rank": rank}
581
+ url = self.resource_url("testrepository/{0}/folders/{1}".format(project_key, folder_id))
582
+ return self.put(url, data=data)
583
+
584
+ def delete_test_repo_folder(self, project_key, folder_id):
585
+ """
586
+ Delete test repository folder for a project.
587
+ :param project_key: Project key (eg. 'FOO').
588
+ :param folder_id: Internal folder Id.
589
+ :return: Returns the delete results.
590
+ """
591
+ url = self.resource_url("testrepository/{0}/folders/{1}".format(project_key, folder_id))
592
+ return self.delete(url)
593
+
594
+ def get_test_repo_folder_tests(self, project_key, folder_id, all_descendants=False, page=1, limit=50):
595
+ """
596
+ Retrieve tests of a test repository folder.
597
+ :param project_key: Project key (eg. 'FOO').
598
+ :param folder_id: Internal folder ID.
599
+ :param all_descendants: Include all descendants (i.e. all child Tests); "false", by default.
600
+ :param page: Page of paginated data (first 1)
601
+ :param limit: Amount of Tests per paginated data.
602
+ :return: Returns list of the Tests contained in a given folder of the test repository.
603
+ Note: param "page" and "limit" must coexist, otherwise rest api will raise 400
604
+ """
605
+ url = self.resource_url("testrepository/{0}/folders/{1}/tests".format(project_key, folder_id))
606
+ params = {}
607
+
608
+ if all_descendants:
609
+ params["allDescendants"] = all_descendants
610
+ if page:
611
+ params["page"] = page
612
+ if limit:
613
+ params["limit"] = limit
614
+
615
+ return self.get(url, params=params)
616
+
617
+ def update_test_repo_folder_tests(self, project_key, folder_id, add=None, remove=None):
618
+ """
619
+ Update tests of a test repository folder.
620
+ :param project_key: Project key (eg. 'FOO').
621
+ :param folder_id: Internal folder Id.
622
+ :param add: OPTIONAL: List of tests to be added (eg. ['TEST-001', 'TEST-002'])
623
+ :param remove: OPTIONAL: List of tests to be removed (eg. ['TEST-003'])
624
+ :return: Returns the update result.
625
+ """
626
+ if add is None:
627
+ add = []
628
+ if remove is None:
629
+ remove = []
630
+ data = {"add": add, "remove": remove}
631
+ url = self.resource_url("testrepository/{0}/folders/{1}/tests".format(project_key, folder_id))
632
+ return self.put(url, data=data)