test_rail-api 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/test_rail/api.rb +61 -11
- data/lib/test_rail/project.rb +29 -0
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4196384451523f5e9c7da96179d59e6999e28058
|
4
|
+
data.tar.gz: 90eade64f69d32450158006537e85c2ffeab999d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76c104fae09342eef31e96e0bb1d6a941fed07352eb5b0b898478d2ac5e7a2d984928c0fc85d3de68032a17f8878659a9396efd4144325eb39206c5bc882c601
|
7
|
+
data.tar.gz: f41459a4157ea7c91d6af3569cbebbd04b826fa8c9fa45fc65d74ecfce47a751daec9ad25908ad7004d653e3a1668dd8e8cc8a77c47ece3b479e32ae895e854b
|
data/lib/test_rail/api.rb
CHANGED
@@ -65,6 +65,53 @@ module TestRail
|
|
65
65
|
return projectexists
|
66
66
|
end
|
67
67
|
|
68
|
+
#
|
69
|
+
# Plan API calls
|
70
|
+
#
|
71
|
+
|
72
|
+
# Add a new plan
|
73
|
+
# (If plan already exists, a new one is created with the same name)
|
74
|
+
# api.add_plan( :project_id => 1, :name => 'My new Plan', :description => 'Test Plan' )
|
75
|
+
# Returns the plan object
|
76
|
+
def add_plan(args)
|
77
|
+
project_id = args[:project_id] or raise 'Missing project id (:project_id => 1)'
|
78
|
+
name = args[:name] or raise 'Missing plan name (:name => "My Test Plan")'
|
79
|
+
description = args[:description]
|
80
|
+
|
81
|
+
plan = post('add_plan', [project_id], { :name => name, :description => description })
|
82
|
+
TestRail::Plan.new(plan.merge({ :api => self }))
|
83
|
+
end
|
84
|
+
|
85
|
+
# Get a list of plans for a project
|
86
|
+
# api.get_plans( :project_id => 1 )
|
87
|
+
# Returns a list of plan objects
|
88
|
+
def get_plans(args)
|
89
|
+
id = args[:project_id] or raise "Missing project id (:project_id => 1)"
|
90
|
+
list = get('get_plans', [id])
|
91
|
+
list.collect do |item|
|
92
|
+
TestRail::Plan.new(item.merge({ :api => self }))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Given a plan id, returns a plan (and populates internal run objects)
|
97
|
+
def get_plan(args)
|
98
|
+
plan_id = args[:plan_id] or raise "Missing plan id (:plan_id => 1)"
|
99
|
+
result = get('get_plan', [plan_id])
|
100
|
+
raw_runs = result['entries'].collect { |e| e['runs'] }.flatten
|
101
|
+
runs = raw_runs.each.collect { |r| TestRail::Run.new(r.merge({ :api => self })) }
|
102
|
+
plan = TestRail::Plan.new(result.merge({ :api => self, :runs => runs }))
|
103
|
+
plan
|
104
|
+
end
|
105
|
+
|
106
|
+
def update_plan(args)
|
107
|
+
id = args[:id] or raise "Missing plan id (:id => 1)"
|
108
|
+
name = args[:name]
|
109
|
+
description = args[:description]
|
110
|
+
|
111
|
+
plan = post('update_plan', [id], { :name => name, :description => description })
|
112
|
+
TestRail::Plan.new(plan.merge({ :api => self }))
|
113
|
+
end
|
114
|
+
|
68
115
|
#
|
69
116
|
# Suite API calls
|
70
117
|
#
|
@@ -243,18 +290,21 @@ module TestRail
|
|
243
290
|
TestRail::Run.new(result.merge({ :api => self }))
|
244
291
|
end
|
245
292
|
|
246
|
-
#
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
raw_runs = result['entries'].collect { |e| e['runs'] }.flatten
|
253
|
-
runs = raw_runs.each.collect { |r| TestRail::Run.new(r.merge({ :api => self })) }
|
254
|
-
|
255
|
-
plan = TestRail::Plan.new(result.merge({ :api => self, :runs => runs }))
|
293
|
+
# Add a new run in test plan
|
294
|
+
# api.add_run_in_plan( :project_id => project_id, :plan_id => plan_id, :suite_id => suite_id )
|
295
|
+
def add_run_in_plan(args)
|
296
|
+
project_id = args[:project_id] or raise "Missing project id ( :project_id => 1)"
|
297
|
+
plan_id = args[:plan_id] or raise "Missing project id ( :project_id => 1)"
|
298
|
+
suite_id = args[:suite_id] or raise "Missing suite id ( :suite_id => 1)"
|
256
299
|
|
257
|
-
|
300
|
+
params = {
|
301
|
+
:project_id => project_id,
|
302
|
+
:suite_id => suite_id,
|
303
|
+
:name => args[:name],
|
304
|
+
:description => args[:description]
|
305
|
+
}
|
306
|
+
result = post('add_plan_entry', [plan_id], params)["runs"][0]
|
307
|
+
TestRail::Run.new(result.merge({ :api => self }))
|
258
308
|
end
|
259
309
|
|
260
310
|
def get_tests(args)
|
data/lib/test_rail/project.rb
CHANGED
@@ -16,6 +16,12 @@ module TestRail
|
|
16
16
|
@api.get_suites( :project_id => @id )
|
17
17
|
end
|
18
18
|
|
19
|
+
# Return a list of plans belonging to this project
|
20
|
+
def plans
|
21
|
+
@api.get_plans( :project_id => @id )
|
22
|
+
end
|
23
|
+
|
24
|
+
|
19
25
|
# Create a new suite for this project
|
20
26
|
def new_suite( args )
|
21
27
|
@api.add_suite( args.merge({:project_id => id}) )
|
@@ -28,6 +34,19 @@ module TestRail
|
|
28
34
|
suites.select{ |s| s.name == name }.first
|
29
35
|
end
|
30
36
|
|
37
|
+
# Create a new plan for this project
|
38
|
+
def new_plan( args )
|
39
|
+
@api.add_plan( args.merge({:project_id => id}) )
|
40
|
+
end
|
41
|
+
|
42
|
+
# Find a plan in this project based on the plan name
|
43
|
+
# project.find_plan( :name => "My Plan" )
|
44
|
+
def find_plan( args )
|
45
|
+
name = args[:name] or raise "Need to provide the name of plan"
|
46
|
+
plans.select{ |s| s.name == name }.first
|
47
|
+
end
|
48
|
+
|
49
|
+
|
31
50
|
# Find or create a suite in this project based on the suite name
|
32
51
|
# project.find_or_create_suite( :name => "My Suite" )
|
33
52
|
def find_or_create_suite( args )
|
@@ -38,5 +57,15 @@ module TestRail
|
|
38
57
|
end
|
39
58
|
suite
|
40
59
|
end
|
60
|
+
|
61
|
+
def find_or_create_plan( args )
|
62
|
+
name =args[:name] or raise "Need to provide name of plan"
|
63
|
+
plan = self.find_plan( args )
|
64
|
+
if plan.nil?
|
65
|
+
plan = new_plan( args )
|
66
|
+
end
|
67
|
+
plan
|
68
|
+
end
|
69
|
+
|
41
70
|
end
|
42
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_rail-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BBC
|
@@ -108,9 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.6.8
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Test Rail API
|
115
115
|
test_files: []
|
116
|
-
has_rdoc:
|