onlyoffice_testrail_wrapper 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7cdb9209303106828ac8d2628bdfbd6243b0b66cbf9e57f8d1c3d506a29d0af
4
- data.tar.gz: 54ad089da3f905190dc4b33784fbfc665faa725d865f0b28d77f034e4766b08e
3
+ metadata.gz: 161af1b6e6f06e66270943b7c6d3fc72d7afd3a89af0b0811c507423f87fd3d5
4
+ data.tar.gz: e4ae37a550ac9850354d22407045bd54df2d76fe3b6fb2214c0092e3ecf4618e
5
5
  SHA512:
6
- metadata.gz: 86813255438a058617f52e431bd1465fe1a2aba8397dc62cd41efc51fc270c22c271a3c0e6a8c59645540896b8842eab77ce53a3614048f7d7f4da9016615ce1
7
- data.tar.gz: e198cc8aa5f2b5c537ee36ff4e30c03ebb262a0485f7852d12f4ef333ce3f751e9046df74a1a842221f9e5b17358afc55ef2ea73f92d64099dbdf368e8655072
6
+ metadata.gz: b017d8b8d9080189d9983f84feb4e4f079474607131b3aad1b8694da51624981594065fcc726337a14be748d437e0a26b56c8c630deb530cab1ad09a33c69e83
7
+ data.tar.gz: 2b87d5d15d003072ccf3809473ea6055834090f539b02a8182ad9de3ef68be40c7a6955f9077edd8e338e8c2cb79a635d00e8ed0350089c72b98ca821b278495
@@ -90,7 +90,7 @@ module OnlyofficeTestrailWrapper
90
90
  # @param [String] request_url to perform http get
91
91
  # @param [Hash] data_hash headers to add to post query
92
92
  # @return [Hash] Json with result data in hash form
93
- def http_post(request_url, data_hash)
93
+ def http_post(request_url, data_hash = {})
94
94
  uri = URI get_testrail_address + request_url
95
95
  request = Net::HTTP::Post.new uri.request_uri
96
96
  request.body = data_hash.to_json
@@ -18,6 +18,8 @@ module OnlyofficeTestrailWrapper
18
18
  attr_accessor :milestone_id
19
19
  # @return [True, False] Completed this test plan or not
20
20
  attr_accessor :is_completed
21
+ # @return [Integer] time since epoch on which plan created
22
+ attr_reader :created_on
21
23
  # @return [String] url to current test plan
22
24
  attr_reader :url
23
25
 
@@ -41,12 +43,22 @@ module OnlyofficeTestrailWrapper
41
43
  Testrail2.http_post "index.php?/api/v2/delete_plan_entry/#{@id}/#{entry_id}", {}
42
44
  end
43
45
 
46
+ # Delete current plan
47
+ # @return [nil]
44
48
  def delete
45
49
  Testrail2.http_post "index.php?/api/v2/delete_plan/#{@id}", {}
46
50
  OnlyofficeLoggerHelper.log "Deleted plan: #{@name}"
47
51
  nil
48
52
  end
49
53
 
54
+ # Close current plan
55
+ # @return [nil]
56
+ def close
57
+ Testrail2.http_post("index.php?/api/v2/close_plan/#{@id}")
58
+ OnlyofficeLoggerHelper.log("Closed plan: #{@name} with id #{@id}")
59
+ nil
60
+ end
61
+
50
62
  def tests_results
51
63
  run_results = {}
52
64
  @entries.each do |current_entrie|
@@ -4,13 +4,21 @@ require_relative 'testrail_suite'
4
4
  require_relative 'testrail_run'
5
5
  require_relative 'testrail_plan'
6
6
  require_relative 'testrail_milestone'
7
+ require_relative 'testrail_project/project_cleanup'
8
+ require_relative 'testrail_project/testrail_project_milestone_methods'
7
9
  require_relative 'testrail_project/testrail_project_plan_helper'
10
+ require_relative 'testrail_project/testrail_project_runs_methods'
11
+ require_relative 'testrail_project/testrail_project_suite_methods'
8
12
 
9
13
  module OnlyofficeTestrailWrapper
10
14
  # @author Roman.Zagudaev
11
15
  # Class for working with Test Projects
