hjhjhjnew 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +55 -0
  4. data/lib/tester.rb +56 -0
  5. data/lib/tester/api_helper.rb +261 -0
  6. data/lib/tester/configuration.rb +66 -0
  7. data/lib/tester/controllers/base_controller.rb +59 -0
  8. data/lib/tester/controllers/body_params_controller.rb +1270 -0
  9. data/lib/tester/controllers/echo_controller.rb +134 -0
  10. data/lib/tester/controllers/error_codes_controller.rb +179 -0
  11. data/lib/tester/controllers/form_params_controller.rb +1391 -0
  12. data/lib/tester/controllers/header_controller.rb +63 -0
  13. data/lib/tester/controllers/query_param_controller.rb +779 -0
  14. data/lib/tester/controllers/response_types_controller.rb +717 -0
  15. data/lib/tester/controllers/template_params_controller.rb +93 -0
  16. data/lib/tester/exceptions/api_exception.rb +18 -0
  17. data/lib/tester/exceptions/global_test_exception.rb +32 -0
  18. data/lib/tester/exceptions/local_test_exception.rb +30 -0
  19. data/lib/tester/exceptions/nested_model_exception.rb +37 -0
  20. data/lib/tester/http/faraday_client.rb +55 -0
  21. data/lib/tester/http/http_call_back.rb +22 -0
  22. data/lib/tester/http/http_client.rb +92 -0
  23. data/lib/tester/http/http_context.rb +18 -0
  24. data/lib/tester/http/http_method_enum.rb +11 -0
  25. data/lib/tester/http/http_request.rb +48 -0
  26. data/lib/tester/http/http_response.rb +21 -0
  27. data/lib/tester/models/additional_model_parameters.rb +70 -0
  28. data/lib/tester/models/base_model.rb +52 -0
  29. data/lib/tester/models/boss.rb +129 -0
  30. data/lib/tester/models/days.rb +30 -0
  31. data/lib/tester/models/delete_body.rb +52 -0
  32. data/lib/tester/models/echo_response.rb +88 -0
  33. data/lib/tester/models/employee.rb +155 -0
  34. data/lib/tester/models/job.rb +43 -0
  35. data/lib/tester/models/person.rb +113 -0
  36. data/lib/tester/models/query_parameter.rb +43 -0
  37. data/lib/tester/models/server_response.rb +61 -0
  38. data/lib/tester/models/suite_code.rb +21 -0
  39. data/lib/tester/models/test_nstring_encoding.rb +52 -0
  40. data/lib/tester/models/test_r_nstring_encoding.rb +52 -0
  41. data/lib/tester/models/test_rstring_encoding.rb +52 -0
  42. data/lib/tester/models/validate.rb +61 -0
  43. data/lib/tester/tester_client.rb +61 -0
  44. data/test/controllers/controller_test_base.rb +33 -0
  45. data/test/controllers/test_body_params_controller.rb +1210 -0
  46. data/test/controllers/test_echo_controller.rb +29 -0
  47. data/test/controllers/test_error_codes_controller.rb +47 -0
  48. data/test/controllers/test_form_params_controller.rb +1099 -0
  49. data/test/controllers/test_header_controller.rb +30 -0
  50. data/test/controllers/test_query_param_controller.rb +345 -0
  51. data/test/controllers/test_response_types_controller.rb +429 -0
  52. data/test/controllers/test_template_params_controller.rb +47 -0
  53. data/test/http_response_catcher.rb +16 -0
  54. data/test/test_helper.rb +91 -0
  55. metadata +178 -0
