automation-test 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +65 -0
- data/lib/apimatic_calculator/api_helper.rb +279 -0
- data/lib/apimatic_calculator/client.rb +35 -0
- data/lib/apimatic_calculator/configuration.rb +111 -0
- data/lib/apimatic_calculator/controllers/base_controller.rb +47 -0
- data/lib/apimatic_calculator/controllers/simple_calculator_controller.rb +45 -0
- data/lib/apimatic_calculator/exceptions/api_exception.rb +20 -0
- data/lib/apimatic_calculator/http/faraday_client.rb +89 -0
- data/lib/apimatic_calculator/http/http_call_back.rb +24 -0
- data/lib/apimatic_calculator/http/http_client.rb +104 -0
- data/lib/apimatic_calculator/http/http_method_enum.rb +13 -0
- data/lib/apimatic_calculator/http/http_request.rb +50 -0
- data/lib/apimatic_calculator/http/http_response.rb +29 -0
- data/lib/apimatic_calculator/models/base_model.rb +58 -0
- data/lib/apimatic_calculator/models/operation_type_enum.rb +23 -0
- data/lib/apimatic_calculator/utilities/date_time_helper.rb +156 -0
- data/lib/apimatic_calculator/utilities/file_wrapper.rb +16 -0
- data/lib/apimatic_calculator.rb +38 -0
- data/test/controllers/controller_test_base.rb +21 -0
- data/test/controllers/test_simple_calculator_controller.rb +34 -0
- data/test/http_response_catcher.rb +19 -0
- data/test/test_helper.rb +94 -0
- metadata +185 -0
data/test/test_helper.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# apimatic_calculator
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'tempfile'
|
7
|
+
require 'open-uri'
|
8
|
+
|
9
|
+
class TestHelper
|
10
|
+
|
11
|
+
@cache = Hash.new
|
12
|
+
|
13
|
+
# Class method to compare the received headers with the expected headers.
|
14
|
+
# @param [Hash] A hash of expected headers (keys in lower case).
|
15
|
+
# @param [Hash] A hash of received headers.
|
16
|
+
# @param [Boolean, optional] A flag which determines if we allow extra headers.
|
17
|
+
def self.match_headers(expected_headers,
|
18
|
+
received_headers,
|
19
|
+
allow_extra: true)
|
20
|
+
return false if ((received_headers.length < expected_headers.length) ||
|
21
|
+
((allow_extra == false) && (received_headers.length > expected_headers.length)))
|
22
|
+
|
23
|
+
received_headers = Hash[received_headers.map{|k, v| [k.to_s.downcase, v]}]
|
24
|
+
expected_headers.each do |e_key, e_value|
|
25
|
+
return false unless received_headers.key?(e_key)
|
26
|
+
return false if ((e_value != nil) &&
|
27
|
+
(e_value != received_headers[e_key]))
|
28
|
+
end
|
29
|
+
|
30
|
+
return true
|
31
|
+
end
|
32
|
+
|
33
|
+
# Class method to compare the received body with the expected body.
|
34
|
+
# @param [Dynamic] The expected body.
|
35
|
+
# @param [Dynamic] The received body.
|
36
|
+
# @param [Boolean, optional] A flag which determines if we check values in dictionaries.
|
37
|
+
# @param [Boolean, optional] A flag which determines if we check the order of array elements.
|
38
|
+
# @param [Boolean, optional] A flag which determines if we check the count of array elements.
|
39
|
+
def self.match_body(expected_body,
|
40
|
+
received_body,
|
41
|
+
check_values: false,
|
42
|
+
check_order: false,
|
43
|
+
check_count: false)
|
44
|
+
if expected_body.instance_of? Hash
|
45
|
+
return false unless received_body.instance_of? Hash
|
46
|
+
for key in expected_body.keys
|
47
|
+
return false unless received_body.keys.include? key
|
48
|
+
if check_values or expected_body[key].instance_of? Hash
|
49
|
+
return false unless TestHelper.match_body(expected_body[key],
|
50
|
+
received_body[key],
|
51
|
+
check_values: check_values,
|
52
|
+
check_order: check_order,
|
53
|
+
check_count: check_count)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
elsif expected_body.instance_of? Array
|
57
|
+
return False unless received_body.instance_of? Array
|
58
|
+
if check_count == true && (expected_body.length != received_body.length)
|
59
|
+
return false
|
60
|
+
else
|
61
|
+
previous_matches = Array.new
|
62
|
+
expected_body.each.with_index do |expected_element, i|
|
63
|
+
matches = (received_body.map.with_index do |received_element, j|
|
64
|
+
j if TestHelper.match_body(expected_element,
|
65
|
+
received_element,
|
66
|
+
check_values: check_values,
|
67
|
+
check_order: check_order,
|
68
|
+
check_count: check_count)
|
69
|
+
end).compact
|
70
|
+
return false if matches.length == 0
|
71
|
+
if check_order == true
|
72
|
+
return false if (i != 0 && matches.map{|x| previous_matches.map{|y| y > x}.all?}.all?)
|
73
|
+
previous_matches = matches
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
elsif expected_body != received_body
|
78
|
+
return false
|
79
|
+
end
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
|
83
|
+
# Class method which takes a URL, downloads the file (if not already downloaded
|
84
|
+
# for this test session) and returns the path of the file.
|
85
|
+
# @param [String] The URL of the required file.
|
86
|
+
def self.get_file(url)
|
87
|
+
unless @cache.keys.include? url
|
88
|
+
@cache[url] = Tempfile.new('APIMatic')
|
89
|
+
@cache[url].binmode
|
90
|
+
@cache[url].write(open(url, {ssl_ca_cert: Certifi.where}).read)
|
91
|
+
end
|
92
|
+
return @cache[url].path
|
93
|
+
end
|
94
|
+
end
|
metadata
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: automation-test
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- APIMatic SDK Generator
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-10-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logging
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.0.1
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.0'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.0.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: faraday_middleware
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: certifi
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '2018.1'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 2018.01.18
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2018.1'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 2018.01.18
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: faraday-http-cache
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '2.2'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '2.2'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: minitest
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '5.14'
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 5.14.1
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '5.14'
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 5.14.1
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: minitest-proveit
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '1.0'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - "~>"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '1.0'
|
129
|
+
description: Simple calculator API hosted on APIMATIC
|
130
|
+
email: support@apimatic.io
|
131
|
+
executables: []
|
132
|
+
extensions: []
|
133
|
+
extra_rdoc_files: []
|
134
|
+
files:
|
135
|
+
- LICENSE
|
136
|
+
- README.md
|
137
|
+
- lib/apimatic_calculator.rb
|
138
|
+
- lib/apimatic_calculator/api_helper.rb
|
139
|
+
- lib/apimatic_calculator/client.rb
|
140
|
+
- lib/apimatic_calculator/configuration.rb
|
141
|
+
- lib/apimatic_calculator/controllers/base_controller.rb
|
142
|
+
- lib/apimatic_calculator/controllers/simple_calculator_controller.rb
|
143
|
+
- lib/apimatic_calculator/exceptions/api_exception.rb
|
144
|
+
- lib/apimatic_calculator/http/faraday_client.rb
|
145
|
+
- lib/apimatic_calculator/http/http_call_back.rb
|
146
|
+
- lib/apimatic_calculator/http/http_client.rb
|
147
|
+
- lib/apimatic_calculator/http/http_method_enum.rb
|
148
|
+
- lib/apimatic_calculator/http/http_request.rb
|
149
|
+
- lib/apimatic_calculator/http/http_response.rb
|
150
|
+
- lib/apimatic_calculator/models/base_model.rb
|
151
|
+
- lib/apimatic_calculator/models/operation_type_enum.rb
|
152
|
+
- lib/apimatic_calculator/utilities/date_time_helper.rb
|
153
|
+
- lib/apimatic_calculator/utilities/file_wrapper.rb
|
154
|
+
- test/controllers/controller_test_base.rb
|
155
|
+
- test/controllers/test_simple_calculator_controller.rb
|
156
|
+
- test/http_response_catcher.rb
|
157
|
+
- test/test_helper.rb
|
158
|
+
homepage: https://apimatic.io
|
159
|
+
licenses:
|
160
|
+
- MIT
|
161
|
+
metadata: {}
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '2.5'
|
171
|
+
- - "<"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '3.0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 2.7.6
|
182
|
+
signing_key:
|
183
|
+
specification_version: 4
|
184
|
+
summary: apimatic_calculator
|
185
|
+
test_files: []
|