12
16
  class TestrailProject
17
+ include ProjectCleanup
18
+ include TestrailProjectMilestoneMethods
13
19
  include TestrailProjectPlanHelper
20
+ include TestrailProjectRunMethods
21
+ include TestrailProjectSuiteMethods
14
22
  # @return [Integer] Id of project
15
23
  attr_accessor :id
16
24
  # @return [String] Name of project
@@ -66,162 +74,5 @@ module OnlyofficeTestrailWrapper
66
74
  OnlyofficeLoggerHelper.log "Deleted project: #{@name}"
67
75
  @testrail.projects_names.delete @name
68
76
  end
69
-
70
- # region: SUITE
71
-
72
- def suite(name_or_id)
73
- case name_or_id.class.to_s
74
- when 'Fixnum'
75
- get_suite_by_id name_or_id
76
- when 'String'
77
- init_suite_by_name name_or_id
78
- else
79
- raise 'Wrong argument. Must be name [String] or id [Integer]'
80
- end
81
- end
82
-
83
- # Get all test runs of project
84
- # @return [Array, TestrailSuite] array with runs
85
- def get_suites
86
- suites = Testrail2.http_get("index.php?/api/v2/get_suites/#{@id}")
87
- @suites_names = HashHelper.get_hash_from_array_with_two_parameters(suites, 'name', 'id') if @suites_names.empty?
88
- suites
89
- end
90
-
91
- # Get Test Suite by it's name
92
- # @param [String] name name of test suite
93
- # @return [TestrailSuite] test suite
94
- def get_suite_by_name(name)
95
- get_suites if @suites_names.empty?
96
- @suites_names[StringHelper.warnstrip!(name)].nil? ? nil : get_suite_by_id(@suites_names[name])
97
- end
98
-
99
- def get_suite_by_id(id)
100
- suite = HashHelper.parse_to_class_variable(Testrail2.http_get("index.php?/api/v2/get_suite/#{id}"), TestrailSuite)
101
- suite.instance_variable_set('@project', self)
102
- OnlyofficeLoggerHelper.log("Initialized suite: #{suite.name}")
103
- suite
104
- end
105
-
106
- # Init suite by it's name
107
- # @param [String] name name of suit
108
- # @return [TestrailSuite] suite with this name
109
- def init_suite_by_name(name)
110
- found_suite = get_suite_by_name name
111
- found_suite.nil? ? create_new_suite(name) : found_suite
112
- end
113
-
114
- # Create new test suite in project
115
- # @param [String] name name of suite
116
- # @param [String] description description of suite (default = nil)
117
- # @return [TestrailSuite] created suite
118
- def create_new_suite(name, description = '')
119
- new_suite = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_suite/#{@id}", name: StringHelper.warnstrip!(name), description: description), TestrailSuite)
120
- new_suite.instance_variable_set('@project', self)
121
- OnlyofficeLoggerHelper.log "Created new suite: #{new_suite.name}"
122
- @suites_names[new_suite.name] = new_suite.id
123
- new_suite
124
- end
125
-
126
- # endregion
127
-
128
- # region: RUN
129
-
130
- def test_run(name_or_id)
131
- case name_or_id.class.to_s
132
- when 'Fixnum'
133
- get_run_by_id name_or_id
134
- when 'String'
135
- init_run_by_name name_or_id
136
- else
137
- raise 'Wrong argument. Must be name [String] or id [Integer]'
138
- end
139
- end
140
-
141
- # Get all test runs of project
142
- # @return [Array, TestRunTestrail] array of test runs
143
- def get_runs(filters = {})
144
- get_url = "index.php?/api/v2/get_runs/#{@id}"
145
- filters.each { |key, value| get_url += "&#{key}=#{value}" }
146
- runs = Testrail2.http_get(get_url)
147
- @runs_names = HashHelper.get_hash_from_array_with_two_parameters(runs, 'name', 'id') if @runs_names.empty?
148
- runs
149
- end
150
-
151
- # Get Test Run by it's name
152
- # @param [String] name name of test run
153
- # @return [TestRunTestRail] test run
154
- def get_run_by_name(name)
155
- get_runs if @runs_names.empty?
156
- @runs_names[StringHelper.warnstrip!(name)].nil? ? nil : get_run_by_id(@runs_names[name])
157
- end
158
-
159
- def get_run_by_id(id)
160
- run = HashHelper.parse_to_class_variable(Testrail2.http_get("index.php?/api/v2/get_run/#{id}"), TestrailRun)
161
- OnlyofficeLoggerHelper.log("Initialized run: #{run.name}")
162
- run.instance_variable_set('@project', self)
163
- run
164
- end
165
-
166
- def init_run_by_name(name, suite_id = nil)
167
- found_run = get_run_by_name name
168
- suite_id = get_suite_by_name(name).id if suite_id.nil?
169
- found_run.nil? ? create_new_run(name, suite_id) : found_run
170
- end
171
-
172
- def create_new_run(name, suite_id, description = '')
173
- new_run = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_run/#{@id}", name: StringHelper.warnstrip!(name), description: description, suite_id: suite_id), TestrailRun)
174
- OnlyofficeLoggerHelper.log "Created new run: #{new_run.name}"
175
- new_run.instance_variable_set('@project', self)
176
- @runs_names[new_run.name] = new_run.id
177
- new_run
178
- end
179
-
180
- # endregion
181
-
182
- # region: MILESTONE
183
-
184
- def milestone(name_or_id)
185
- case name_or_id.class.to_s
186
- when 'Fixnum'
187
- get_milestone_by_id name_or_id
188
- when 'String'
189
- init_milestone_by_name name_or_id
190
- else
191
- raise 'Wrong argument. Must be name [String] or id [Integer]'
192
- end
193
- end
194
-
195
- def init_milestone_by_name(name)
196
- found_milestone = get_milestone_by_name name
197
- found_milestone.nil? ? create_new_milestone(name) : found_milestone
198
- end
199
-
200
- def get_milestone_by_id(id)
201
- milestone = HashHelper.parse_to_class_variable(Testrail2.http_get("index.php?/api/v2/get_milestone/#{id}"), TestrailMilestone)
202
- OnlyofficeLoggerHelper.log("Initialized milestone: #{milestone.name}")
203
- milestone
204
- end
205
-
206
- def get_milestone_by_name(name)
207
- get_milestones if @milestones_names.empty?
208
- @milestones_names[StringHelper.warnstrip!(name.to_s)].nil? ? nil : get_milestone_by_id(@milestones_names[name])
209
- end
210
-
211
- def get_milestones
212
- milestones = Testrail2.http_get("index.php?/api/v2/get_milestones/#{@id}")
213
- @milestones_names = HashHelper.get_hash_from_array_with_two_parameters(milestones, 'name', 'id') if @milestones_names.empty?
214
- milestones
215
- end
216
-
217
- # @param [String] name of milestone
218
- # @param [String] description of milestone
219
- def create_new_milestone(name, description = '')
220
- new_milestone = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_milestone/#{@id}", :name => StringHelper.warnstrip!(name.to_s), description => description), TestrailMilestone)
221
- OnlyofficeLoggerHelper.log "Created new milestone: #{new_milestone.name}"
222
- new_milestone
223
- end
224
-
225
- # endregion
226
77
  end
