onlyoffice_testrail_wrapper 0.1.0

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 (28) hide show
  1. checksums.yaml +7 -0
  2. data/lib/onlyoffice_testrail_wrapper.rb +10 -0
  3. data/lib/onlyoffice_testrail_wrapper/helpers/hash_helper.rb +21 -0
  4. data/lib/onlyoffice_testrail_wrapper/helpers/rspec_helper.rb +24 -0
  5. data/lib/onlyoffice_testrail_wrapper/helpers/ruby_helper.rb +10 -0
  6. data/lib/onlyoffice_testrail_wrapper/helpers/string_helper.rb +12 -0
  7. data/lib/onlyoffice_testrail_wrapper/helpers/system_helper.rb +17 -0
  8. data/lib/onlyoffice_testrail_wrapper/mock/rspec_example_mock.rb +40 -0
  9. data/lib/onlyoffice_testrail_wrapper/name.rb +9 -0
  10. data/lib/onlyoffice_testrail_wrapper/rspec_extension.rb +14 -0
  11. data/lib/onlyoffice_testrail_wrapper/testrail.rb +187 -0
  12. data/lib/onlyoffice_testrail_wrapper/testrail_case.rb +67 -0
  13. data/lib/onlyoffice_testrail_wrapper/testrail_helper.rb +173 -0
  14. data/lib/onlyoffice_testrail_wrapper/testrail_helper/testrail_helper_rspec_metadata.rb +55 -0
  15. data/lib/onlyoffice_testrail_wrapper/testrail_helper/testrail_status_helper.rb +18 -0
  16. data/lib/onlyoffice_testrail_wrapper/testrail_milestone.rb +23 -0
  17. data/lib/onlyoffice_testrail_wrapper/testrail_plan.rb +92 -0
  18. data/lib/onlyoffice_testrail_wrapper/testrail_plan_entry.rb +16 -0
  19. data/lib/onlyoffice_testrail_wrapper/testrail_project.rb +227 -0
  20. data/lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb +65 -0
  21. data/lib/onlyoffice_testrail_wrapper/testrail_result.rb +47 -0
  22. data/lib/onlyoffice_testrail_wrapper/testrail_run.rb +147 -0
  23. data/lib/onlyoffice_testrail_wrapper/testrail_section.rb +109 -0
  24. data/lib/onlyoffice_testrail_wrapper/testrail_suite.rb +113 -0
  25. data/lib/onlyoffice_testrail_wrapper/testrail_test.rb +40 -0
  26. data/lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb +119 -0
  27. data/lib/onlyoffice_testrail_wrapper/version.rb +7 -0
  28. metadata +237 -0
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../testrail'
4
+
5
+ # USAGE
6
+ # Configure TestrailTools with needed parameters:
7
+ #
8
+ # TestrailTools.configure do |testrail|
9
+ # testrail.project = 'Foo'
10
+ # testrail.run = 'Bar'
11
+ # end
12
+ #
13
+ # Then call methods:
14
+ #
15
+ # TestrailTools.close_run
16
+ # TestrailTools.close_all_runs
17
+ #
18
+ module OnlyofficeTestrailWrapper
19
+ module TestrailTools
20
+ class TestrailConfig
21
+ attr_accessor :project, :plan, :suite, :run
22
+ end
23
+
24
+ def self.configure
25
+ @testrail_config ||= TestrailConfig.new
26
+ yield(@testrail_config) if block_given?
27
+ end
28
+
29
+ def self.testrail
30
+ @testrail_config
31
+ end
32
+
33
+ def self.get_all_plans_younger_than(time)
34
+ check_config(__method__, :@project)
35
+ project.get_plans(is_completed: 0).reject { |e| e['created_on'] < time.to_i }
36
+ end
37
+
38
+ def self.close_all_runs_older_than(time)
39
+ check_config(__method__, :@project)
40
+ loop do
41
+ old_runs = project.get_runs(is_completed: 0).reject { |e| e['created_on'] > time.to_i }
42
+ return if old_runs.empty?
43
+
44
+ old_runs.each { |run| Testrail2.http_post("index.php?/api/v2/close_run/#{run['id']}", {}) }
45
+ end
46
+ end
47
+
48
+ def self.close_all_plans_older_than(time)
49
+ check_config(__method__, :@project)
50
+ loop do
51
+ old_plans = project.get_plans(is_completed: 0).reject { |e| e['created_on'] > time.to_i }
52
+ return if old_plans.empty?
53
+
54
+ old_plans.each { |run| Testrail2.http_post("index.php?/api/v2/close_plan/#{run['id']}", {}) }
55
+ end
56
+ end
57
+
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
+ def self.get_tests_report(status)
69
+ check_config(__method__, :@project, :@plan)
70
+ { 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? }) } }
71
+ end
72
+
73
+ def self.get_runs_durations
74
+ check_config(__method__, :@project, :@plan)
75
+ sorted_durations = plan.plan_durations
76
+ sorted_durations.each do |run|
77
+ OnlyofficeLoggerHelper.log "'#{run.first}' took about #{run[1]} hours"
78
+ end
79
+ end
80
+
81
+ def self.project
82
+ @project ||= Testrail2.new.project(@testrail_config.project)
83
+ end
84
+
85
+ def self.run
86
+ @run ||= project.test_run(@testrail_config.run)
87
+ end
88
+
89
+ def self.plan
90
+ @plan ||= project.plan(@testrail_config.plan)
91
+ end
92
+
93
+ def self.suite
94
+ @suite ||= project.suite(@testrail_config.suite)
95
+ end
96
+
97
+ def self.check_config(*args)
98
+ return if @testrail_config && (@testrail_config.instance_variables & args[1..-1]) == args[1..-1]
99
+
100
+ raise "Method: #{args.shift} - some of needed parameters are missing: #{args.join(', ')}. To configure them, type:\n
101
+ TestrailTools.configure do |config|\n\t\tconfig.param_name = value\n\tend"
102
+ end
103
+
104
+ def self.get_most_failed
105
+ failed_tests = TestrailTools.get_tests_report(:failed)[@plan.name]
106
+ aborted_tests = TestrailTools.get_tests_report(:aborted)[@plan.name]
107
+ untested_tests = TestrailTools.get_tests_report(:untested)[@plan.name]
108
+
109
+ problem_tests = {}
110
+ problem_tests = problem_tests.deep_merge(failed_tests)
111
+ problem_tests = problem_tests.deep_merge(aborted_tests)
112
+ problem_tests = problem_tests.deep_merge(untested_tests)
113
+ problem_result = problem_tests.sort_by { |_key, value| value.length }.reverse
114
+ problem_result.each do |cur|
115
+ p cur[0]
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OnlyofficeTestrailWrapper
4
+ module Version
5
+ STRING = '0.1.0'
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,237 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: onlyoffice_testrail_wrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ONLYOFFICE
8
+ - Pavel Lobashov
9
+ - Roman Zagudaev
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2020-11-27 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: onlyoffice_bugzilla_helper
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '0.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '0.1'
29
+ - !ruby/object:Gem::Dependency
30
+ name: onlyoffice_logger_helper
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '1'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1'
43
+ - !ruby/object:Gem::Dependency
44
+ name: codecov
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: overcommit
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rake
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '13'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '13'
85
+ - !ruby/object:Gem::Dependency
86
+ name: rspec
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '3'
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '3'
99
+ - !ruby/object:Gem::Dependency
100
+ name: rubocop
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: '1'
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '1'
113
+ - !ruby/object:Gem::Dependency
114
+ name: rubocop-performance
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '1'
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - "~>"
125
+ - !ruby/object:Gem::Version
126
+ version: '1'
127
+ - !ruby/object:Gem::Dependency
128
+ name: rubocop-rake
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - "~>"
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - "~>"
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ - !ruby/object:Gem::Dependency
142
+ name: rubocop-rspec
143
+ requirement: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - "~>"
146
+ - !ruby/object:Gem::Version
147
+ version: '2'
148
+ type: :development
149
+ prerelease: false
150
+ version_requirements: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - "~>"
153
+ - !ruby/object:Gem::Version
154
+ version: '2'
155
+ - !ruby/object:Gem::Dependency
156
+ name: yard
157
+ requirement: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - "~>"
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: 0.9.20
165
+ type: :development
166
+ prerelease: false
167
+ version_requirements: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - "~>"
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: 0.9.20
175
+ description: Wrapper for Testrail by OnlyOffice
176
+ email:
177
+ - shockwavenn@gmail.com
178
+ - rzagudaev@gmail.com
179
+ executables: []
180
+ extensions: []
181
+ extra_rdoc_files: []
182
+ files:
183
+ - lib/onlyoffice_testrail_wrapper.rb
184
+ - lib/onlyoffice_testrail_wrapper/helpers/hash_helper.rb
185
+ - lib/onlyoffice_testrail_wrapper/helpers/rspec_helper.rb
186
+ - lib/onlyoffice_testrail_wrapper/helpers/ruby_helper.rb
187
+ - lib/onlyoffice_testrail_wrapper/helpers/string_helper.rb
188
+ - lib/onlyoffice_testrail_wrapper/helpers/system_helper.rb
189
+ - lib/onlyoffice_testrail_wrapper/mock/rspec_example_mock.rb
190
+ - lib/onlyoffice_testrail_wrapper/name.rb
191
+ - lib/onlyoffice_testrail_wrapper/rspec_extension.rb
192
+ - lib/onlyoffice_testrail_wrapper/testrail.rb
193
+ - lib/onlyoffice_testrail_wrapper/testrail_case.rb
194
+ - lib/onlyoffice_testrail_wrapper/testrail_helper.rb
195
+ - lib/onlyoffice_testrail_wrapper/testrail_helper/testrail_helper_rspec_metadata.rb
196
+ - lib/onlyoffice_testrail_wrapper/testrail_helper/testrail_status_helper.rb
197
+ - lib/onlyoffice_testrail_wrapper/testrail_milestone.rb
198
+ - lib/onlyoffice_testrail_wrapper/testrail_plan.rb
199
+ - lib/onlyoffice_testrail_wrapper/testrail_plan_entry.rb
200
+ - lib/onlyoffice_testrail_wrapper/testrail_project.rb
201
+ - lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_plan_helper.rb
202
+ - lib/onlyoffice_testrail_wrapper/testrail_result.rb
203
+ - lib/onlyoffice_testrail_wrapper/testrail_run.rb
204
+ - lib/onlyoffice_testrail_wrapper/testrail_section.rb
205
+ - lib/onlyoffice_testrail_wrapper/testrail_suite.rb
206
+ - lib/onlyoffice_testrail_wrapper/testrail_test.rb
207
+ - lib/onlyoffice_testrail_wrapper/testrail_tools/testrail_tools.rb
208
+ - lib/onlyoffice_testrail_wrapper/version.rb
209
+ homepage: https://github.com/ONLYOFFICE-QA/onlyoffice_testrail_wrapper
210
+ licenses:
211
+ - AGPL-3.0
212
+ metadata:
213
+ bug_tracker_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_testrail_wrapper/issues
214
+ changelog_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_testrail_wrapper/blob/master/CHANGELOG.md
215
+ documentation_uri: https://www.rubydoc.info/gems/onlyoffice_testrail_wrapper
216
+ homepage_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_testrail_wrapper
217
+ source_code_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_testrail_wrapper
218
+ post_install_message:
219
+ rdoc_options: []
220
+ require_paths:
221
+ - lib
222
+ required_ruby_version: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ - - ">="
225
+ - !ruby/object:Gem::Version
226
+ version: '2.5'
227
+ required_rubygems_version: !ruby/object:Gem::Requirement
228
+ requirements:
229
+ - - ">="
230
+ - !ruby/object:Gem::Version
231
+ version: '0'
232
+ requirements: []
233
+ rubygems_version: 3.1.4
234
+ signing_key:
235
+ specification_version: 4
236
+ summary: ONLYOFFICE Testrail Wrapper Gem
237
+ test_files: []