cheminee 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +72 -0
- data/README.md +90 -0
- data/Rakefile +10 -0
- data/cheminee.gemspec +38 -0
- data/docs/DefaultApi.md +70 -0
- data/docs/Smile.md +18 -0
- data/docs/StandardizedSmile.md +20 -0
- data/git_push.sh +57 -0
- data/lib/cheminee/api/default_api.rb +86 -0
- data/lib/cheminee/api_client.rb +391 -0
- data/lib/cheminee/api_error.rb +58 -0
- data/lib/cheminee/configuration.rb +290 -0
- data/lib/cheminee/models/smile.rb +221 -0
- data/lib/cheminee/models/standardized_smile.rb +223 -0
- data/lib/cheminee/version.rb +15 -0
- data/lib/cheminee.rb +42 -0
- data/openapi-generator-config.json +7 -0
- data/openapi.json +77 -0
- data/pkg/cheminee-0.0.15.gem +0 -0
- data/spec/api/default_api_spec.rb +45 -0
- data/spec/api_client_spec.rb +228 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/smile_spec.rb +34 -0
- data/spec/models/standardized_smile_spec.rb +40 -0
- data/spec/spec_helper.rb +111 -0
- metadata +115 -0
@@ -0,0 +1,223 @@
|
|
1
|
+
=begin
|
2
|
+
#Cheminée
|
3
|
+
|
4
|
+
#Cheminée: The Chemical Structure Search Engine
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 7.0.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Cheminee
|
17
|
+
class StandardizedSmile
|
18
|
+
attr_accessor :smile
|
19
|
+
|
20
|
+
attr_accessor :error
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'smile' => :'smile',
|
26
|
+
:'error' => :'error'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns all the JSON keys this model knows about
|
31
|
+
def self.acceptable_attributes
|
32
|
+
attribute_map.values
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'smile' => :'String',
|
39
|
+
:'error' => :'String'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# List of attributes with nullable: true
|
44
|
+
def self.openapi_nullable
|
45
|
+
Set.new([
|
46
|
+
])
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initializes the object
|
50
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
51
|
+
def initialize(attributes = {})
|
52
|
+
if (!attributes.is_a?(Hash))
|
53
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Cheminee::StandardizedSmile` initialize method"
|
54
|
+
end
|
55
|
+
|
56
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
58
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
59
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Cheminee::StandardizedSmile`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
60
|
+
end
|
61
|
+
h[k.to_sym] = v
|
62
|
+
}
|
63
|
+
|
64
|
+
if attributes.key?(:'smile')
|
65
|
+
self.smile = attributes[:'smile']
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.key?(:'error')
|
69
|
+
self.error = attributes[:'error']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
74
|
+
# @return Array for valid properties with the reasons
|
75
|
+
def list_invalid_properties
|
76
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
77
|
+
invalid_properties = Array.new
|
78
|
+
invalid_properties
|
79
|
+
end
|
80
|
+
|
81
|
+
# Check to see if the all the properties in the model are valid
|
82
|
+
# @return true if the model is valid
|
83
|
+
def valid?
|
84
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
85
|
+
true
|
86
|
+
end
|
87
|
+
|
88
|
+
# Checks equality by comparing each attribute.
|
89
|
+
# @param [Object] Object to be compared
|
90
|
+
def ==(o)
|
91
|
+
return true if self.equal?(o)
|
92
|
+
self.class == o.class &&
|
93
|
+
smile == o.smile &&
|
94
|
+
error == o.error
|
95
|
+
end
|
96
|
+
|
97
|
+
# @see the `==` method
|
98
|
+
# @param [Object] Object to be compared
|
99
|
+
def eql?(o)
|
100
|
+
self == o
|
101
|
+
end
|
102
|
+
|
103
|
+
# Calculates hash code according to all attributes.
|
104
|
+
# @return [Integer] Hash code
|
105
|
+
def hash
|
106
|
+
[smile, error].hash
|
107
|
+
end
|
108
|
+
|
109
|
+
# Builds the object from hash
|
110
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
111
|
+
# @return [Object] Returns the model itself
|
112
|
+
def self.build_from_hash(attributes)
|
113
|
+
return nil unless attributes.is_a?(Hash)
|
114
|
+
attributes = attributes.transform_keys(&:to_sym)
|
115
|
+
transformed_hash = {}
|
116
|
+
openapi_types.each_pair do |key, type|
|
117
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
118
|
+
transformed_hash["#{key}"] = nil
|
119
|
+
elsif type =~ /\AArray<(.*)>/i
|
120
|
+
# check to ensure the input is an array given that the attribute
|
121
|
+
# is documented as an array but the input is not
|
122
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
123
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
124
|
+
end
|
125
|
+
elsif !attributes[attribute_map[key]].nil?
|
126
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
127
|
+
end
|
128
|
+
end
|
129
|
+
new(transformed_hash)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Deserializes the data based on type
|
133
|
+
# @param string type Data type
|
134
|
+
# @param string value Value to be deserialized
|
135
|
+
# @return [Object] Deserialized data
|
136
|
+
def self._deserialize(type, value)
|
137
|
+
case type.to_sym
|
138
|
+
when :Time
|
139
|
+
Time.parse(value)
|
140
|
+
when :Date
|
141
|
+
Date.parse(value)
|
142
|
+
when :String
|
143
|
+
value.to_s
|
144
|
+
when :Integer
|
145
|
+
value.to_i
|
146
|
+
when :Float
|
147
|
+
value.to_f
|
148
|
+
when :Boolean
|
149
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
150
|
+
true
|
151
|
+
else
|
152
|
+
false
|
153
|
+
end
|
154
|
+
when :Object
|
155
|
+
# generic object (usually a Hash), return directly
|
156
|
+
value
|
157
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
158
|
+
inner_type = Regexp.last_match[:inner_type]
|
159
|
+
value.map { |v| _deserialize(inner_type, v) }
|
160
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
161
|
+
k_type = Regexp.last_match[:k_type]
|
162
|
+
v_type = Regexp.last_match[:v_type]
|
163
|
+
{}.tap do |hash|
|
164
|
+
value.each do |k, v|
|
165
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
else # model
|
169
|
+
# models (e.g. Pet) or oneOf
|
170
|
+
klass = Cheminee.const_get(type)
|
171
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns the string representation of the object
|
176
|
+
# @return [String] String presentation of the object
|
177
|
+
def to_s
|
178
|
+
to_hash.to_s
|
179
|
+
end
|
180
|
+
|
181
|
+
# to_body is an alias to to_hash (backward compatibility)
|
182
|
+
# @return [Hash] Returns the object in the form of hash
|
183
|
+
def to_body
|
184
|
+
to_hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Returns the object in the form of hash
|
188
|
+
# @return [Hash] Returns the object in the form of hash
|
189
|
+
def to_hash
|
190
|
+
hash = {}
|
191
|
+
self.class.attribute_map.each_pair do |attr, param|
|
192
|
+
value = self.send(attr)
|
193
|
+
if value.nil?
|
194
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
195
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
196
|
+
end
|
197
|
+
|
198
|
+
hash[param] = _to_hash(value)
|
199
|
+
end
|
200
|
+
hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# Outputs non-array value in the form of hash
|
204
|
+
# For object, use to_hash. Otherwise, just return the value
|
205
|
+
# @param [Object] value Any valid value
|
206
|
+
# @return [Hash] Returns the value in the form of hash
|
207
|
+
def _to_hash(value)
|
208
|
+
if value.is_a?(Array)
|
209
|
+
value.compact.map { |v| _to_hash(v) }
|
210
|
+
elsif value.is_a?(Hash)
|
211
|
+
{}.tap do |hash|
|
212
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
213
|
+
end
|
214
|
+
elsif value.respond_to? :to_hash
|
215
|
+
value.to_hash
|
216
|
+
else
|
217
|
+
value
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
=begin
|
2
|
+
#Cheminée
|
3
|
+
|
4
|
+
#Cheminée: The Chemical Structure Search Engine
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 7.0.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
module Cheminee
|
14
|
+
VERSION = '0.0.15'
|
15
|
+
end
|
data/lib/cheminee.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
=begin
|
2
|
+
#Cheminée
|
3
|
+
|
4
|
+
#Cheminée: The Chemical Structure Search Engine
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 7.0.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
# Common files
|
14
|
+
require 'cheminee/api_client'
|
15
|
+
require 'cheminee/api_error'
|
16
|
+
require 'cheminee/version'
|
17
|
+
require 'cheminee/configuration'
|
18
|
+
|
19
|
+
# Models
|
20
|
+
require 'cheminee/models/smile'
|
21
|
+
require 'cheminee/models/standardized_smile'
|
22
|
+
|
23
|
+
# APIs
|
24
|
+
require 'cheminee/api/default_api'
|
25
|
+
|
26
|
+
module Cheminee
|
27
|
+
class << self
|
28
|
+
# Customize default settings for the SDK using block.
|
29
|
+
# Cheminee.configure do |config|
|
30
|
+
# config.username = "xxx"
|
31
|
+
# config.password = "xxx"
|
32
|
+
# end
|
33
|
+
# If no block given, return the default Configuration object.
|
34
|
+
def configure
|
35
|
+
if block_given?
|
36
|
+
yield(Configuration.default)
|
37
|
+
else
|
38
|
+
Configuration.default
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/openapi.json
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
{
|
2
|
+
"openapi": "3.0.0",
|
3
|
+
"info": {
|
4
|
+
"title": "Cheminée",
|
5
|
+
"description": "Cheminée: The Chemical Structure Search Engine",
|
6
|
+
"version": "1.0",
|
7
|
+
"contact": {
|
8
|
+
"url": "https://github.com/rdkit-rs/cheminee"
|
9
|
+
}
|
10
|
+
},
|
11
|
+
"servers": [
|
12
|
+
{
|
13
|
+
"url": "http://localhost:3000/api/v1"
|
14
|
+
}
|
15
|
+
],
|
16
|
+
"tags": [],
|
17
|
+
"paths": {
|
18
|
+
"/standardize": {
|
19
|
+
"post": {
|
20
|
+
"requestBody": {
|
21
|
+
"content": {
|
22
|
+
"application/json; charset=utf-8": {
|
23
|
+
"schema": {
|
24
|
+
"type": "array",
|
25
|
+
"items": {
|
26
|
+
"$ref": "#/components/schemas/Smile"
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
},
|
31
|
+
"required": true
|
32
|
+
},
|
33
|
+
"responses": {
|
34
|
+
"200": {
|
35
|
+
"description": "",
|
36
|
+
"content": {
|
37
|
+
"application/json; charset=utf-8": {
|
38
|
+
"schema": {
|
39
|
+
"type": "array",
|
40
|
+
"items": {
|
41
|
+
"$ref": "#/components/schemas/StandardizedSmile"
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
},
|
51
|
+
"components": {
|
52
|
+
"schemas": {
|
53
|
+
"Smile": {
|
54
|
+
"type": "object",
|
55
|
+
"required": [
|
56
|
+
"smile"
|
57
|
+
],
|
58
|
+
"properties": {
|
59
|
+
"smile": {
|
60
|
+
"type": "string"
|
61
|
+
}
|
62
|
+
}
|
63
|
+
},
|
64
|
+
"StandardizedSmile": {
|
65
|
+
"type": "object",
|
66
|
+
"properties": {
|
67
|
+
"smile": {
|
68
|
+
"type": "string"
|
69
|
+
},
|
70
|
+
"error": {
|
71
|
+
"type": "string"
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
Binary file
|
@@ -0,0 +1,45 @@
|
|
1
|
+
=begin
|
2
|
+
#Cheminée
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 6.2.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for Cheminee::DefaultApi
|
17
|
+
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'DefaultApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
@api_instance = Cheminee::DefaultApi.new
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
# run after each test
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test an instance of DefaultApi' do
|
30
|
+
it 'should create an instance of DefaultApi' do
|
31
|
+
expect(@api_instance).to be_instance_of(Cheminee::DefaultApi)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# unit tests for standardize_post
|
36
|
+
# @param smile
|
37
|
+
# @param [Hash] opts the optional parameters
|
38
|
+
# @return [Array<Smile>]
|
39
|
+
describe 'standardize_post test' do
|
40
|
+
it 'should work' do
|
41
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,228 @@
|
|
1
|
+
=begin
|
2
|
+
#Cheminée
|
3
|
+
|
4
|
+
#Cheminée: The Chemical Structure Search Engine
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 7.0.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
|
15
|
+
describe Cheminee::ApiClient do
|
16
|
+
context 'initialization' do
|
17
|
+
context 'URL stuff' do
|
18
|
+
context 'host' do
|
19
|
+
it 'removes http from host' do
|
20
|
+
Cheminee.configure { |c| c.host = 'http://example.com' }
|
21
|
+
expect(Cheminee::Configuration.default.host).to eq('example.com')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'removes https from host' do
|
25
|
+
Cheminee.configure { |c| c.host = 'https://wookiee.com' }
|
26
|
+
expect(Cheminee::ApiClient.default.config.host).to eq('wookiee.com')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'removes trailing path from host' do
|
30
|
+
Cheminee.configure { |c| c.host = 'hobo.com/v4' }
|
31
|
+
expect(Cheminee::Configuration.default.host).to eq('hobo.com')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'base_path' do
|
36
|
+
it "prepends a slash to base_path" do
|
37
|
+
Cheminee.configure { |c| c.base_path = 'v4/dog' }
|
38
|
+
expect(Cheminee::Configuration.default.base_path).to eq('/v4/dog')
|
39
|
+
end
|
40
|
+
|
41
|
+
it "doesn't prepend a slash if one is already there" do
|
42
|
+
Cheminee.configure { |c| c.base_path = '/v4/dog' }
|
43
|
+
expect(Cheminee::Configuration.default.base_path).to eq('/v4/dog')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "ends up as a blank string if nil" do
|
47
|
+
Cheminee.configure { |c| c.base_path = nil }
|
48
|
+
expect(Cheminee::Configuration.default.base_path).to eq('')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'params_encoding in #build_request' do
|
55
|
+
let(:config) { Cheminee::Configuration.new }
|
56
|
+
let(:api_client) { Cheminee::ApiClient.new(config) }
|
57
|
+
|
58
|
+
it 'defaults to nil' do
|
59
|
+
expect(Cheminee::Configuration.default.params_encoding).to eq(nil)
|
60
|
+
expect(config.params_encoding).to eq(nil)
|
61
|
+
|
62
|
+
request = api_client.build_request(:get, '/test')
|
63
|
+
expect(request.options[:params_encoding]).to eq(nil)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'can be customized' do
|
67
|
+
config.params_encoding = :multi
|
68
|
+
request = api_client.build_request(:get, '/test')
|
69
|
+
expect(request.options[:params_encoding]).to eq(:multi)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'timeout in #build_request' do
|
74
|
+
let(:config) { Cheminee::Configuration.new }
|
75
|
+
let(:api_client) { Cheminee::ApiClient.new(config) }
|
76
|
+
|
77
|
+
it 'defaults to 0' do
|
78
|
+
expect(Cheminee::Configuration.default.timeout).to eq(0)
|
79
|
+
expect(config.timeout).to eq(0)
|
80
|
+
|
81
|
+
request = api_client.build_request(:get, '/test')
|
82
|
+
expect(request.options[:timeout]).to eq(0)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'can be customized' do
|
86
|
+
config.timeout = 100
|
87
|
+
request = api_client.build_request(:get, '/test')
|
88
|
+
expect(request.options[:timeout]).to eq(100)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
describe '#deserialize' do
|
95
|
+
it "handles Array<Integer>" do
|
96
|
+
api_client = Cheminee::ApiClient.new
|
97
|
+
headers = { 'Content-Type' => 'application/json' }
|
98
|
+
response = double('response', headers: headers, body: '[12, 34]')
|
99
|
+
data = api_client.deserialize(response, 'Array<Integer>')
|
100
|
+
expect(data).to be_instance_of(Array)
|
101
|
+
expect(data).to eq([12, 34])
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'handles Array<Array<Integer>>' do
|
105
|
+
api_client = Cheminee::ApiClient.new
|
106
|
+
headers = { 'Content-Type' => 'application/json' }
|
107
|
+
response = double('response', headers: headers, body: '[[12, 34], [56]]')
|
108
|
+
data = api_client.deserialize(response, 'Array<Array<Integer>>')
|
109
|
+
expect(data).to be_instance_of(Array)
|
110
|
+
expect(data).to eq([[12, 34], [56]])
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'handles Hash<String, String>' do
|
114
|
+
api_client = Cheminee::ApiClient.new
|
115
|
+
headers = { 'Content-Type' => 'application/json' }
|
116
|
+
response = double('response', headers: headers, body: '{"message": "Hello"}')
|
117
|
+
data = api_client.deserialize(response, 'Hash<String, String>')
|
118
|
+
expect(data).to be_instance_of(Hash)
|
119
|
+
expect(data).to eq(:message => 'Hello')
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe "#object_to_hash" do
|
124
|
+
it 'ignores nils and includes empty arrays' do
|
125
|
+
# uncomment below to test object_to_hash for model
|
126
|
+
# api_client = Cheminee::ApiClient.new
|
127
|
+
# _model = Cheminee::ModelName.new
|
128
|
+
# update the model attribute below
|
129
|
+
# _model.id = 1
|
130
|
+
# update the expected value (hash) below
|
131
|
+
# expected = {id: 1, name: '', tags: []}
|
132
|
+
# expect(api_client.object_to_hash(_model)).to eq(expected)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe '#build_collection_param' do
|
137
|
+
let(:param) { ['aa', 'bb', 'cc'] }
|
138
|
+
let(:api_client) { Cheminee::ApiClient.new }
|
139
|
+
|
140
|
+
it 'works for csv' do
|
141
|
+
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'works for ssv' do
|
145
|
+
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'works for tsv' do
|
149
|
+
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'works for pipes' do
|
153
|
+
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'works for multi' do
|
157
|
+
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'fails for invalid collection format' do
|
161
|
+
expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe '#json_mime?' do
|
166
|
+
let(:api_client) { Cheminee::ApiClient.new }
|
167
|
+
|
168
|
+
it 'works' do
|
169
|
+
expect(api_client.json_mime?(nil)).to eq false
|
170
|
+
expect(api_client.json_mime?('')).to eq false
|
171
|
+
|
172
|
+
expect(api_client.json_mime?('application/json')).to eq true
|
173
|
+
expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
|
174
|
+
expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
|
175
|
+
|
176
|
+
expect(api_client.json_mime?('application/xml')).to eq false
|
177
|
+
expect(api_client.json_mime?('text/plain')).to eq false
|
178
|
+
expect(api_client.json_mime?('application/jsonp')).to eq false
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe '#select_header_accept' do
|
183
|
+
let(:api_client) { Cheminee::ApiClient.new }
|
184
|
+
|
185
|
+
it 'works' do
|
186
|
+
expect(api_client.select_header_accept(nil)).to be_nil
|
187
|
+
expect(api_client.select_header_accept([])).to be_nil
|
188
|
+
|
189
|
+
expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
|
190
|
+
expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
191
|
+
expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
192
|
+
|
193
|
+
expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
|
194
|
+
expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
describe '#select_header_content_type' do
|
199
|
+
let(:api_client) { Cheminee::ApiClient.new }
|
200
|
+
|
201
|
+
it 'works' do
|
202
|
+
expect(api_client.select_header_content_type(nil)).to be_nil
|
203
|
+
expect(api_client.select_header_content_type([])).to be_nil
|
204
|
+
|
205
|
+
expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
|
206
|
+
expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
207
|
+
expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
208
|
+
expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
|
209
|
+
expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe '#sanitize_filename' do
|
214
|
+
let(:api_client) { Cheminee::ApiClient.new }
|
215
|
+
|
216
|
+
it 'works' do
|
217
|
+
expect(api_client.sanitize_filename('sun')).to eq('sun')
|
218
|
+
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
|
219
|
+
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
|
220
|
+
expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
|
221
|
+
expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
|
222
|
+
expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
|
223
|
+
expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
|
224
|
+
expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
|
225
|
+
expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
=begin
|
2
|
+
#Cheminée
|
3
|
+
|
4
|
+
#Cheminée: The Chemical Structure Search Engine
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 7.0.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
|
15
|
+
describe Cheminee::Configuration do
|
16
|
+
let(:config) { Cheminee::Configuration.default }
|
17
|
+
|
18
|
+
before(:each) do
|
19
|
+
# uncomment below to setup host and base_path
|
20
|
+
# require 'URI'
|
21
|
+
# uri = URI.parse("http://localhost:3000/api/v1")
|
22
|
+
# Cheminee.configure do |c|
|
23
|
+
# c.host = uri.host
|
24
|
+
# c.base_path = uri.path
|
25
|
+
# end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#base_url' do
|
29
|
+
it 'should have the default value' do
|
30
|
+
# uncomment below to test default value of the base path
|
31
|
+
# expect(config.base_url).to eq("http://localhost:3000/api/v1")
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should remove trailing slashes' do
|
35
|
+
[nil, '', '/', '//'].each do |base_path|
|
36
|
+
config.base_path = base_path
|
37
|
+
# uncomment below to test trailing slashes
|
38
|
+
# expect(config.base_url).to eq("http://localhost:3000/api/v1")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|