227
78
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OnlyofficeTestrailWrapper
4
+ # Methods to perform project cleanup
5
+ module ProjectCleanup
6
+ # Close old runs in project, older than days count
7
+ # @param [Integer] days_old to close
8
+ # @return [nil]
9
+ def close_old_runs(days_old = 2)
10
+ OnlyofficeLoggerHelper.log("Going to close runs for #{name}, days old: #{days_old}")
11
+ runs = runs_older_than_days(days_old)
12
+ OnlyofficeLoggerHelper.log("Old runs number: #{runs.size} for #{name}, days old: #{days_old}")
13
+ runs.each(&:close)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OnlyofficeTestrailWrapper
4
+ # Methods to perform operations on milestones
5
+ module TestrailProjectMilestoneMethods
6
+ def milestone(name_or_id)
7
+ case name_or_id.class.to_s
8
+ when 'Fixnum'
9
+ get_milestone_by_id name_or_id
10
+ when 'String'
11
+ init_milestone_by_name name_or_id
12
+ else
13
+ raise 'Wrong argument. Must be name [String] or id [Integer]'
14
+ end
15
+ end
16
+
17
+ def init_milestone_by_name(name)
18
+ found_milestone = get_milestone_by_name name
19
+ found_milestone.nil? ? create_new_milestone(name) : found_milestone
20
+ end
21
+
22
+ def get_milestone_by_id(id)
23
+ milestone = HashHelper.parse_to_class_variable(Testrail2.http_get("index.php?/api/v2/get_milestone/#{id}"), TestrailMilestone)
24
+ OnlyofficeLoggerHelper.log("Initialized milestone: #{milestone.name}")
25
+ milestone
26
+ end
27
+
28
+ def get_milestone_by_name(name)
29
+ get_milestones if @milestones_names.empty?
30
+ @milestones_names[StringHelper.warnstrip!(name.to_s)].nil? ? nil : get_milestone_by_id(@milestones_names[name])
31
+ end
32
+
33
+ def get_milestones
34
+ milestones = Testrail2.http_get("index.php?/api/v2/get_milestones/#{@id}")
35
+ @milestones_names = HashHelper.get_hash_from_array_with_two_parameters(milestones, 'name', 'id') if @milestones_names.empty?
36
+ milestones
37
+ end
38
+
39
+ # @param [String] name of milestone
40
+ # @param [String] description of milestone
41
+ def create_new_milestone(name, description = '')
42
+ new_milestone = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_milestone/#{@id}", :name => StringHelper.warnstrip!(name.to_s), description => description), TestrailMilestone)
43
+ OnlyofficeLoggerHelper.log "Created new milestone: #{new_milestone.name}"
44
+ new_milestone
45
+ end
46
+ end
47
+ end
@@ -36,9 +36,18 @@ module OnlyofficeTestrailWrapper
36
36
  @plans_names[StringHelper.warnstrip!(name.to_s)].nil? ? nil : get_plan_by_id(@plans_names[name])
