blueprint_ruby_client 0.5.0 → 0.5.1
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/Gemfile.lock +1 -1
- data/README.md +5 -5
- data/config.json +1 -1
- data/docs/AssetsApi.md +3 -3
- data/docs/HierarchyApi.md +19 -19
- data/docs/IntegrationTransformExample.md +1 -1
- data/docs/IntegrationsApi.md +4 -4
- data/docs/LTIApi.md +4 -4
- data/generate.sh +1 -1
- data/lib/blueprint_ruby_client/api/asset_type_configs_api.rb +15 -1
- data/lib/blueprint_ruby_client/api/asset_type_templates_api.rb +55 -1
- data/lib/blueprint_ruby_client/api/assets_api.rb +175 -7
- data/lib/blueprint_ruby_client/api/hierarchy_api.rb +393 -33
- data/lib/blueprint_ruby_client/api/integrations_api.rb +203 -3
- data/lib/blueprint_ruby_client/api/lti_api.rb +121 -1
- data/lib/blueprint_ruby_client/api/security_api.rb +3 -1
- data/lib/blueprint_ruby_client/api_client.rb +2 -0
- data/lib/blueprint_ruby_client/models/asset.rb +57 -0
- data/lib/blueprint_ruby_client/models/asset_body.rb +40 -0
- data/lib/blueprint_ruby_client/models/asset_relationship.rb +55 -0
- data/lib/blueprint_ruby_client/models/asset_result_set.rb +55 -0
- data/lib/blueprint_ruby_client/models/error.rb +57 -0
- data/lib/blueprint_ruby_client/models/errors.rb +23 -0
- data/lib/blueprint_ruby_client/models/integration.rb +57 -0
- data/lib/blueprint_ruby_client/models/integration_body.rb +40 -0
- data/lib/blueprint_ruby_client/models/integration_transform.rb +73 -0
- data/lib/blueprint_ruby_client/models/integration_transform_example.rb +53 -13
- data/lib/blueprint_ruby_client/models/links.rb +55 -0
- data/lib/blueprint_ruby_client/models/lti1_integration_attributes.rb +74 -0
- data/lib/blueprint_ruby_client/models/meta.rb +55 -0
- data/lib/blueprint_ruby_client/models/namespace.rb +41 -0
- data/lib/blueprint_ruby_client/models/namespace_relationship.rb +23 -0
- data/lib/blueprint_ruby_client/models/node.rb +73 -0
- data/lib/blueprint_ruby_client/models/node_attributes.rb +135 -0
- data/lib/blueprint_ruby_client/models/node_body.rb +40 -0
- data/lib/blueprint_ruby_client/models/node_relationship.rb +55 -0
- data/lib/blueprint_ruby_client/models/node_relationships.rb +71 -0
- data/lib/blueprint_ruby_client/models/node_result_set.rb +55 -0
- data/lib/blueprint_ruby_client/models/resource.rb +57 -0
- data/lib/blueprint_ruby_client/models/template.rb +58 -0
- data/lib/blueprint_ruby_client/models/template_attributes.rb +40 -18
- data/lib/blueprint_ruby_client/models/template_body.rb +40 -0
- data/lib/blueprint_ruby_client/models/template_variables.rb +43 -38
- data/lib/blueprint_ruby_client/version.rb +1 -1
- data/spec/api/assets_api_spec.rb +1 -1
- data/spec/api/hierarchy_api_spec.rb +9 -9
- data/spec/models/integration_transform_example_spec.rb +2 -2
- metadata +4 -11
- data/git_push.sh +0 -67
- data/spec/api_client_spec.rb +0 -226
- data/spec/configuration_spec.rb +0 -42
- data/spec/spec_helper.rb +0 -111
- data/swagger-codegen-cli.jar +0 -0
@@ -21,16 +21,22 @@ module BlueprintClient
|
|
21
21
|
# Attribute mapping from ruby-style variable name to JSON key.
|
22
22
|
def self.attribute_map
|
23
23
|
{
|
24
|
+
|
24
25
|
:'field' => :'field',
|
26
|
+
|
25
27
|
:'data' => :'data'
|
28
|
+
|
26
29
|
}
|
27
30
|
end
|
28
31
|
|
29
32
|
# Attribute type mapping.
|
30
33
|
def self.swagger_types
|
31
34
|
{
|
35
|
+
|
32
36
|
:'field' => :'String',
|
37
|
+
|
33
38
|
:'data' => :'String'
|
39
|
+
|
34
40
|
}
|
35
41
|
end
|
36
42
|
|
@@ -42,72 +48,71 @@ module BlueprintClient
|
|
42
48
|
# convert string to symbol for hash key
|
43
49
|
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
44
50
|
|
51
|
+
|
45
52
|
if attributes.has_key?(:'field')
|
53
|
+
|
54
|
+
|
46
55
|
self.field = attributes[:'field']
|
56
|
+
|
57
|
+
|
47
58
|
end
|
48
59
|
|
60
|
+
|
49
61
|
if attributes.has_key?(:'data')
|
62
|
+
|
63
|
+
|
50
64
|
self.data = attributes[:'data']
|
65
|
+
|
66
|
+
|
51
67
|
end
|
52
68
|
|
69
|
+
|
53
70
|
end
|
54
71
|
|
55
72
|
# Show invalid properties with the reasons. Usually used together with valid?
|
56
73
|
# @return Array for valid properies with the reasons
|
57
74
|
def list_invalid_properties
|
58
75
|
invalid_properties = Array.new
|
76
|
+
|
77
|
+
|
59
78
|
return invalid_properties
|
60
79
|
end
|
61
80
|
|
62
81
|
# Check to see if the all the properties in the model are valid
|
63
82
|
# @return true if the model is valid
|
64
83
|
def valid?
|
84
|
+
|
85
|
+
|
65
86
|
if @field.nil?
|
66
87
|
return false
|
67
88
|
end
|
68
89
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
73
95
|
if @data.nil?
|
74
96
|
return false
|
75
97
|
end
|
76
98
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
@field = field
|
95
|
-
end
|
96
|
-
|
97
|
-
# Custom attribute writer method with validation
|
98
|
-
# @param [Object] data Value to be assigned
|
99
|
-
def data=(data)
|
100
|
-
if data.nil?
|
101
|
-
fail ArgumentError, "data cannot be nil"
|
102
|
-
end
|
103
|
-
|
104
|
-
if @data !~ Regexp.new(/^(assets\\.(id|type|attributes\\..+)|(nodes\\.(id|type|attributes\\..+))|(integrations\\..+))$/)
|
105
|
-
fail ArgumentError, "invalid value for 'data', must conform to the pattern ^(assets\\.(id|type|attributes\\..+)|(nodes\\.(id|type|attributes\\..+))|(integrations\\..+))$."
|
106
|
-
end
|
107
|
-
|
108
|
-
@data = data
|
109
|
-
end
|
110
|
-
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
111
116
|
# Checks equality by comparing each attribute.
|
112
117
|
# @param [Object] Object to be compared
|
113
118
|
def ==(o)
|
data/spec/api/assets_api_spec.rb
CHANGED
@@ -131,7 +131,7 @@ describe 'AssetsApi' do
|
|
131
131
|
|
132
132
|
# unit tests for replace_asset
|
133
133
|
# Replaces the Asset with the data sent in the body
|
134
|
-
# Wholesale replacement of Asset data: if you were to PUT to
|
134
|
+
# Wholesale replacement of Asset data: if you were to PUT to:\n /1/{namespace}/assets/sometype/someid\n\nwith a body of:\n { type: \"someothertype\", id: \"someotherid\" }\n\nIt would change the Asset's path to:\n /1/{namespace}/assets/someothertype/someotherid\n\nand\n /1/{namespace}/assets/sometype/someid\nwould return a 404.\nIt would also update the assets associated with any node.\n
|
135
135
|
# @param namespace identifier namespacing the blueprint.
|
136
136
|
# @param asset_id id of an asset
|
137
137
|
# @param asset_type subtype of Asset, e.g. 'textbooks', 'digitisations', etc.
|
@@ -35,7 +35,7 @@ describe 'HierarchyApi' do
|
|
35
35
|
# unit tests for add_node
|
36
36
|
#
|
37
37
|
# Add a node
|
38
|
-
# @param namespace_inc_global identifier namespacing the blueprint.
|
38
|
+
# @param namespace_inc_global identifier namespacing the blueprint. `global` is a special namespace which references data from all blueprints in the call.
|
39
39
|
# @param body node
|
40
40
|
# @param [Hash] opts the optional parameters
|
41
41
|
# @return [NodeBody]
|
@@ -51,7 +51,7 @@ describe 'HierarchyApi' do
|
|
51
51
|
|
52
52
|
# unit tests for bulk_upload
|
53
53
|
#
|
54
|
-
# Send operations to modify nodes in bulk, to be applied/rejected as a single transaction
|
54
|
+
# Send operations to modify nodes in bulk, to be applied/rejected as a single transaction.\nFormat will be:\n\n OLD NODE TYPE, OLD NODE ID, NEW NODE TYPE, NEW NODE ID, PARENTS, TITLE, DESCRIPTION, DOMAIN IDS, STUDENT NUMBERS\n
|
55
55
|
# @param namespace identifier namespacing the blueprint.
|
56
56
|
# @param [Hash] opts the optional parameters
|
57
57
|
# @return [nil]
|
@@ -85,7 +85,7 @@ describe 'HierarchyApi' do
|
|
85
85
|
|
86
86
|
# unit tests for export_hierarchy
|
87
87
|
#
|
88
|
-
# Download the blueprint's nodes in CSV format
|
88
|
+
# Download the blueprint's nodes in CSV format\nFormat will be:\n\n OLD NODE TYPE, OLD NODE ID, NEW NODE TYPE, NEW NODE ID, PARENTS, TITLE, DESCRIPTION, DOMAIN IDS, STUDENT NUMBERS\n\nOLD NODE TYPE and OLD NODE ID are left intentionally blank to allow direct upload of the output back into the bulk importer\n
|
89
89
|
# @param namespace identifier namespacing the blueprint.
|
90
90
|
# @param [Hash] opts the optional parameters
|
91
91
|
# @return [nil]
|
@@ -101,7 +101,7 @@ describe 'HierarchyApi' do
|
|
101
101
|
|
102
102
|
# unit tests for get_ancestors
|
103
103
|
# Get ancestor nodes
|
104
|
-
# A proxy for finding ancestors of a given node, equivalent to
|
104
|
+
# A proxy for finding ancestors of a given node, equivalent to\n`/1/abc/nodes?filter[descendant]=department%2Fdep101`\n
|
105
105
|
# @param id id identifying a domain model
|
106
106
|
# @param namespace identifier namespacing the blueprint.
|
107
107
|
# @param type subtype of Node, e.g. 'modules', 'departments', etc.
|
@@ -121,7 +121,7 @@ describe 'HierarchyApi' do
|
|
121
121
|
|
122
122
|
# unit tests for get_children
|
123
123
|
# Get child nodes
|
124
|
-
# A proxy for finding children of a given node, equivalent to
|
124
|
+
# A proxy for finding children of a given node, equivalent to\n`/1/abc/nodes?filter[parent]=department%2Fdep101`\n
|
125
125
|
# @param id id identifying a domain model
|
126
126
|
# @param namespace identifier namespacing the blueprint.
|
127
127
|
# @param type subtype of Node, e.g. 'modules', 'departments', etc.
|
@@ -141,7 +141,7 @@ describe 'HierarchyApi' do
|
|
141
141
|
|
142
142
|
# unit tests for get_descendants
|
143
143
|
# Get descendant nodes
|
144
|
-
# A proxy for finding descendants of a given node, equivalent to
|
144
|
+
# A proxy for finding descendants of a given node, equivalent to\n`/1/abc/nodes?filter[ancestor]=department%2Fdep101`\n
|
145
145
|
# @param id id identifying a domain model
|
146
146
|
# @param namespace identifier namespacing the blueprint.
|
147
147
|
# @param type subtype of Node, e.g. 'modules', 'departments', etc.
|
@@ -180,7 +180,7 @@ describe 'HierarchyApi' do
|
|
180
180
|
|
181
181
|
# unit tests for get_parents
|
182
182
|
# Get parent nodes
|
183
|
-
# A proxy for finding parents of a given node, equivalent to
|
183
|
+
# A proxy for finding parents of a given node, equivalent to\n`/1/abc/nodes?filter[child]=department%2Fdep101`\n
|
184
184
|
# @param id id identifying a domain model
|
185
185
|
# @param namespace identifier namespacing the blueprint.
|
186
186
|
# @param type subtype of Node, e.g. 'modules', 'departments', etc.
|
@@ -219,8 +219,8 @@ describe 'HierarchyApi' do
|
|
219
219
|
|
220
220
|
# unit tests for search_nodes
|
221
221
|
# Search nodes
|
222
|
-
# This endpoint is a really flexible way to ask questions about the hierarchy. for example
|
223
|
-
# @param namespace_inc_global identifier namespacing the blueprint.
|
222
|
+
# This endpoint is a really flexible way to ask questions about the hierarchy. for example:\n\n###### Find all nodes for abc:\n`/1/abc/nodes`\n\n###### Find all modules for abc:\n`/1/abc/nodes?filter[nodeType]=Modules`\n\n###### Find all nodes that are descendants of DEP101:\n`/1/abc/nodes?filter[descendant]=departments%2Fdep101`\n\n###### Find all Departments that are ancestors of ABF203:\n`/1/abc/nodes?filter[descendant]=modules%2Fabf203&filter[nodeType]=Departments` # <= case insensitive\n\n###### Find all nodes with list assets that are descendants of DEP101 for abc:\n`/1/abc/nodes?filter[nodeType]=Modules&filter[ancestor]=departments%2FDEP101&filter[hasAssets]=true&filter[assetType]=Lists`\n\n###### Globally, find all modules that have no list assets\n`/1/global/nodes?filter[nodeType]=Modules&filter[hasAssets]=false&filter[assetType]=Lists`\n\n###### Find all nodes of type modules during 2015 that have no assets. Note a node's valid_from/valid_to just need to overlap from/to to qualify\n`/1/global/nodes?filter[nodeType]=Modules&filter[hasAssets]=false&filter[from]=20150101&filter[to]=20151231`\n
|
223
|
+
# @param namespace_inc_global identifier namespacing the blueprint. `global` is a special namespace which references data from all blueprints in the call.
|
224
224
|
# @param [Hash] opts the optional parameters
|
225
225
|
# @option opts [Float] :offset index to start result set from
|
226
226
|
# @option opts [Float] :limit number of records to return
|
@@ -32,7 +32,7 @@ describe 'IntegrationTransformExample' do
|
|
32
32
|
@instance.should be_a(BlueprintClient::IntegrationTransformExample)
|
33
33
|
end
|
34
34
|
end
|
35
|
-
describe 'test attribute "
|
35
|
+
describe 'test attribute "output"' do
|
36
36
|
it 'should work' do
|
37
37
|
# assertion here
|
38
38
|
# should be_a()
|
@@ -42,7 +42,7 @@ describe 'IntegrationTransformExample' do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
describe 'test attribute "
|
45
|
+
describe 'test attribute "input"' do
|
46
46
|
it 'should work' do
|
47
47
|
# assertion here
|
48
48
|
# should be_a()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blueprint_ruby_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Paddock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -237,7 +237,6 @@ files:
|
|
237
237
|
- docs/TemplateBody.md
|
238
238
|
- docs/TemplateVariables.md
|
239
239
|
- generate.sh
|
240
|
-
- git_push.sh
|
241
240
|
- lib/blueprint_ruby_client.rb
|
242
241
|
- lib/blueprint_ruby_client/api/asset_type_configs_api.rb
|
243
242
|
- lib/blueprint_ruby_client/api/asset_type_templates_api.rb
|
@@ -283,8 +282,6 @@ files:
|
|
283
282
|
- spec/api/integrations_api_spec.rb
|
284
283
|
- spec/api/lti_api_spec.rb
|
285
284
|
- spec/api/security_api_spec.rb
|
286
|
-
- spec/api_client_spec.rb
|
287
|
-
- spec/configuration_spec.rb
|
288
285
|
- spec/models/asset_body_spec.rb
|
289
286
|
- spec/models/asset_relationship_spec.rb
|
290
287
|
- spec/models/asset_result_set_spec.rb
|
@@ -311,8 +308,6 @@ files:
|
|
311
308
|
- spec/models/template_body_spec.rb
|
312
309
|
- spec/models/template_spec.rb
|
313
310
|
- spec/models/template_variables_spec.rb
|
314
|
-
- spec/spec_helper.rb
|
315
|
-
- swagger-codegen-cli.jar
|
316
311
|
- templates/Gemfile.mustache
|
317
312
|
- templates/README.mustache
|
318
313
|
- templates/api.mustache
|
@@ -350,7 +345,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
350
345
|
version: '0'
|
351
346
|
requirements: []
|
352
347
|
rubyforge_project:
|
353
|
-
rubygems_version: 2.5.1
|
348
|
+
rubygems_version: 2.4.5.1
|
354
349
|
signing_key:
|
355
350
|
specification_version: 4
|
356
351
|
summary: A ruby API wrapper for Blueprint
|
@@ -362,8 +357,6 @@ test_files:
|
|
362
357
|
- spec/api/integrations_api_spec.rb
|
363
358
|
- spec/api/lti_api_spec.rb
|
364
359
|
- spec/api/security_api_spec.rb
|
365
|
-
- spec/api_client_spec.rb
|
366
|
-
- spec/configuration_spec.rb
|
367
360
|
- spec/models/asset_body_spec.rb
|
368
361
|
- spec/models/asset_relationship_spec.rb
|
369
362
|
- spec/models/asset_result_set_spec.rb
|
@@ -390,4 +383,4 @@ test_files:
|
|
390
383
|
- spec/models/template_body_spec.rb
|
391
384
|
- spec/models/template_spec.rb
|
392
385
|
- spec/models/template_variables_spec.rb
|
393
|
-
|
386
|
+
has_rdoc:
|
data/git_push.sh
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#
|
3
|
-
# Generated by: https://github.com/swagger-api/swagger-codegen.git
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
18
|
-
#
|
19
|
-
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
20
|
-
|
21
|
-
git_user_id=$1
|
22
|
-
git_repo_id=$2
|
23
|
-
release_note=$3
|
24
|
-
|
25
|
-
if [ "$git_user_id" = "" ]; then
|
26
|
-
git_user_id="talis"
|
27
|
-
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
28
|
-
fi
|
29
|
-
|
30
|
-
if [ "$git_repo_id" = "" ]; then
|
31
|
-
git_repo_id="blueprint_rb"
|
32
|
-
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
33
|
-
fi
|
34
|
-
|
35
|
-
if [ "$release_note" = "" ]; then
|
36
|
-
release_note="Minor update"
|
37
|
-
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
38
|
-
fi
|
39
|
-
|
40
|
-
# Initialize the local directory as a Git repository
|
41
|
-
git init
|
42
|
-
|
43
|
-
# Adds the files in the local repository and stages them for commit.
|
44
|
-
git add .
|
45
|
-
|
46
|
-
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
47
|
-
git commit -m "$release_note"
|
48
|
-
|
49
|
-
# Sets the new remote
|
50
|
-
git_remote=`git remote`
|
51
|
-
if [ "$git_remote" = "" ]; then # git remote not defined
|
52
|
-
|
53
|
-
if [ "$GIT_TOKEN" = "" ]; then
|
54
|
-
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
|
55
|
-
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
56
|
-
else
|
57
|
-
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
58
|
-
fi
|
59
|
-
|
60
|
-
fi
|
61
|
-
|
62
|
-
git pull origin master
|
63
|
-
|
64
|
-
# Pushes (Forces) the changes in the local repository up to the remote repository
|
65
|
-
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
66
|
-
git push origin master 2>&1 | grep -v 'To https'
|
67
|
-
|
data/spec/api_client_spec.rb
DELETED
@@ -1,226 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
Talis Blueprint API
|
3
|
-
|
4
|
-
This is the API documentation for [Blueprint](https://github.com/talis/blueprint-server), a primitive for institutional structure and time periods
|
5
|
-
|
6
|
-
OpenAPI spec version: 1.0.0
|
7
|
-
|
8
|
-
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'spec_helper'
|
14
|
-
|
15
|
-
describe BlueprintClient::ApiClient do
|
16
|
-
context 'initialization' do
|
17
|
-
context 'URL stuff' do
|
18
|
-
context 'host' do
|
19
|
-
it 'removes http from host' do
|
20
|
-
BlueprintClient.configure { |c| c.host = 'http://example.com' }
|
21
|
-
expect(BlueprintClient::Configuration.default.host).to eq('example.com')
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'removes https from host' do
|
25
|
-
BlueprintClient.configure { |c| c.host = 'https://wookiee.com' }
|
26
|
-
expect(BlueprintClient::ApiClient.default.config.host).to eq('wookiee.com')
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'removes trailing path from host' do
|
30
|
-
BlueprintClient.configure { |c| c.host = 'hobo.com/v4' }
|
31
|
-
expect(BlueprintClient::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
|
-
BlueprintClient.configure { |c| c.base_path = 'v4/dog' }
|
38
|
-
expect(BlueprintClient::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
|
-
BlueprintClient.configure { |c| c.base_path = '/v4/dog' }
|
43
|
-
expect(BlueprintClient::Configuration.default.base_path).to eq('/v4/dog')
|
44
|
-
end
|
45
|
-
|
46
|
-
it "ends up as a blank string if nil" do
|
47
|
-
BlueprintClient.configure { |c| c.base_path = nil }
|
48
|
-
expect(BlueprintClient::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) { BlueprintClient::Configuration.new }
|
56
|
-
let(:api_client) { BlueprintClient::ApiClient.new(config) }
|
57
|
-
|
58
|
-
it "defaults to nil" do
|
59
|
-
expect(BlueprintClient::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) { BlueprintClient::Configuration.new }
|
75
|
-
let(:api_client) { BlueprintClient::ApiClient.new(config) }
|
76
|
-
|
77
|
-
it "defaults to 0" do
|
78
|
-
expect(BlueprintClient::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
|
-
describe "#deserialize" do
|
93
|
-
it "handles Array<Integer>" do
|
94
|
-
api_client = BlueprintClient::ApiClient.new
|
95
|
-
headers = {'Content-Type' => 'application/json'}
|
96
|
-
response = double('response', headers: headers, body: '[12, 34]')
|
97
|
-
data = api_client.deserialize(response, 'Array<Integer>')
|
98
|
-
expect(data).to be_instance_of(Array)
|
99
|
-
expect(data).to eq([12, 34])
|
100
|
-
end
|
101
|
-
|
102
|
-
it "handles Array<Array<Integer>>" do
|
103
|
-
api_client = BlueprintClient::ApiClient.new
|
104
|
-
headers = {'Content-Type' => 'application/json'}
|
105
|
-
response = double('response', headers: headers, body: '[[12, 34], [56]]')
|
106
|
-
data = api_client.deserialize(response, 'Array<Array<Integer>>')
|
107
|
-
expect(data).to be_instance_of(Array)
|
108
|
-
expect(data).to eq([[12, 34], [56]])
|
109
|
-
end
|
110
|
-
|
111
|
-
it "handles Hash<String, String>" do
|
112
|
-
api_client = BlueprintClient::ApiClient.new
|
113
|
-
headers = {'Content-Type' => 'application/json'}
|
114
|
-
response = double('response', headers: headers, body: '{"message": "Hello"}')
|
115
|
-
data = api_client.deserialize(response, 'Hash<String, String>')
|
116
|
-
expect(data).to be_instance_of(Hash)
|
117
|
-
expect(data).to eq({:message => 'Hello'})
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe "#object_to_hash" do
|
122
|
-
it "ignores nils and includes empty arrays" do
|
123
|
-
# uncomment below to test object_to_hash for model
|
124
|
-
#api_client = BlueprintClient::ApiClient.new
|
125
|
-
#_model = BlueprintClient::ModelName.new
|
126
|
-
# update the model attribute below
|
127
|
-
#_model.id = 1
|
128
|
-
# update the expected value (hash) below
|
129
|
-
#expected = {id: 1, name: '', tags: []}
|
130
|
-
#expect(api_client.object_to_hash(_model)).to eq(expected)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe "#build_collection_param" do
|
135
|
-
let(:param) { ['aa', 'bb', 'cc'] }
|
136
|
-
let(:api_client) { BlueprintClient::ApiClient.new }
|
137
|
-
|
138
|
-
it "works for csv" do
|
139
|
-
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
|
140
|
-
end
|
141
|
-
|
142
|
-
it "works for ssv" do
|
143
|
-
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
|
144
|
-
end
|
145
|
-
|
146
|
-
it "works for tsv" do
|
147
|
-
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
|
148
|
-
end
|
149
|
-
|
150
|
-
it "works for pipes" do
|
151
|
-
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
|
152
|
-
end
|
153
|
-
|
154
|
-
it "works for multi" do
|
155
|
-
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
|
156
|
-
end
|
157
|
-
|
158
|
-
it "fails for invalid collection format" do
|
159
|
-
expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
describe "#json_mime?" do
|
164
|
-
let(:api_client) { BlueprintClient::ApiClient.new }
|
165
|
-
|
166
|
-
it "works" do
|
167
|
-
expect(api_client.json_mime?(nil)).to eq false
|
168
|
-
expect(api_client.json_mime?('')).to eq false
|
169
|
-
|
170
|
-
expect(api_client.json_mime?('application/json')).to eq true
|
171
|
-
expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
|
172
|
-
expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
|
173
|
-
|
174
|
-
expect(api_client.json_mime?('application/xml')).to eq false
|
175
|
-
expect(api_client.json_mime?('text/plain')).to eq false
|
176
|
-
expect(api_client.json_mime?('application/jsonp')).to eq false
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
describe "#select_header_accept" do
|
181
|
-
let(:api_client) { BlueprintClient::ApiClient.new }
|
182
|
-
|
183
|
-
it "works" do
|
184
|
-
expect(api_client.select_header_accept(nil)).to be_nil
|
185
|
-
expect(api_client.select_header_accept([])).to be_nil
|
186
|
-
|
187
|
-
expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
|
188
|
-
expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
189
|
-
expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
190
|
-
|
191
|
-
expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
|
192
|
-
expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
describe "#select_header_content_type" do
|
197
|
-
let(:api_client) { BlueprintClient::ApiClient.new }
|
198
|
-
|
199
|
-
it "works" do
|
200
|
-
expect(api_client.select_header_content_type(nil)).to eq('application/json')
|
201
|
-
expect(api_client.select_header_content_type([])).to eq('application/json')
|
202
|
-
|
203
|
-
expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
|
204
|
-
expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
205
|
-
expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
206
|
-
expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
|
207
|
-
expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
describe "#sanitize_filename" do
|
212
|
-
let(:api_client) { BlueprintClient::ApiClient.new }
|
213
|
-
|
214
|
-
it "works" do
|
215
|
-
expect(api_client.sanitize_filename('sun')).to eq('sun')
|
216
|
-
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
|
217
|
-
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
|
218
|
-
expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
|
219
|
-
expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
|
220
|
-
expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
|
221
|
-
expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
|
222
|
-
expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
|
223
|
-
expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
data/spec/configuration_spec.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
Talis Blueprint API
|
3
|
-
|
4
|
-
This is the API documentation for [Blueprint](https://github.com/talis/blueprint-server), a primitive for institutional structure and time periods
|
5
|
-
|
6
|
-
OpenAPI spec version: 1.0.0
|
7
|
-
|
8
|
-
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
|
10
|
-
|
11
|
-
=end
|
12
|
-
|
13
|
-
require 'spec_helper'
|
14
|
-
|
15
|
-
describe BlueprintClient::Configuration do
|
16
|
-
let(:config) { BlueprintClient::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:10010/1")
|
22
|
-
#BlueprintClient.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:10010/1")
|
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:10010/1")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|