testrail-ruby 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/endpoints.rb +76 -271
- data/lib/testrail-ruby.rb +17 -41
- data/lib/version.rb +1 -1
- metadata +1 -2
- data/lib/testrail-ruby-broken.rb +0 -85
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 928183b23034905ff5b66c5a8aa1f6ce5635ecd8
|
4
|
+
data.tar.gz: 802c7abb8fe7766de441ba64fbcc0083e2d47299
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a601eec402e070a1322282b6bf262a2f94c625aaf49b7ff9aa3ccc1548d575e635a92cbf41f6f5e76e59c16863d3ca189cb22f2c427b1f469c907f11f37d1abe
|
7
|
+
data.tar.gz: 4f820237599e4b8f86db03a5841f91bccf572b32eb60e9faa6df0912a0026fc604a906df2a945706c86af655df94dffdefac138e6517462cb614959608d8c8b1
|
data/lib/endpoints.rb
CHANGED
@@ -1,688 +1,493 @@
|
|
1
1
|
module Endpoints
|
2
|
-
##########################++
|
3
|
-
####get_case################
|
4
|
-
############################
|
5
2
|
# Returns an existing test case
|
6
3
|
# @param case_id [int] The id of the test case you want.
|
7
|
-
# @
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# GET index.php?/api/v2/get_case/1
|
11
|
-
# @example Response Example
|
12
|
-
# {
|
13
|
-
# "created_by": 5,
|
14
|
-
# "created_on": 1392300984,
|
15
|
-
# "custom_expected": "..",
|
16
|
-
# "custom_preconds": "..",
|
17
|
-
# "custom_steps": "..",
|
18
|
-
# "custom_steps_separated": [
|
19
|
-
# {
|
20
|
-
# "content": "Step 1",
|
21
|
-
# "expected": "Expected Result 1"
|
22
|
-
# },
|
23
|
-
# {
|
24
|
-
# "content": "Step 2",
|
25
|
-
# "expected": "Expected Result 2"
|
26
|
-
# }
|
27
|
-
# ],
|
28
|
-
# "estimate": "1m 5s",
|
29
|
-
# "estimate_forecast": null,
|
30
|
-
# "id": 1,
|
31
|
-
# "milestone_id": 7,
|
32
|
-
# "priority_id": 2,
|
33
|
-
# "refs": "RF-1, RF-2",
|
34
|
-
# "section_id": 1,
|
35
|
-
# "suite_id": 1,
|
36
|
-
# "title": "Change document attributes (author, title, organization)",
|
37
|
-
# "type_id": 4,
|
38
|
-
# "updated_by": 1,
|
39
|
-
# "updated_on": 1393586511
|
40
|
-
# }
|
4
|
+
# @param [Hash] opts
|
5
|
+
# @example Endpoint
|
6
|
+
# index.php?/api/v2/get_case/:case_id
|
41
7
|
# @see http://docs.gurock.com/testrail-api2/reference-cases
|
42
|
-
def get_case(case_id)
|
43
|
-
send_get("get_case/#{case_id
|
8
|
+
def get_case(case_id, opts = nil)
|
9
|
+
send_get("get_case/#{case_id}", opts)
|
44
10
|
end
|
45
11
|
|
46
|
-
##########################++
|
47
|
-
####get_cases###############
|
48
|
-
############################
|
49
12
|
# Returns a list of test cases for a test suite or specific section in a test suite.
|
50
13
|
# @param project_id [int] The id of the project that contains your tests
|
51
14
|
# @param [Hash] opts
|
52
|
-
# @
|
53
|
-
#
|
54
|
-
# @option opts [unix timestamp] :created_after Only return test cases created after this date (as UNIX timestamp).
|
55
|
-
# @option opts [unix timestamp] :created_before Only return test cases created before this date (as UNIX timestamp).
|
56
|
-
# @option opts [int(list)] :created_by A comma-separated list of creators (user IDs) to filter by.
|
57
|
-
# @option opts [int(list)] :milestone_id A comma-separated list of milestone IDs to filter by (not available if the milestone field is disabled for the project).
|
58
|
-
# @option opts [int(list)] :priority_id A comma-separated list of priority IDs to filter by.
|
59
|
-
# @option opts [int(list)] :template_id A comma-separated list of template IDs to filter by (requires TestRail 5.2 or later)
|
60
|
-
# @option opts [int(list)] :type_id A comma-separated list of case type IDs to filter by.
|
61
|
-
# @option opts [unix timestamp] :updated_after Only return test cases updated after this date (as UNIX timestamp).
|
62
|
-
# @option opts [unix timestamp] :updated_before Only return test cases updated before this date (as UNIX timestamp).
|
63
|
-
# @option opts [int(list)] :updated_by A comma-separated list of users who updated test cases to filter by.
|
64
|
-
# @example Code Example
|
65
|
-
# @client.get_cases(1, {"suite_id":1, "section_id":1})
|
66
|
-
# @example Endpoint Example
|
67
|
-
# GET index.php?/api/v2/get_cases/1&suite_id=1§ion_id=1
|
68
|
-
# @example Response Example
|
69
|
-
# [
|
70
|
-
# { "id": 1, "title": "..", .. },
|
71
|
-
# { "id": 2, "title": "..", .. },
|
72
|
-
# ..
|
73
|
-
# ]
|
15
|
+
# @example Endpoint
|
16
|
+
# index.php?/api/v2/get_cases/:project_id
|
74
17
|
# @see http://docs.gurock.com/testrail-api2/reference-cases
|
75
|
-
def get_cases(project_id,
|
76
|
-
|
18
|
+
def get_cases(project_id, opts = {})
|
19
|
+
options = opts.to_a.map { |x| "#{x[0]}=#{x[1]}" }.join("&")
|
20
|
+
send_get("get_cases/#{project_id.to_s}&#{options}", opts)
|
77
21
|
end
|
78
22
|
|
79
|
-
##################deprecated
|
80
|
-
####get_cases_by_section####
|
81
|
-
############################
|
82
23
|
# Return all test cases in a given project by suite_id and section_id
|
83
|
-
# @
|
24
|
+
# @param project_id [int] The id of the project that contains your tests
|
25
|
+
# @param suite_id [int] The id of the suite within the project
|
26
|
+
# @param section_id [int] The id of the section within the suite
|
27
|
+
# @param [Hash] opts
|
28
|
+
# @example Endpoint
|
29
|
+
# index.php?/api/v2/get_cases/:project_id&suite_id=:suite_id§ion_id=:section_id
|
30
|
+
# @see http://docs.gurock.com/testrail-api2/reference-cases
|
84
31
|
def get_cases_by_section(project_id, suite_id, section_id, opts = {})
|
85
|
-
send_get("get_cases
|
32
|
+
send_get("get_cases/:#{project_id.to_s}&suite_id=:#{suite_id.to_s}§ion_id=:#{section_id.to_s}", opts)
|
86
33
|
end
|
87
34
|
|
88
|
-
##################deprecated
|
89
|
-
####get_cases_by_suite######
|
90
|
-
############################
|
91
35
|
# Return all test cases in a given project by suite_id
|
92
|
-
# @
|
36
|
+
# @param project_id [int] The id of the project that contains your tests
|
37
|
+
# @param suite_id [int] The id of the suite within the project
|
38
|
+
# @param [Hash] opts
|
39
|
+
# @example Endpoint
|
40
|
+
# index.php?/api/v2/get_cases/:project_id&suite_id=:suite_id
|
41
|
+
# @see http://docs.gurock.com/testrail-api2/reference-cases
|
93
42
|
def get_cases_by_suite(project_id, suite_id, opts = {})
|
94
|
-
send_get("get_cases
|
43
|
+
send_get("get_cases/:#{project_id.to_s}&suite_id=:#{suite_id.to_s}", opts)
|
95
44
|
end
|
96
45
|
|
97
|
-
############################
|
98
|
-
####add_case################
|
99
|
-
############################
|
100
46
|
# Creates a new test case
|
101
47
|
# @param section_id [int] The id of the test case
|
102
48
|
# @param [Hash] opts
|
103
|
-
# @
|
104
|
-
#
|
105
|
-
# @option opts [int] :type_id The ID of the case type
|
106
|
-
# @option opts [int] :priority_id The ID of the case priority
|
107
|
-
# @option opts [timespan] :estimate The estimate, e.g. "30s" or "1m 45s"
|
108
|
-
# @option opts [int] :milestone_id The ID of the milestone to link to the test case
|
109
|
-
# @option opts [string] :refs A comma-separated list of references/requirements
|
110
|
-
# @example Code Example
|
111
|
-
# @client.add_case(1, {"title":"testCaseName", "type_id":1})
|
112
|
-
# @example Endpoint Example
|
113
|
-
# index.php?/api/v2/add_case/1&title="foo"&type_id=1
|
49
|
+
# @example Endpoint
|
50
|
+
# index.php?/api/v2/add_case/:section_id
|
114
51
|
# @see http://docs.gurock.com/testrail-api2/reference-cases
|
115
52
|
def add_case(section_id, opts = {})
|
116
|
-
send_post("add_case
|
53
|
+
send_post("add_case/:#{section_id.to_s}", opts)
|
117
54
|
end
|
118
55
|
|
119
|
-
############################
|
120
|
-
####update_case#############
|
121
|
-
############################
|
122
56
|
# Update test result by case id
|
123
57
|
# @param case_id [int] The id of the test case
|
124
58
|
# @param [Hash] opts
|
125
|
-
# @example Endpoint
|
59
|
+
# @example Endpoint
|
126
60
|
# index.php?/api/v2/update_case/:case_id
|
127
61
|
# @see http://docs.gurock.com/testrail-api2/reference-cases
|
128
62
|
def update_case(case_id, opts = {})
|
129
63
|
send_post("update_case/:#{case_id.to_s}", opts)
|
130
64
|
end
|
131
65
|
|
132
|
-
############################
|
133
|
-
####delete_case################
|
134
|
-
############################
|
135
66
|
# Delete test case by case id
|
136
67
|
# @param case_id [int] The id of the test case
|
137
68
|
# @param [Hash] opts
|
138
|
-
# @example Endpoint
|
69
|
+
# @example Endpoint
|
139
70
|
# index.php?/api/v2/delete_case/:case_id
|
140
71
|
# @see http://docs.gurock.com/testrail-api2/reference-cases
|
141
72
|
def delete_case(case_id, opts = {})
|
142
73
|
send_post("delete_case/:#{case_id.to_s}", opts)
|
143
74
|
end
|
144
75
|
|
145
|
-
############################
|
146
|
-
####get_suite###############
|
147
|
-
############################
|
148
76
|
# Return suite by suite id
|
149
77
|
# @param suite_id [int] The suite id
|
150
78
|
# @param [Hash] opts
|
151
|
-
# @example Endpoint
|
79
|
+
# @example Endpoint
|
152
80
|
# index.php?/api/v2/get_suite/:suite_id
|
153
81
|
# @see http://docs.gurock.com/testrail-api2/reference-suites
|
154
82
|
def get_suite(suite_id, opts = {})
|
155
83
|
send_get("get_suite/:#{suite_id.to_s}", opts)
|
156
84
|
end
|
157
85
|
|
158
|
-
############################
|
159
|
-
####get_suites##############
|
160
|
-
############################
|
161
86
|
# Return all suites in project by project id
|
162
|
-
# @param project_id
|
87
|
+
# @param project_id [int] The id of the project containing suites
|
163
88
|
# @param [Hash] opts
|
164
|
-
# @example Endpoint
|
89
|
+
# @example Endpoint
|
165
90
|
# index.php?/api/v2/get_suites/:project_id
|
166
91
|
# @see http://docs.gurock.com/testrail-api2/reference-suites
|
167
92
|
def get_suites(project_id, opts = {})
|
168
93
|
send_get("get_suites/:#{project_id.to_s}", opts)
|
169
94
|
end
|
170
95
|
|
171
|
-
############################
|
172
|
-
####add_suite###############
|
173
|
-
############################
|
174
96
|
# Add a test suite
|
175
97
|
# @param project_id [int] The id of the project containing suites
|
176
98
|
# @param [Hash] opts
|
177
|
-
# @example Endpoint
|
99
|
+
# @example Endpoint
|
178
100
|
# index.php?/api/v2/add_suite/:project_id
|
179
101
|
# @see http://docs.gurock.com/testrail-api2/reference-suites
|
180
102
|
def add_suite(project_id, opts = {})
|
181
103
|
send_post("add_suite/:#{project_id.to_s}", opts)
|
182
104
|
end
|
183
105
|
|
184
|
-
############################
|
185
|
-
####update_suite############
|
186
|
-
############################
|
187
106
|
# update a test suite
|
188
107
|
# @param suite_id [int] The suite id
|
189
108
|
# @param [Hash] opts
|
190
|
-
# @example Endpoint
|
109
|
+
# @example Endpoint
|
191
110
|
# index.php?/api/v2/update_suite/:suite_id
|
192
111
|
# @see http://docs.gurock.com/testrail-api2/reference-suites
|
193
112
|
def update_suite(suite_id, opts = {})
|
194
113
|
send_post("update_suite/:#{suite_id.to_s}", opts)
|
195
114
|
end
|
196
115
|
|
197
|
-
############################
|
198
|
-
####delete_suite############
|
199
|
-
############################
|
200
116
|
# Delete a test suite
|
201
117
|
# @param suite_id [int] The suite id
|
202
118
|
# @param [Hash] opts
|
203
|
-
# @example Endpoint
|
119
|
+
# @example Endpoint
|
204
120
|
# index.php?/api/v2/delete_suite/:suite_id
|
205
121
|
# @see http://docs.gurock.com/testrail-api2/reference-suites
|
206
122
|
def delete_suite(suite_id, opts = {})
|
207
123
|
send_post("delete_suite/:#{suite_id.to_s}", opts)
|
208
124
|
end
|
209
125
|
|
210
|
-
|
211
|
-
############################
|
212
|
-
####get_section#############
|
213
|
-
############################
|
214
126
|
# Return section by id
|
215
127
|
# @param section_id [int]
|
216
128
|
# @param [Hash] opts
|
217
|
-
# @example Endpoint
|
129
|
+
# @example Endpoint
|
218
130
|
# index.php?/api/v2/get_section/:section_id
|
219
131
|
# @see http://docs.gurock.com/testrail-api2/reference-sections
|
220
132
|
def get_section(section_id, opts = {})
|
221
133
|
send_get("get_section/:#{section_id.to_s}", opts)
|
222
134
|
end
|
223
135
|
|
224
|
-
############################
|
225
|
-
####get_sections############
|
226
|
-
############################
|
227
136
|
# Get sections for suite
|
228
137
|
# @param suite_id [int]
|
229
138
|
# @param [Hash] opts
|
230
|
-
# @example Endpoint
|
139
|
+
# @example Endpoint
|
231
140
|
# index.php?/api/v2/get_sections/:project_id&suite_id=:suite_id
|
232
141
|
# @see http://docs.gurock.com/testrail-api2/reference-sections
|
233
142
|
def get_sections(project_id, suite_id, opts = {})
|
234
143
|
send_get("get_sections/#{project_id.to_s}&suite_id=#{suite_id.to_s}", opts)
|
235
144
|
end
|
236
145
|
|
237
|
-
############################
|
238
|
-
####add_section#############
|
239
|
-
############################
|
240
146
|
# Add section to suite
|
241
147
|
# @param project_id [int]
|
242
148
|
# @param [Hash] opts
|
243
149
|
# @option opts [Int] suite_id
|
244
150
|
# @option opts [String] name
|
245
151
|
# @option opts [Int] parent_id
|
246
|
-
# @example Endpoint
|
152
|
+
# @example Endpoint
|
247
153
|
# index.php?/api/v2/add_section/:project_id
|
248
|
-
# @example Code
|
154
|
+
# @example Code
|
249
155
|
# @client.add_section(1, {"suite_id": 5, "name": "This is a new section", "parent_id": 10})
|
250
156
|
# @see http://docs.gurock.com/testrail-api2/reference-sections
|
251
157
|
def add_section(project_id, opts = {})
|
252
158
|
send_post("add_section/#{project_id.to_s}", opts)
|
253
159
|
end
|
254
160
|
|
255
|
-
############################
|
256
|
-
####get_milestone###########
|
257
|
-
############################
|
258
161
|
# Get milestone by milestone id
|
259
162
|
# @param milestone_id [int]
|
260
163
|
# @param [Hash] opts
|
261
|
-
# @example Endpoint
|
164
|
+
# @example Endpoint
|
262
165
|
# index.php?/api/v2/get_milestone/:milestone_id
|
263
166
|
# @see http://docs.gurock.com/testrail-api2/reference-milestones
|
264
167
|
def get_milestone(milestone_id, opts = {})
|
265
168
|
send_get("get_milestone/:#{milestone_id.to_s}", opts)
|
266
169
|
end
|
267
170
|
|
268
|
-
############################
|
269
|
-
####get_milestones##########
|
270
|
-
############################
|
271
171
|
# Get project milestones by project id
|
272
172
|
# @param project_id [int]
|
273
173
|
# @param [Hash] opts
|
274
|
-
# @example Endpoint
|
174
|
+
# @example Endpoint
|
275
175
|
# index.php?/api/v2/get_milestones/:project_id
|
276
176
|
# @see http://docs.gurock.com/testrail-api2/reference-milestones
|
277
177
|
def get_milestones(project_id, opts = {})
|
278
178
|
send_get("get_milestones/:#{project_id.to_s}", opts)
|
279
179
|
end
|
280
180
|
|
281
|
-
############################
|
282
|
-
####add_milestone###########
|
283
|
-
############################
|
284
181
|
# Add milestone to project id
|
285
182
|
# @param project_id [int]
|
286
183
|
# @param [Hash] opts
|
287
|
-
# @example Endpoint
|
184
|
+
# @example Endpoint
|
288
185
|
# index.php?/api/v2/add_milestone/:project_id
|
289
186
|
# @see http://docs.gurock.com/testrail-api2/reference-milestones
|
290
187
|
def add_milestone(project_id, opts = {})
|
291
188
|
send_post("add_milestone/:#{project_id.to_s}", opts)
|
292
189
|
end
|
293
190
|
|
294
|
-
############################
|
295
|
-
####update_milestone########
|
296
|
-
############################
|
297
191
|
# Add milestone to project id
|
298
192
|
# @param milestone_id [int]
|
299
193
|
# @param [Hash] opts
|
300
|
-
# @example Endpoint
|
194
|
+
# @example Endpoint
|
301
195
|
# index.php?/api/v2/update_milestone/:milestone_id
|
302
196
|
# @see http://docs.gurock.com/testrail-api2/reference-milestones
|
303
197
|
def update_milestone(milestone_id, opts = {})
|
304
198
|
send_post("update_milestone/:#{milestone_id.to_s}", opts)
|
305
199
|
end
|
306
200
|
|
307
|
-
############################
|
308
|
-
####delete_milestone########
|
309
|
-
############################
|
310
201
|
# Add milestone to project id
|
311
202
|
# @param milestone_id [int]
|
312
203
|
# @param [Hash] opts
|
313
|
-
# @example Endpoint
|
204
|
+
# @example Endpoint
|
314
205
|
# index.php?/api/v2/delete_milestone/:milestone_id
|
315
206
|
# @see http://docs.gurock.com/testrail-api2/reference-milestones
|
316
207
|
def delete_milestone(milestone_id, opts = {})
|
317
208
|
send_post("delete_milestone/:#{milestone_id.to_s}", opts)
|
318
209
|
end
|
319
210
|
|
320
|
-
############################
|
321
|
-
####get_plan################
|
322
|
-
############################
|
323
211
|
# Get plan by id
|
324
212
|
# @param plan_id [int]
|
325
213
|
# @param [Hash] opts
|
326
|
-
# @example Endpoint
|
214
|
+
# @example Endpoint
|
327
215
|
# index.php?/api/v2/get_plan/:plan_id
|
328
216
|
# @see http://docs.gurock.com/testrail-api2/reference-plans
|
329
217
|
def get_plan(plan_id, opts = {})
|
330
218
|
send_get("get_plan/:#{plan_id.to_s}", opts)
|
331
219
|
end
|
332
220
|
|
333
|
-
############################
|
334
|
-
####get_plans###############
|
335
|
-
############################
|
336
221
|
# Get plans in project by project id
|
337
222
|
# @param project_id [int]
|
338
223
|
# @param [Hash] opts
|
339
|
-
# @example Endpoint
|
224
|
+
# @example Endpoint
|
340
225
|
# index.php?/api/v2/get_plans/:project_id
|
341
226
|
# @see http://docs.gurock.com/testrail-api2/reference-plans
|
342
227
|
def get_plans(project_id, opts = {})
|
343
228
|
send_get("get_plans/:#{project_id.to_s}", opts)
|
344
229
|
end
|
345
230
|
|
346
|
-
############################
|
347
|
-
####add_plan################
|
348
|
-
############################
|
349
231
|
# Add plan to project by project id
|
350
232
|
# @param project_id [int]
|
351
233
|
# @param [Hash] opts
|
352
|
-
# @example Endpoint
|
234
|
+
# @example Endpoint
|
353
235
|
# index.php?/api/v2/add_plan/:project_id
|
354
236
|
# @see http://docs.gurock.com/testrail-api2/reference-plans
|
355
237
|
def add_plan(project_id, opts = {})
|
356
238
|
send_post("add_plan/:#{project_id.to_s}", opts)
|
357
239
|
end
|
358
240
|
|
359
|
-
############################
|
360
|
-
####add_plan_entry##########
|
361
|
-
############################
|
362
241
|
# Add plan entries by plan id
|
363
242
|
# @param plan_id [int]
|
364
243
|
# @param [Hash] opts
|
365
|
-
# @example Endpoint
|
244
|
+
# @example Endpoint
|
366
245
|
# index.php?/api/v2/add_plan_entry/:plan_id
|
367
246
|
# @see http://docs.gurock.com/testrail-api2/reference-plans
|
368
247
|
def add_plan_entry(plan_id, opts = {})
|
369
248
|
send_post("add_plan_entry/:#{plan_id.to_s}", opts)
|
370
249
|
end
|
371
250
|
|
372
|
-
############################
|
373
|
-
####update_plan#############
|
374
|
-
############################
|
375
251
|
# Update plan by plan id
|
376
252
|
# @param plan_id [int]
|
377
253
|
# @param [Hash] opts
|
378
|
-
# @example Endpoint
|
254
|
+
# @example Endpoint
|
379
255
|
# index.php?/api/v2/update_plan/:plan_id
|
380
256
|
# @see http://docs.gurock.com/testrail-api2/reference-plans
|
381
257
|
def update_plan(plan_id, opts = {})
|
382
258
|
send_post("update_plan/:#{plan_id.to_s}", opts)
|
383
259
|
end
|
384
260
|
|
385
|
-
############################
|
386
|
-
####update_plan_entry#######
|
387
|
-
############################
|
388
261
|
# Update plan entry by plan id
|
389
262
|
# @param plan_id [int]
|
390
263
|
# @param entry_id [int] Id of entry
|
391
264
|
# @param [Hash] opts
|
392
|
-
# @example Endpoint
|
265
|
+
# @example Endpoint
|
393
266
|
# index.php?/api/v2/update_plan_entry/:plan_id/:entry_id
|
394
267
|
# @see http://docs.gurock.com/testrail-api2/reference-plans
|
395
268
|
def update_plan_entry(plan_id, entry_id, opts = {})
|
396
269
|
send_post("update_plan_entry/:#{plan_id.to_s}/:#{entry_id.to_s}", opts)
|
397
270
|
end
|
398
271
|
|
399
|
-
############################
|
400
|
-
####close_plan##############
|
401
|
-
############################
|
402
272
|
# Close plan by plan id
|
403
273
|
# @param plan_id [int]
|
404
274
|
# @param [Hash] opts
|
405
|
-
# @example Endpoint
|
275
|
+
# @example Endpoint
|
406
276
|
# index.php?/api/v2/close_plan/:plan_id
|
407
277
|
# @see http://docs.gurock.com/testrail-api2/reference-plans
|
408
278
|
def close_plan(plan_id, opts = {})
|
409
279
|
send_post("close_plan/:#{plan_id.to_s}", opts)
|
410
280
|
end
|
411
281
|
|
412
|
-
|
413
|
-
####delete_plan#############
|
414
|
-
############################
|
415
|
-
# @example Endpoint Example
|
282
|
+
# @example Endpoint
|
416
283
|
# index.php?/api/v2/delete_plan/:plan_id
|
417
284
|
# @see http://docs.gurock.com/testrail-api2/reference-plans
|
418
285
|
def delete_plan(plan_id, opts)
|
419
286
|
send_post("delete_plan/:#{plan_id.to_s}", opts)
|
420
287
|
end
|
421
288
|
|
422
|
-
|
423
|
-
####delete_plan_by_entry####
|
424
|
-
############################
|
425
|
-
# @example Endpoint Example
|
289
|
+
# @example Endpoint
|
426
290
|
# index.php?/api/v2/delete_plan_entry/:plan_id/:entry_id
|
427
291
|
def delete_plan_entry(plan_id, entry_id, opts = {})
|
428
292
|
send_post("delete_plan_entry/:#{plan_id.to_s}/:#{entry_id.to_s}", opts)
|
429
293
|
end
|
430
294
|
|
431
|
-
############################
|
432
|
-
####get_project#############
|
433
|
-
############################
|
434
295
|
# Get project by project id
|
435
296
|
# @param project_id [int]
|
436
297
|
# @param [Hash] opts
|
437
|
-
# @example Endpoint
|
298
|
+
# @example Endpoint
|
438
299
|
# index.php?/api/v2/get_project/:project_id
|
439
300
|
# @see http://docs.gurock.com/testrail-api2/reference-projects
|
440
301
|
def get_project(project_id, opts = {})
|
441
|
-
send_get("get_project
|
302
|
+
send_get("get_project/:#{project_id.to_s}", opts)
|
442
303
|
end
|
443
304
|
|
444
|
-
############################
|
445
|
-
####get_projects############
|
446
|
-
############################
|
447
305
|
# Get all projects
|
448
306
|
# @param [Hash] opts
|
449
|
-
# @example Endpoint
|
307
|
+
# @example Endpoint
|
450
308
|
# index.php?/api/v2/get_projects
|
451
309
|
# @see http://docs.gurock.com/testrail-api2/reference-projects
|
452
310
|
def get_projects(opts = {})
|
453
311
|
send_get('get_projects', opts)
|
454
312
|
end
|
455
313
|
|
456
|
-
############################
|
457
|
-
####add_project#############
|
458
|
-
############################
|
459
314
|
# Add a project
|
460
315
|
# @param [Hash] opts
|
461
|
-
# @example Endpoint
|
316
|
+
# @example Endpoint
|
462
317
|
# index.php?/api/v2/add_project
|
463
318
|
# @see http://docs.gurock.com/testrail-api2/reference-projects
|
464
319
|
def add_project(opts = {})
|
465
320
|
send_post("add_project", opts)
|
466
321
|
end
|
467
322
|
|
468
|
-
############################
|
469
|
-
####update_project##########
|
470
|
-
############################
|
471
323
|
# Update a project
|
472
324
|
# @param project_id [int] The project you want to update
|
473
325
|
# @param [Hash] opts
|
474
|
-
# @example Endpoint
|
326
|
+
# @example Endpoint
|
475
327
|
# index.php?/api/v2/update_project/:project_id
|
476
328
|
# @see http://docs.gurock.com/testrail-api2/reference-projects
|
477
329
|
def update_project(project_id, opts)
|
478
330
|
send_post("update_project/:#{project_id.to_s}", opts)
|
479
331
|
end
|
480
332
|
|
481
|
-
|
482
|
-
####delete_project##########
|
483
|
-
############################
|
333
|
+
|
484
334
|
# Delete a project
|
485
335
|
# @param project_id [int] The project you want to delete
|
486
336
|
# @param [Hash] opts
|
487
|
-
# @example Endpoint
|
337
|
+
# @example Endpoint
|
488
338
|
# index.php?/api/v2/delete_project/:project_id
|
489
339
|
# @see http://docs.gurock.com/testrail-api2/reference-projects
|
490
340
|
def delete_project(project_id, opts)
|
491
341
|
send_post("delete_project/:#{project_id.to_s}", opts)
|
492
342
|
end
|
493
343
|
|
494
|
-
############################
|
495
|
-
####get_results#############
|
496
|
-
############################
|
497
344
|
# Returns a list of test results for a test
|
498
345
|
# @param test_id [int]
|
499
346
|
# @param [Hash] opts
|
500
|
-
# @example Endpoint
|
347
|
+
# @example Endpoint
|
501
348
|
# index.php?/api/v2/get_results/:test_id
|
502
349
|
# @see http://docs.gurock.com/testrail-api2/reference-results
|
503
350
|
def get_results(test_id, opts = {})
|
504
351
|
send_get("get_results/:#{test_id.to_s}", opts)
|
505
352
|
end
|
506
353
|
|
507
|
-
############################
|
508
|
-
####get_results_for_case####
|
509
|
-
############################
|
510
354
|
# Returns a list of test results for a test run and case combination
|
511
355
|
# @param run_id [int]
|
512
356
|
# @param case_id [int]
|
513
357
|
# @param [Hash] opts
|
514
|
-
# @example Endpoint
|
358
|
+
# @example Endpoint
|
515
359
|
# index.php?/api/v2/get_results_for_case/:run_id/:case_id
|
516
360
|
# @see http://docs.gurock.com/testrail-api2/reference-results
|
517
361
|
def get_results_for_case(run_id, case_id, opts = {})
|
518
362
|
send_get("get_results_for_case/:#{run_id.to_s}/:#{case_id.to_s}", opts)
|
519
363
|
end
|
520
364
|
|
521
|
-
############################
|
522
|
-
####get_results_for_run#####
|
523
|
-
############################
|
524
365
|
# Returns a list of test results for a test run
|
525
366
|
# @param run_id [int]
|
526
367
|
# @param [Hash] opts
|
527
|
-
# @example Endpoint
|
368
|
+
# @example Endpoint
|
528
369
|
# index.php?/api/v2/get_results_for_run/:run_id
|
529
370
|
# @see http://docs.gurock.com/testrail-api2/reference-results
|
530
371
|
def get_results_for_run(run_id, opts = {})
|
531
372
|
send_get("get_results_for_run/:#{run_id.to_s}", opts)
|
532
373
|
end
|
533
374
|
|
534
|
-
############################
|
535
|
-
####add_result##############
|
536
|
-
############################
|
537
375
|
# Adds a new test result, comment or assigns a test. It's recommended to use add_results instead if you plan to add results for multiple tests.
|
538
376
|
# @param test_id [int]
|
539
377
|
# @param [Hash] opts
|
540
|
-
# @example Endpoint
|
378
|
+
# @example Endpoint
|
541
379
|
# index.php?/api/v2/add_result/:test_id
|
542
380
|
# @see http://docs.gurock.com/testrail-api2/reference-results
|
543
381
|
def add_result(test_id, opts = {})
|
544
382
|
send_post("add_result/:#{test_id.to_s}", opts)
|
545
383
|
end
|
546
384
|
|
547
|
-
############################
|
548
|
-
####add_result_for_case#####
|
549
|
-
############################
|
550
385
|
# Adds a new test result, comment or assigns a test (for a test run and case combination)
|
551
386
|
# @param run_id [int]
|
552
387
|
# @param case_id [int]
|
553
388
|
# @param [Hash] opts
|
554
|
-
# @example Endpoint
|
389
|
+
# @example Endpoint
|
555
390
|
# index.php?/api/v2/add_result_for_case/:run_id/:case_id
|
556
391
|
# @see http://docs.gurock.com/testrail-api2/reference-results
|
557
392
|
def add_result_for_case(run_id, case_id, opts = {})
|
558
393
|
send_post("add_result_for_case/:#{run_id.to_s}/:#{case_id.to_s}", opts)
|
559
394
|
end
|
560
395
|
|
561
|
-
############################
|
562
|
-
####add_results#############
|
563
|
-
############################
|
564
396
|
# Adds one or more new test results, comments or assigns one or more tests
|
565
397
|
# @param run_id [int]
|
566
398
|
# @param [Hash] opts
|
567
|
-
# @example Endpoint
|
399
|
+
# @example Endpoint
|
568
400
|
# index.php?/api/v2/add_results/:run_id
|
569
401
|
# @see http://docs.gurock.com/testrail-api2/reference-results
|
570
402
|
def add_results(run_id, opts = {})
|
571
403
|
send_post("add_results/:#{run_id.to_s}", opts)
|
572
404
|
end
|
573
405
|
|
574
|
-
############################
|
575
|
-
####add_results_for_cases###
|
576
|
-
############################
|
577
406
|
# Adds one or more new test results, comments or assigns one or more tests (using the case IDs)
|
578
407
|
# @param run_id [int]
|
579
408
|
# @param [Hash] opts
|
580
|
-
# @example Endpoint
|
409
|
+
# @example Endpoint
|
581
410
|
# index.php?/api/v2/add_results_for_cases/:run_id
|
582
411
|
# @see http://docs.gurock.com/testrail-api2/reference-results
|
583
412
|
def add_results_for_cases(run_id, opts = {})
|
584
413
|
send_post("add_results_for_cases/:#{run_id.to_s}", opts)
|
585
414
|
end
|
586
415
|
|
587
|
-
############################
|
588
|
-
####get_run#################
|
589
|
-
############################
|
590
416
|
# Get run by run id
|
591
417
|
# @param run_id [int]
|
592
418
|
# @param [Hash] opts
|
593
|
-
# @example Endpoint
|
419
|
+
# @example Endpoint
|
594
420
|
# index.php?/api/v2/get_run/:run_id
|
595
421
|
# @see http://docs.gurock.com/testrail-api2/reference-runs
|
596
422
|
def get_run(run_id, opts = {})
|
597
423
|
send_get("get_run/:#{run_id.to_s}", opts)
|
598
424
|
end
|
599
425
|
|
600
|
-
############################
|
601
|
-
####get_runs################
|
602
|
-
############################
|
603
426
|
# Get runs by project id
|
604
427
|
# @param project_id [int]
|
605
428
|
# @param plan_id [int]
|
606
429
|
# @param [Hash] opts
|
607
|
-
# @example Endpoint
|
430
|
+
# @example Endpoint
|
608
431
|
# index.php?/api/v2/get_runs/:project_id
|
609
432
|
# @see http://docs.gurock.com/testrail-api2/reference-runs
|
610
433
|
def get_runs(project_id, opts = {})
|
611
434
|
send_get("get_runs/#{project_id.to_s}", opts)
|
612
435
|
end
|
613
436
|
|
614
|
-
############################
|
615
|
-
####add_run#################
|
616
|
-
############################
|
617
437
|
# Add run by suite id
|
618
438
|
# @param project_id [int]
|
619
439
|
# @param [Hash] opts
|
620
|
-
# @example Endpoint
|
440
|
+
# @example Endpoint
|
621
441
|
# index.php?/api/v2/add_run/:project_id
|
622
442
|
# @see http://docs.gurock.com/testrail-api2/reference-runs
|
623
443
|
def add_run(project_id, opts = {})
|
624
444
|
send_post("add_run/:#{project_id.to_s}", opts)
|
625
445
|
end
|
626
446
|
|
627
|
-
############################
|
628
|
-
####update_run##############
|
629
|
-
############################
|
630
447
|
# Updates existing test run
|
631
448
|
# @param run_id [int]
|
632
449
|
# @param [Hash] opts
|
633
|
-
# @example Endpoint
|
450
|
+
# @example Endpoint
|
634
451
|
# index.php?/api/v2/update_run/:run_id
|
635
452
|
# @see http://docs.gurock.com/testrail-api2/reference-runs
|
636
453
|
def update_run(run_id, opts = {})
|
637
454
|
send_post("update_run/:#{run_id.to_s}", opts)
|
638
455
|
end
|
639
456
|
|
640
|
-
############################
|
641
|
-
####close_run###############
|
642
|
-
############################
|
643
457
|
# Closes an existing test run and archives its tests & results
|
644
458
|
# @param run_id [int]
|
645
459
|
# @param [Hash] opts
|
646
|
-
# @example Endpoint
|
460
|
+
# @example Endpoint
|
647
461
|
# index.php?/api/v2/close_run/:run_id
|
648
462
|
# @see http://docs.gurock.com/testrail-api2/reference-runs
|
649
463
|
def close_run(run_id, opts = {})
|
650
464
|
send_post("close_run/#{run_id.to_s}", opts)
|
651
465
|
end
|
652
466
|
|
653
|
-
############################
|
654
|
-
####delete_run##############
|
655
|
-
############################
|
656
467
|
# Deletes an existing test run.
|
657
468
|
# @param run_id [int]
|
658
469
|
# @param [Hash] opts
|
659
|
-
# @example Endpoint
|
470
|
+
# @example Endpoint
|
660
471
|
# index.php?/api/v2/delete_run/:run_id
|
661
472
|
# @see http://docs.gurock.com/testrail-api2/reference-runs
|
662
473
|
def delete_run(run_id, opts = {})
|
663
474
|
send_post("delete_run/:#{run_id.to_s}", opts)
|
664
475
|
end
|
665
476
|
|
666
|
-
############################
|
667
|
-
####get_test################
|
668
|
-
############################
|
669
477
|
# Returns an existing test
|
670
478
|
# @param test_id [int]
|
671
479
|
# @param [Hash] opts
|
672
|
-
# @example Endpoint
|
480
|
+
# @example Endpoint
|
673
481
|
# index.php?/api/v2/get_test/:test_id
|
674
482
|
# @see http://docs.gurock.com/testrail-api2/reference-tests
|
675
483
|
def get_test(test_id, opts = {})
|
676
484
|
send_get("get_test/:#{test_id.to_s}", opts)
|
677
485
|
end
|
678
486
|
|
679
|
-
############################
|
680
|
-
####get_tests###############
|
681
|
-
############################
|
682
487
|
# Returns a list of tests for a test run
|
683
488
|
# @param run_id [int]
|
684
489
|
# @param [Hash] opts
|
685
|
-
# @example Endpoint
|
490
|
+
# @example Endpoint
|
686
491
|
# index.php?/api/v2/get_tests/:run_id
|
687
492
|
# @see http://docs.gurock.com/testrail-api2/reference-tests
|
688
493
|
def get_tests(run_id, opts = {})
|
data/lib/testrail-ruby.rb
CHANGED
@@ -21,47 +21,23 @@ module TestRail
|
|
21
21
|
attr_accessor :password
|
22
22
|
|
23
23
|
def initialize(base_url)
|
24
|
-
|
25
|
-
base_url += '/'
|
26
|
-
end
|
24
|
+
base_url += '/' unless base_url =~ /\/$/
|
27
25
|
@url = base_url + 'index.php?/api/v2/'
|
28
26
|
end
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
#
|
33
|
-
# Issues a GET request (read) against the API and returns the result
|
34
|
-
# (as Ruby hash).
|
35
|
-
#
|
36
|
-
# Arguments:
|
37
|
-
#
|
38
|
-
# uri The API method to call including parameters
|
39
|
-
# (e.g. get_case/1)
|
40
|
-
#
|
41
|
-
def send_get(uri)
|
42
|
-
_send_request('GET', uri, nil)
|
28
|
+
def send_get(uri, data)
|
29
|
+
_send_request('GET', uri, data)
|
43
30
|
end
|
44
31
|
|
45
|
-
#
|
46
|
-
# Send POST
|
47
|
-
#
|
48
|
-
# Issues a POST request (write) against the API and returns the result
|
49
|
-
# (as Ruby hash).
|
50
|
-
#
|
51
|
-
# Arguments:
|
52
|
-
#
|
53
|
-
# uri The API method to call including parameters
|
54
|
-
# (e.g. add_case/1)
|
55
|
-
# data The data to submit as part of the request (as
|
56
|
-
# Ruby hash, strings must be UTF-8 encoded)
|
57
|
-
#
|
58
32
|
def send_post(uri, data)
|
59
33
|
_send_request('POST', uri, data)
|
60
34
|
end
|
61
35
|
|
62
36
|
private
|
37
|
+
|
63
38
|
def _send_request(method, uri, data)
|
64
39
|
url = URI.parse(@url + uri)
|
40
|
+
puts "URL: #{url}"
|
65
41
|
if method == 'POST'
|
66
42
|
request = Net::HTTP::Post.new(url.path + '?' + url.query)
|
67
43
|
request.body = JSON.dump(data)
|
@@ -78,20 +54,20 @@ module TestRail
|
|
78
54
|
end
|
79
55
|
response = conn.request(request)
|
80
56
|
|
81
|
-
if response.body && !response.body.empty?
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
57
|
+
result = if response.body && !response.body.empty?
|
58
|
+
JSON.parse(response.body)
|
59
|
+
else
|
60
|
+
{}
|
61
|
+
end
|
86
62
|
|
87
63
|
if response.code != '200'
|
88
|
-
if result && result.key?('error')
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
raise APIError
|
94
|
-
|
64
|
+
error = if result && result.key?('error')
|
65
|
+
'"' + result['error'] + '"'
|
66
|
+
else
|
67
|
+
'No additional error message received'
|
68
|
+
end
|
69
|
+
raise APIError, 'TestRail API returned HTTP %s (%s)' %
|
70
|
+
[response.code, error]
|
95
71
|
end
|
96
72
|
|
97
73
|
result
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testrail-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frances Morales
|
@@ -105,7 +105,6 @@ files:
|
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
107
|
- lib/endpoints.rb
|
108
|
-
- lib/testrail-ruby-broken.rb
|
109
108
|
- lib/testrail-ruby.rb
|
110
109
|
- lib/version.rb
|
111
110
|
- spec/spec_helper.rb
|
data/lib/testrail-ruby-broken.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
require_relative 'version'
|
2
|
-
require_relative 'endpoints'
|
3
|
-
require 'net/http'
|
4
|
-
require 'net/https'
|
5
|
-
require 'uri'
|
6
|
-
require 'json'
|
7
|
-
|
8
|
-
## #USAGE:
|
9
|
-
## #@client = TestRail::APIClient.new('YourBaseURLHere')
|
10
|
-
## #@client.user = 'UserName'
|
11
|
-
## #@client.password = 'Password'
|
12
|
-
|
13
|
-
module TestRail
|
14
|
-
class APIClient
|
15
|
-
@url = ''
|
16
|
-
@user = ''
|
17
|
-
@password = ''
|
18
|
-
|
19
|
-
include Endpoints
|
20
|
-
attr_accessor :user
|
21
|
-
attr_accessor :password
|
22
|
-
|
23
|
-
def initialize(base_url)
|
24
|
-
base_url += '/' unless base_url =~ /\/$/
|
25
|
-
@url = base_url + 'index.php?/api/v2/'
|
26
|
-
end
|
27
|
-
|
28
|
-
def send_get(uri, data)
|
29
|
-
puts "Getting: #{uri}"
|
30
|
-
puts "Sending Data: #{data}"
|
31
|
-
_send_request('GET', uri, data)
|
32
|
-
end
|
33
|
-
|
34
|
-
def send_post(uri, data)
|
35
|
-
puts "Posting: #{uri}"
|
36
|
-
puts "Sending Data: #{data}"
|
37
|
-
_send_request('POST', uri, data)
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def _send_request(method, uri, data)
|
43
|
-
url = URI.parse(@url + uri)
|
44
|
-
puts "URL: #{url}"
|
45
|
-
puts "url.query: #{url.query}"
|
46
|
-
puts "Data Payload: #{data}"
|
47
|
-
if method == 'POST'
|
48
|
-
request = Net::HTTP::Post.new(url.path + '?' + url.query)
|
49
|
-
request.body = JSON.dump(data)
|
50
|
-
else
|
51
|
-
request = Net::HTTP::Get.new(url.path + '?' + url.query)
|
52
|
-
end
|
53
|
-
request.basic_auth(@user, @password)
|
54
|
-
request.add_field('Content-Type', 'application/json')
|
55
|
-
|
56
|
-
conn = Net::HTTP.new(url.host, url.port)
|
57
|
-
if url.scheme == 'https'
|
58
|
-
conn.use_ssl = true
|
59
|
-
conn.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
60
|
-
end
|
61
|
-
response = conn.request(request)
|
62
|
-
|
63
|
-
result = if response.body && !response.body.empty?
|
64
|
-
JSON.parse(response.body)
|
65
|
-
else
|
66
|
-
{}
|
67
|
-
end
|
68
|
-
|
69
|
-
if response.code != '200'
|
70
|
-
error = if result && result.key?('error')
|
71
|
-
'"' + result['error'] + '"'
|
72
|
-
else
|
73
|
-
'No additional error message received'
|
74
|
-
end
|
75
|
-
raise APIError, 'TestRail API returned HTTP %s (%s)' %
|
76
|
-
[response.code, error]
|
77
|
-
end
|
78
|
-
|
79
|
-
result
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
class APIError < StandardError
|
84
|
-
end
|
85
|
-
end
|