37
37
  end
38
38
 
39
+ extend Gem::Deprecate
40
+ deprecate :get_plan_by_name, 'plan_by_name', 2069, 1
41
+
42
+ # @param [String] name of plan
43
+ # @return [TestrailPlan, nil] result of plan search
44
+ def plan_by_name(name)
45
+ plans.find { |plan| plan.name == name }
46
+ end
47
+
39
48
  # Get list of all TestPlans
40
49
  # @param filters [Hash] filter conditions
41
- # @return [Array, TestrailPlan] test plans
50
+ # @return [Array<Hash>] test plans
42
51
  def get_plans(filters = {})
43
52
  get_url = "index.php?/api/v2/get_plans/#{@id}"
44
53
  filters.each { |key, value| get_url += "&#{key}=#{value}" }
@@ -47,6 +56,19 @@ module OnlyofficeTestrailWrapper
47
56
  plans
48
57
  end
49
58
 
59
+ extend Gem::Deprecate
60
+ deprecate :get_plans, 'plans', 2069, 1
61
+
62
+ # Get list of all TestPlans
63
+ # @param filters [Hash] filter conditions
64
+ # @return [Array<TestrailPlan>] test plans
65
+ def plans(filters = {})
66
+ get_url = "index.php?/api/v2/get_plans/#{@id}"
67
+ filters.each { |key, value| get_url += "&#{key}=#{value}" }
68
+ plans = Testrail2.http_get(get_url)
69
+ plans.map { |suite| HashHelper.parse_to_class_variable(suite, TestrailPlan) }
70
+ end
71
+
50
72
  # @param [String] name of test plan
51
73
  # @param [String] description
