testrail-ruby 0.0.9 → 0.0.10
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.
- checksums.yaml +4 -4
- data/lib/version.rb +1 -1
- metadata +1 -6
- data/lib/testrail/deprecated/client.rb +0 -167
- data/lib/testrail/deprecated/command_helper.rb +0 -18
- data/lib/testrail/deprecated/config.rb +0 -32
- data/lib/testrail/deprecated/request.rb +0 -55
- data/lib/testrail/deprecated/response.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dc067d516de6bc22d79edcba17a13b21f6dd5cf
|
4
|
+
data.tar.gz: 866dfb179ef951eb3225326a80fb7a45b9d22ecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77845d3648ba7480b017e30461a54d0a6729ce5fd34debd2db739d4e792031bcfb3d896f5ac30d708018ecde77b4c0e88bf06324973652afa5728bed53892f7e
|
7
|
+
data.tar.gz: 3f5057f4afc65bc85389c244794ae035455a8b7762a2187841a67d13b3a638cfc9da47deaefd80a891ccd7ddd1eb7c45b29507d290c8aa88af80b0eec0bb9c01
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frances Morales
|
@@ -106,11 +106,6 @@ files:
|
|
106
106
|
- Rakefile
|
107
107
|
- lib/endpoints.rb
|
108
108
|
- lib/testrail-ruby.rb
|
109
|
-
- lib/testrail/deprecated/client.rb
|
110
|
-
- lib/testrail/deprecated/command_helper.rb
|
111
|
-
- lib/testrail/deprecated/config.rb
|
112
|
-
- lib/testrail/deprecated/request.rb
|
113
|
-
- lib/testrail/deprecated/response.rb
|
114
109
|
- lib/version.rb
|
115
110
|
- spec/spec_helper.rb
|
116
111
|
- spec/testrail/endpoints_spec.rb
|
@@ -1,167 +0,0 @@
|
|
1
|
-
module Testrail
|
2
|
-
class Client
|
3
|
-
attr_reader :request
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@request = Testrail::Request
|
7
|
-
end
|
8
|
-
|
9
|
-
# Test Results - see http://docs.gurock.com/testrail-api/reference-results
|
10
|
-
def add_result(test_id, opts = {})
|
11
|
-
request.post('add_result', test_id, opts)
|
12
|
-
end
|
13
|
-
|
14
|
-
def add_result_for_case(run_id, case_id, opts = {})
|
15
|
-
request.post('add_result_for_case', run_id, case_id, opts)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Test - see http://docs.gurock.com/testrail-api/reference-tests
|
19
|
-
def get_test(test_id, opts = {})
|
20
|
-
request.get('get_test', test_id, opts)
|
21
|
-
end
|
22
|
-
|
23
|
-
def get_tests(run_id, opts = {})
|
24
|
-
request.get('get_tests', run_id, opts)
|
25
|
-
end
|
26
|
-
|
27
|
-
# Test Cases - see http://docs.gurock.com/testrail-api/reference-cases
|
28
|
-
def get_case(case_id, opts = {})
|
29
|
-
request.get('get_case', case_id, opts)
|
30
|
-
end
|
31
|
-
|
32
|
-
def get_cases(suite_id, section_id, opts = {})
|
33
|
-
request.get('get_cases', [suite_id, section_id], opts)
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_case(section_id, opts = {})
|
37
|
-
request.post('add_case', section_id, opts)
|
38
|
-
end
|
39
|
-
|
40
|
-
def update_case(case_id, opts = {})
|
41
|
-
request.post('update_case', case_id, opts)
|
42
|
-
end
|
43
|
-
|
44
|
-
def delete_case(case_id, opts = {})
|
45
|
-
request.post('delete_case', case_id, opts)
|
46
|
-
end
|
47
|
-
|
48
|
-
# Suites and Sections - see http://docs.gurock.com/testrail-api/reference-suites
|
49
|
-
def get_suite(suite_id, opts = {})
|
50
|
-
request.get('get_suite', suite_id, opts)
|
51
|
-
end
|
52
|
-
|
53
|
-
def get_suites(project_id, opts = {})
|
54
|
-
request.get('get_suites', project_id, opts)
|
55
|
-
end
|
56
|
-
|
57
|
-
def get_section(section_id, opts = {})
|
58
|
-
request.get('get_section', section_id, opts)
|
59
|
-
end
|
60
|
-
|
61
|
-
def get_sections(suite_id, opts = {})
|
62
|
-
request.get('get_sections', suite_id, opts)
|
63
|
-
end
|
64
|
-
|
65
|
-
def add_suite(project_id, opts = {})
|
66
|
-
request.post('add_suite', project_id, opts)
|
67
|
-
end
|
68
|
-
|
69
|
-
def add_section(suite_id, opts = {})
|
70
|
-
request.post('add_section', suite_id, opts)
|
71
|
-
end
|
72
|
-
|
73
|
-
# Test Runs - see http://docs.gurock.com/testrail-api/reference-runs
|
74
|
-
def get_run(run_id, opts = {})
|
75
|
-
request.get('get_run', run_id, opts)
|
76
|
-
end
|
77
|
-
|
78
|
-
def get_runs(project_id, plan_id, opts = {})
|
79
|
-
request.get('get_runs', project_id, plan_id, opts)
|
80
|
-
end
|
81
|
-
|
82
|
-
def add_run(suite_id, opts = {})
|
83
|
-
request.post('add_run', suite_id, opts)
|
84
|
-
end
|
85
|
-
|
86
|
-
def close_run(run_id, opts = {})
|
87
|
-
request.post('close_run', run_id, opts)
|
88
|
-
end
|
89
|
-
|
90
|
-
# Test Plans - see http://docs.gurock.com/testrail-api/reference-plans
|
91
|
-
def get_plan(plan_id, opts = {})
|
92
|
-
request.get('get_plan', plan_id, opts)
|
93
|
-
end
|
94
|
-
|
95
|
-
def get_plans(project_id, opts = {})
|
96
|
-
request.get('get_plans', project_id, opts)
|
97
|
-
end
|
98
|
-
|
99
|
-
def add_plan(project_id, opts = {})
|
100
|
-
request.post('add_plan', project_id, opts)
|
101
|
-
end
|
102
|
-
|
103
|
-
def add_plan_entries(plan_id, opts = {})
|
104
|
-
request.post('add_plan_entries', plan_id, opts)
|
105
|
-
end
|
106
|
-
|
107
|
-
def close_plan(plan_id, opts = {})
|
108
|
-
request.post('close_plan', plan_id, opts)
|
109
|
-
end
|
110
|
-
|
111
|
-
# Milestones - see http://docs.gurock.com/testrail-api/reference-milestones
|
112
|
-
def get_milestone(milestone_id, opts = {})
|
113
|
-
request.get('get_milestone', milestone_id, opts)
|
114
|
-
end
|
115
|
-
|
116
|
-
def get_milestones(project_id, opts = {})
|
117
|
-
request.get('get_milestones', project_id, opts)
|
118
|
-
end
|
119
|
-
|
120
|
-
def add_milestone(project_id, opts = {})
|
121
|
-
request.post('add_milestone', project_id, opts)
|
122
|
-
end
|
123
|
-
|
124
|
-
# Projects - see http://docs.gurock.com/testrail-api/reference-projects
|
125
|
-
def get_project(project_id, opts = {})
|
126
|
-
request.get('get_project', project_id, opts)
|
127
|
-
end
|
128
|
-
|
129
|
-
def get_projects(opts = {})
|
130
|
-
request.get('get_projects', opts)
|
131
|
-
end
|
132
|
-
|
133
|
-
# COMMANDS.each do |method_name|
|
134
|
-
# define_method method_name
|
135
|
-
# end
|
136
|
-
|
137
|
-
COMMANDS = %w(add_result
|
138
|
-
add_result_for_case
|
139
|
-
get_test
|
140
|
-
get_tests
|
141
|
-
get_case
|
142
|
-
get_cases
|
143
|
-
add_case
|
144
|
-
update_case
|
145
|
-
delete_case
|
146
|
-
get_suite
|
147
|
-
get_suites
|
148
|
-
get_section
|
149
|
-
get_sections
|
150
|
-
add_suite
|
151
|
-
add_section
|
152
|
-
get_run
|
153
|
-
get_runs
|
154
|
-
add_run
|
155
|
-
close_run
|
156
|
-
get_plan
|
157
|
-
get_plans
|
158
|
-
add_plan
|
159
|
-
add_plan_entries
|
160
|
-
close_plan
|
161
|
-
get_milestone
|
162
|
-
get_milestones
|
163
|
-
add_milestone
|
164
|
-
get_project
|
165
|
-
get_projects).freeze
|
166
|
-
end
|
167
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Testrail
|
2
|
-
module CommandHelper
|
3
|
-
def build_url(command, ids = nil)
|
4
|
-
command = Testrail.config.server + Testrail.config.api_path + command
|
5
|
-
unless ids.nil?
|
6
|
-
ids = '/' + [ids].flatten.join('/')
|
7
|
-
command += ids
|
8
|
-
end
|
9
|
-
command + key
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def key
|
15
|
-
'&key=' + String(Testrail.config.api_key)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require 'active_support/configurable'
|
3
|
-
|
4
|
-
module Testrail
|
5
|
-
def self.configure
|
6
|
-
@config = Config.new
|
7
|
-
yield @config if block_given?
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.config
|
11
|
-
@config ||= Config.new
|
12
|
-
end
|
13
|
-
|
14
|
-
class Config
|
15
|
-
include ActiveSupport::Configurable
|
16
|
-
config_accessor :headers, :server, :api_path, :api_key, :logger
|
17
|
-
|
18
|
-
def initialize
|
19
|
-
default_config
|
20
|
-
end
|
21
|
-
|
22
|
-
def default_config
|
23
|
-
self.headers = {
|
24
|
-
'Accept' => 'application/json'
|
25
|
-
}
|
26
|
-
self.server = 'https://example.testrail.com'
|
27
|
-
self.api_path = '/index.php?/miniapi/'
|
28
|
-
self.api_key = nil
|
29
|
-
self.logger = Logger.new STDOUT
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
require 'testrail/command_helper'
|
3
|
-
|
4
|
-
module Testrail
|
5
|
-
class Request
|
6
|
-
extend Testrail::CommandHelper
|
7
|
-
include HTTParty
|
8
|
-
|
9
|
-
base_uri Testrail.config.server
|
10
|
-
format :json
|
11
|
-
|
12
|
-
def self.get(*args)
|
13
|
-
request(:get, *args)
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.post(*args)
|
17
|
-
request(:post, *args)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def self.request(method, *args)
|
23
|
-
command, ids, opts = parse_args(*args)
|
24
|
-
url = build_url(command, ids)
|
25
|
-
attempts = 0
|
26
|
-
begin
|
27
|
-
response = Testrail::Response.new(HTTParty.send(method, url, opts))
|
28
|
-
rescue TimeoutError => error
|
29
|
-
attempts += 1
|
30
|
-
retry if attempts < 3
|
31
|
-
log_error error, "Timeout connecting to #{method.to_s.upcase} #{url}"
|
32
|
-
raise error
|
33
|
-
rescue Exception => error
|
34
|
-
log_error error, 'Unexpected exception intercepted calling TestRail'
|
35
|
-
raise error
|
36
|
-
end
|
37
|
-
response
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.log_error(error, message)
|
41
|
-
unless Testrail.logger.nil?
|
42
|
-
Testrail.logger.error message
|
43
|
-
Testrail.logger.error error
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.parse_args(*args)
|
48
|
-
opts = args.last.instance_of?(Hash) ? args.pop : {}
|
49
|
-
opts[:headers] = opts[:headers] ? Testrail.config.headers.merge(opts[:headers]) : Testrail.config.headers
|
50
|
-
command = args.shift
|
51
|
-
ids = args.empty? ? nil : args
|
52
|
-
[command, ids, opts]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
module Testrail
|
5
|
-
class Response
|
6
|
-
attr_reader :http_response
|
7
|
-
attr_accessor :success, :payload, :error
|
8
|
-
|
9
|
-
extend Forwardable
|
10
|
-
|
11
|
-
def_delegators :http_response, :request, :response, :code
|
12
|
-
|
13
|
-
def initialize(http_response = nil)
|
14
|
-
@http_response = http_response
|
15
|
-
parse_payload if http_response.respond_to?(:body) && !http_response.body.nil?
|
16
|
-
parse_error if Integer(http_response.code) >= 400
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def parse_payload
|
22
|
-
result_body = JSON.parse(http_response.body)
|
23
|
-
@success = result_body.key?('result') ? result_body.delete('result') : nil
|
24
|
-
@payload = @success ? result_body : nil
|
25
|
-
@error = result_body.key?('error') ? result_body.delete('error') : nil
|
26
|
-
rescue JSON::ParserError
|
27
|
-
@success = false
|
28
|
-
@error = "Malformed JSON response.\n Received #{http_response.body}"
|
29
|
-
end
|
30
|
-
|
31
|
-
def parse_error
|
32
|
-
@success = false
|
33
|
-
@error = ::Net::HTTPResponse::CODE_TO_OBJ[http_response.code.to_s].name.gsub!(/Net::HTTP/, '')
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|