@@ -0,0 +1,47 @@
1
+ # This file was automatically generated for Stamplay by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ require_relative 'controller_test_base'
4
+
5
+ class TemplateParamsControllerTests < ControllerTestBase
6
+ # Called only once for the class before any test has executed
7
+ def self.startup
8
+ self.controller = @@api_client.template_params
9
+ end
10
+
11
+ # Todo: Add description for test test_send_string_array
12
+ def test_send_string_array()
13
+ # Parameters for the API call
14
+ strings = JSON.parse('["abc","def"]')
15
+
16
+ # Perform the API call through the SDK function
17
+ result = self.class.controller.send_string_array(strings)
18
+
19
+ # Test response code
20
+ assert_equal(@response_catcher.response.status_code, 200)
21
+
22
+ # Test whether the captured response is as we expected
23
+ assert_not_nil(result)
24
+ expected_body = JSON.parse('{"path":"/abc/def"}')
25
+ received_body = JSON.parse(@response_catcher.response.raw_body)
26
+ assert(TestHelper.match_body(expected_body, received_body, check_values: true))
27
+ end
28
+
29
+ # Todo: Add description for test test_send_integer_array
30
+ def test_send_integer_array()
31
+ # Parameters for the API call
32
+ integers = JSON.parse('[1,2,3,4,5]')
33
+
34
+ # Perform the API call through the SDK function
35
+ result = self.class.controller.send_integer_array(integers)
36
+
37
+ # Test response code
38
+ assert_equal(@response_catcher.response.status_code, 200)
39
+
40
+ # Test whether the captured response is as we expected
41
+ assert_not_nil(result)
42
+ expected_body = JSON.parse('{"path":"/1/2/3/4/5"}')
43
+ received_body = JSON.parse(@response_catcher.response.raw_body)
44
+ assert(TestHelper.match_body(expected_body, received_body, check_values: true))
45
+ end
46
+
47
+ end
@@ -0,0 +1,16 @@
1
+ # This file was automatically generated for Stamplay by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ class HttpResponseCatcher < Tester::HttpCallBack
4
+ attr_accessor :response
5
+
6
+ def on_before_request(request)
7
+ end
8
+
9
+ # Catching the response
10
+ def on_after_response(context)
11
+ @response = context.response
12
+ end
13
+ end
14
+
15
+
16
+
@@ -0,0 +1,91 @@
1
+ # This file was automatically generated for Stamplay by APIMATIC v2.0 ( https://apimatic.io ).
2
+
3
+ require 'tempfile'
4
+ require 'open-uri'
5
+
6
+ class TestHelper
7
+
8
+ @cache = Hash.new
9
+
10
+ # Class method to compare the received headers with the expected headers.
11
+ # @param [Hash] A hash of expected headers (keys in lower case).
12
+ # @param [Hash] A hash of received headers.
13
+ # @param [Boolean, optional] A flag which determines if we allow extra headers.
14
+ def self.match_headers(expected_headers,
15
+ received_headers,
16
+ allow_extra: true)
17
+ return false if ((received_headers.length < expected_headers.length) ||
18
+ ((allow_extra == false) && (received_headers.length > expected_headers.length)))
19
+
20
+ received_headers = Hash[received_headers.map{|k, v| [k.to_s.downcase, v]}]
21
+ expected_headers.each do |e_key, e_value|
22
+ return false unless received_headers.key?(e_key)
23
+ return false if ((e_value != nil) &&
24
+ (e_value != received_headers[e_key]))
25
+ end
26
+
27
+ return true
28
+ end
29
+
30
+ # Class method to compare the received body with the expected body.
31
+ # @param [Dynamic] The expected body.
32
+ # @param [Dynamic] The received body.
33
+ # @param [Boolean, optional] A flag which determines if we check values in dictionaries.
34
+ # @param [Boolean, optional] A flag which determines if we check the order of array elements.
35
+ # @param [Boolean, optional] A flag which determines if we check the count of array elements.
36
+ def self.match_body(expected_body,
37
+ received_body,
38
+ check_values: false,
39
+ check_order: false,
40
+ check_count: false)
41
+ if expected_body.instance_of? Hash
42
+ return false unless received_body.instance_of? Hash
43
+ for key in expected_body.keys
44
+ return false unless received_body.keys.include? key
45
+ if check_values or expected_body[key].instance_of? Hash
46
+ return false unless TestHelper.match_body(expected_body[key],
47
+ received_body[key],
48
+ check_values: check_values,
49
+ check_order: check_order,
50
+ check_count: check_count)
51
+ end
52
+ end
53
+ elsif expected_body.instance_of? Array
54
+ return False unless received_body.instance_of? Array
55
+ if check_count == true && (expected_body.length != received_body.length)
56
+ return false
57
+ else
58
+ previous_matches = Array.new
59
+ expected_body.each.with_index do |expected_element, i|
60
+ matches = (received_body.map.with_index do |received_element, j|
61
+ j if TestHelper.match_body(expected_element,
62
+ received_element,
63
+ check_values: check_values,
64
+ check_order: check_order,
65
+ check_count: check_count)
66
+ end).compact
67
+ return false if matches.length == 0
68
+ if check_order == true
69
+ return false if (i != 0 && matches.map{|x| previous_matches.map{|y| y > x}.all?}.all?)
70
+ previous_matches = matches
71
+ end
72
+ end
73
+ end
74
+ elsif expected_body != received_body
75
+ return false
76
+ end
77
+ return true
78
+ end
79
+
80
+ # Class method which takes a URL, downloads the file (if not already downloaded
81
+ # for this test session) and returns the path of the file.
82
+ # @param [String] The URL of the required file.
83
+ def self.get_file(url)
84
+ unless @cache.keys.include? url
85
+ @cache[url] = Tempfile.new('APIMatic')
86
+ @cache[url].binmode
87
+ @cache[url].write(open(url, {ssl_ca_cert: Certifi.where}).read)
88
+ end
89
+ return @cache[url].path
90
+ end
91
+ end
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hjhjhjnew
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - APIMatic SDK Generator
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-01-31 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.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.10.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.10.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.1.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.1.5
55
+ - !ruby/object:Gem::Dependency
56
+ name: certifi
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2016.9'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2016.09.26
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '2016.9'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2016.09.26
75
+ - !ruby/object:Gem::Dependency
76
+ name: faraday-http-cache
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.2'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 1.2.2
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '1.2'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 1.2.2
95
+ description: Testing various api features
96
+ email: support@apimatic.io
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - LICENSE
102
+ - README.md
103
+ - lib/tester.rb
104
+ - lib/tester/api_helper.rb
105
+ - lib/tester/configuration.rb
106
+ - lib/tester/controllers/base_controller.rb
107
+ - lib/tester/controllers/body_params_controller.rb
108
+ - lib/tester/controllers/echo_controller.rb
109
+ - lib/tester/controllers/error_codes_controller.rb
110
+ - lib/tester/controllers/form_params_controller.rb
111
+ - lib/tester/controllers/header_controller.rb
112
+ - lib/tester/controllers/query_param_controller.rb
113
+ - lib/tester/controllers/response_types_controller.rb
114
+ - lib/tester/controllers/template_params_controller.rb
115
+ - lib/tester/exceptions/api_exception.rb
116
+ - lib/tester/exceptions/global_test_exception.rb
117
+ - lib/tester/exceptions/local_test_exception.rb
118
+ - lib/tester/exceptions/nested_model_exception.rb
119
+ - lib/tester/http/faraday_client.rb
120
+ - lib/tester/http/http_call_back.rb
121
+ - lib/tester/http/http_client.rb
122
+ - lib/tester/http/http_context.rb
123
+ - lib/tester/http/http_method_enum.rb
124
+ - lib/tester/http/http_request.rb
125
+ - lib/tester/http/http_response.rb
126
+ - lib/tester/models/additional_model_parameters.rb
127
+ - lib/tester/models/base_model.rb
128
+ - lib/tester/models/boss.rb
129
+ - lib/tester/models/days.rb
130
+ - lib/tester/models/delete_body.rb
131
+ - lib/tester/models/echo_response.rb
132
+ - lib/tester/models/employee.rb
133
+ - lib/tester/models/job.rb
134
+ - lib/tester/models/person.rb
135
+ - lib/tester/models/query_parameter.rb
136
+ - lib/tester/models/server_response.rb
137
+ - lib/tester/models/suite_code.rb
138
+ - lib/tester/models/test_nstring_encoding.rb
139
+ - lib/tester/models/test_r_nstring_encoding.rb
140
+ - lib/tester/models/test_rstring_encoding.rb
141
+ - lib/tester/models/validate.rb
142
+ - lib/tester/tester_client.rb
143
+ - test/controllers/controller_test_base.rb
144
+ - test/controllers/test_body_params_controller.rb
145
+ - test/controllers/test_echo_controller.rb
146
+ - test/controllers/test_error_codes_controller.rb
147
+ - test/controllers/test_form_params_controller.rb
148
+ - test/controllers/test_header_controller.rb
149
+ - test/controllers/test_query_param_controller.rb
150
+ - test/controllers/test_response_types_controller.rb
151
+ - test/controllers/test_template_params_controller.rb
152
+ - test/http_response_catcher.rb
153
+ - test/test_helper.rb
154
+ homepage: https://apimatic.io
155
+ licenses:
156
+ - MIT
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '2.0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project:
174
+ rubygems_version: 2.7.3
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: tester
178
+ test_files: []