52
74
  # @param [Integer] milestone_id
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OnlyofficeTestrailWrapper
4
+ # Methods to perform operations on Runs
5
+ module TestrailProjectRunMethods
6
+ def test_run(name_or_id)
7
+ case name_or_id.class.to_s
8
+ when 'Fixnum'
9
+ get_run_by_id name_or_id
10
+ when 'String'
11
+ init_run_by_name name_or_id
12
+ else
13
+ raise 'Wrong argument. Must be name [String] or id [Integer]'
14
+ end
15
+ end
16
+
17
+ # Get all test runs of project
18
+ # @return [Array<Hash>] array of test runs
19
+ def get_runs(filters = {})
20
+ get_url = "index.php?/api/v2/get_runs/#{@id}"
21
+ filters.each { |key, value| get_url += "&#{key}=#{value}" }
22
+ runs = Testrail2.http_get(get_url)
23
+ @runs_names = HashHelper.get_hash_from_array_with_two_parameters(runs, 'name', 'id') if @runs_names.empty?
24
+ runs
25
+ end
26
+
27
+ # Get all test runs of project as objects
28
+ # @param [Hash] filters to apply
29
+ # @return [Array<TestrailRun>] array of test runs
30
+ def runs(filters = {})
31
+ get_url = "index.php?/api/v2/get_runs/#{@id}"
32
+ filters.each { |key, value| get_url += "&#{key}=#{value}" }
33
+ runs = Testrail2.http_get(get_url)
34
+ runs.map { |suite| HashHelper.parse_to_class_variable(suite, TestrailRun) }
35
+ end
36
+
37
+ extend Gem::Deprecate
38
+ deprecate :get_runs, 'runs', 2069, 1
39
+
40
+ # Get Test Run by it's name
41
+ # @param [String] name name of test run
42
+ # @return [TestRunTestRail] test run
43
+ def get_run_by_name(name)
44
+ get_runs if @runs_names.empty?
45
+ @runs_names[StringHelper.warnstrip!(name)].nil? ? nil : get_run_by_id(@runs_names[name])
46
+ end
47
+
48
+ def get_run_by_id(id)
49
+ run = HashHelper.parse_to_class_variable(Testrail2.http_get("index.php?/api/v2/get_run/#{id}"), TestrailRun)
50
+ OnlyofficeLoggerHelper.log("Initialized run: #{run.name}")
51
+ run.instance_variable_set('@project', self)
52
+ run
53
+ end
54
+
55
+ def init_run_by_name(name, suite_id = nil)
56
+ found_run = get_run_by_name name
57
+ suite_id = get_suite_by_name(name).id if suite_id.nil?
58
+ found_run.nil? ? create_new_run(name, suite_id) : found_run
59
+ end
60
+
61
+ def create_new_run(name, suite_id, description = '')
62
+ new_run = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_run/#{@id}", name: StringHelper.warnstrip!(name), description: description, suite_id: suite_id), TestrailRun)
63
+ OnlyofficeLoggerHelper.log "Created new run: #{new_run.name}"
64
+ new_run.instance_variable_set('@project', self)
65
+ @runs_names[new_run.name] = new_run.id
66
+ new_run
67
+ end
68
+
69
+ # Get list of runs which older than several days
70
+ # @param [Integer] days_old should pass to get this run
71
+ # @param [Boolean] not_closed - return only not_closed runs
72
+ # @return [Array<TestrailRun>] list of runs
73
+ def runs_older_than_days(days_old, not_closed: true)
74
+ closed_flag_digit = not_closed ? 0 : 1
75
+ OnlyofficeLoggerHelper.log("Getting runs for #{@name}, days old: #{days_old}")
76
+ unix_timestamp = Date.today.prev_day(days_old).to_time.to_i
77
+ get_runs(created_before: unix_timestamp, is_completed: closed_flag_digit).map do |r|
78
+ TestrailRun.new(r['name'],
79
+ r['description'],
80
+ r['suite_id'],
81
+ r['id'],
82
+ is_completed: r['is_completed'])
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OnlyofficeTestrailWrapper
4
+ # Methods to perform operations on Suites
5
+ module TestrailProjectSuiteMethods
6
+ def suite(name_or_id)
7
+ case name_or_id.class.to_s
8
+ when 'Fixnum'
9
+ get_suite_by_id name_or_id
10
+ when 'String'
11
+ init_suite_by_name name_or_id
12
+ else
13
+ raise 'Wrong argument. Must be name [String] or id [Integer]'
14
+ end
15
+ end
16
+
17
+ # Get all test suites of project
18
+ # @return [Array<Hash>] array with suites data in hash
19
+ def get_suites
20
+ suites = Testrail2.http_get("index.php?/api/v2/get_suites/#{@id}")
21
+ @suites_names = HashHelper.get_hash_from_array_with_two_parameters(suites, 'name', 'id') if @suites_names.empty?
22
+ suites
23
+ end
24
+
25
+ extend Gem::Deprecate
26
+ deprecate :get_suites, 'suites', 2069, 1
27
+
28
+ # Get all test suites of project as objects
29
+ # @return [Array<TestrailSuite>] array with TestRailSuite
30
+ def suites
31
+ suites = Testrail2.http_get("index.php?/api/v2/get_suites/#{@id}")
32
+ suites.map { |suite| HashHelper.parse_to_class_variable(suite, TestrailSuite) }
33
+ end
34
+
35
+ # Get Test Suite by it's name
36
+ # @param [String] name name of test suite
37
+ # @return [TestrailSuite, nil] test suite or nil if not found
38
+ def get_suite_by_name(name)
39
+ get_suites if @suites_names.empty?
40
+ @suites_names[StringHelper.warnstrip!(name)].nil? ? nil : get_suite_by_id(@suites_names[name])
41
+ end
42
+
43
+ def get_suite_by_id(id)
44
+ suite = HashHelper.parse_to_class_variable(Testrail2.http_get("index.php?/api/v2/get_suite/#{id}"), TestrailSuite)
45
+ suite.instance_variable_set('@project', self)
46
+ OnlyofficeLoggerHelper.log("Initialized suite: #{suite.name}")
47
+ suite
48
+ end
49
+
50
+ # Init suite by it's name
51
+ # @param [String] name name of suit
52
+ # @return [TestrailSuite] suite with this name
53
+ def init_suite_by_name(name)
54
+ found_suite = get_suite_by_name name
55
+ found_suite.nil? ? create_new_suite(name) : found_suite
56
+ end
57
+
58
+ # Create new test suite in project
59
+ # @param [String] name of suite
60
+ # @param [String] description description of suite
61
+ # @return [TestrailSuite] created suite
62
+ def create_new_suite(name, description = '')
63
+ new_suite = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/add_suite/#{@id}", name: StringHelper.warnstrip!(name), description: description), TestrailSuite)
64
+ new_suite.instance_variable_set('@project', self)
65
+ OnlyofficeLoggerHelper.log "Created new suite: #{new_suite.name}"
66
+ @suites_names[new_suite.name] = new_suite.id
67
+ new_suite
68
+ end
69
+ end
70
+ end
@@ -37,19 +37,25 @@ module OnlyofficeTestrailWrapper
37
37
  attr_accessor :tests_names
38
38
  # @return [Array] array of arrays of TestResults
39
39
  attr_accessor :test_results
40
+ # @return [Integer] time since epoch on which run created
41
+ attr_reader :created_on
42
+ # @return [True, False] is current run completed
43
+ attr_reader :is_completed
40
44
 
41
45
  # Default constructor
42
46
  # @param [Integer] id id of test, default = nil
43
47
  # @param [String] name name of test run, default = nil
44
48
  # @param [String] description description of test run
49
+ # @param [Hash] params all other params
45
50
  # @return [TestRunTestRail] new Test run
46
- def initialize(name = '', description = '', suite_id = nil, id = nil)
51
+ def initialize(name = '', description = '', suite_id = nil, id = nil, params = {})
47
52
  @id = id
48
53
  @name = name
49
54
  @description = description
50
55
  @suite_id = suite_id
51
56
  @tests_names = {}
52
57
  @test_results = []
58
+ @is_completed = params[:is_completed]
53
59
  end
54
60
 
55
61
  # Get all incomplete test (With status 'Untested' or 'Rerun')
@@ -64,8 +70,9 @@ module OnlyofficeTestrailWrapper
64
70
  end
65
71
 
66
72
  def close
73
+ OnlyofficeLoggerHelper.log("Starting to send command to close run: #{@name}")
67
74
  test_run = HashHelper.parse_to_class_variable(Testrail2.http_post("index.php?/api/v2/close_run/#{@id}", {}), TestrailRun)
68
- OnlyofficeLoggerHelper.log "Closed run: #{@name}"
75
+ OnlyofficeLoggerHelper.log("Run is closed: #{@name}")
69
76
  test_run
70
77
  end
71
78
 
@@ -95,6 +95,8 @@ module OnlyofficeTestrailWrapper
95
95
  found_section.nil? ? create_new_section(name, parent_section) : found_section
96
96
  end
97
97
 
98
+ # Delete current test suite
99
+ # @return [nil]
98
100
  def delete
99
101
  Testrail2.http_post "index.php?/api/v2/delete_suite/#{@id}", {}
100
102
  OnlyofficeLoggerHelper.log "Deleted suite: #{@name}"
@@ -12,7 +12,6 @@ require_relative '../testrail'
12
12
  #
13
13
  # Then call methods:
14
14
  #
15
- # TestrailTools.close_run
16
15
  # TestrailTools.close_all_runs
17
16
  #
18
17
  module OnlyofficeTestrailWrapper
@@ -38,33 +37,23 @@ module OnlyofficeTestrailWrapper
38
37
  def self.close_all_runs_older_than(time)
39
38
  check_config(__method__, :@project)
40
39
  loop do
41
- old_runs = project.get_runs(is_completed: 0).reject { |e| e['created_on'] > time.to_i }
40
+ old_runs = project.runs(is_completed: 0).reject { |e| e.created_on > time.to_i }
42
41
  return if old_runs.empty?
43
42
 
44
- old_runs.each { |run| Testrail2.http_post("index.php?/api/v2/close_run/#{run['id']}", {}) }
43
+ old_runs.each(&:close)
45
44
  end
46
45
  end
47
46
 
48
47
  def self.close_all_plans_older_than(time)
49
48
  check_config(__method__, :@project)
50
49
  loop do
51
- old_plans = project.get_plans(is_completed: 0).reject { |e| e['created_on'] > time.to_i }
50
+ old_plans = project.plans(is_completed: 0).reject { |e| e.created_on > time.to_i }
52
51
  return if old_plans.empty?
53
52
 
54
- old_plans.each { |run| Testrail2.http_post("index.php?/api/v2/close_plan/#{run['id']}", {}) }
53
+ old_plans.each(&:close)
55
54
  end
56
55
  end
57
56
 
58
- def self.close_run
59
- check_config(__method__, :@project, :@run)
60
- run.close
61
- end
62
-
63
- def self.get_incompleted_plan_entries
64
- check_config(__method__, :@project, :@plan)
65
- plan.entries.reject { |entry| entry.runs.first.untested_count.zero? }
66
- end
67
-
68
57
  def self.get_tests_report(status)
69
58
  check_config(__method__, :@project, :@plan)
70
59
  { plan.name => plan.entries.inject({}) { |a, e| a.merge!({ e.name => e.runs.first.get_tests.map { |test| test['title'] if TestrailResult::RESULT_STATUSES.key(test['status_id']) == status }.compact }.delete_if { |_, value| value.empty? }) } }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OnlyofficeTestrailWrapper
4
4
  module Version
5
- STRING = '0.1.0'
5
+ STRING = '0.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onlyoffice_testrail_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ONLYOFFICE
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-11-27 00:00:00.000000000 Z
13
+ date: 2021-02-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: onlyoffice_bugzilla_helper
@@ -198,7 +198,11 @@ files:
198
198
  - lib/onlyoffice_testrail_wrapper/testrail_plan.rb
199
199
  - lib/onlyoffice_testrail_wrapper/testrail_plan_entry.rb
200
200
  - lib/onlyoffice_testrail_wrapper/testrail_project.rb
201
+ - lib/onlyoffice_testrail_wrapper/testrail_project/project_cleanup.rb
202
+ - lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_milestone_methods.rb
201
203
  - lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb
204
+ - lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_runs_methods.rb
205
+ - lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_suite_methods.rb
202
206
  - lib/onlyoffice_testrail_wrapper/testrail_result.rb
203
207
  - lib/onlyoffice_testrail_wrapper/testrail_run.rb
204
208
  - lib/onlyoffice_testrail_wrapper/testrail_section.rb
@@ -230,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
234
  - !ruby/object:Gem::Version
231
235
  version: '0'
232
236
  requirements: []
233
- rubygems_version: 3.1.4
237
+ rubygems_version: 3.2.11
234
238
  signing_key:
235
239
  specification_version: 4
236
240
  summary: ONLYOFFICE Testrail Wrapper Gem