pulp_2to3_migration_client 0.3.0b1.dev01595360000
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 +7 -0
- data/Gemfile +9 -0
- data/README.md +114 -0
- data/Rakefile +10 -0
- data/docs/AsyncOperationResponse.md +17 -0
- data/docs/InlineResponse200.md +23 -0
- data/docs/InlineResponse2001.md +23 -0
- data/docs/InlineResponse2002.md +23 -0
- data/docs/MigrationPlanRun.md +19 -0
- data/docs/MigrationPlansApi.md +295 -0
- data/docs/Pulp2contentApi.md +154 -0
- data/docs/Pulp2repositoriesApi.md +140 -0
- data/docs/Pulp2to3MigrationMigrationPlan.md +21 -0
- data/docs/Pulp2to3MigrationPulp2Content.md +33 -0
- data/docs/Pulp2to3MigrationPulp2Repository.md +39 -0
- data/git_push.sh +58 -0
- data/lib/pulp_2to3_migration_client.rb +50 -0
- data/lib/pulp_2to3_migration_client/api/migration_plans_api.rb +355 -0
- data/lib/pulp_2to3_migration_client/api/pulp2content_api.rb +194 -0
- data/lib/pulp_2to3_migration_client/api/pulp2repositories_api.rb +173 -0
- data/lib/pulp_2to3_migration_client/api_client.rb +402 -0
- data/lib/pulp_2to3_migration_client/api_error.rb +57 -0
- data/lib/pulp_2to3_migration_client/configuration.rb +243 -0
- data/lib/pulp_2to3_migration_client/models/async_operation_response.rb +212 -0
- data/lib/pulp_2to3_migration_client/models/inline_response200.rb +247 -0
- data/lib/pulp_2to3_migration_client/models/inline_response2001.rb +247 -0
- data/lib/pulp_2to3_migration_client/models/inline_response2002.rb +247 -0
- data/lib/pulp_2to3_migration_client/models/migration_plan_run.rb +221 -0
- data/lib/pulp_2to3_migration_client/models/pulp2to3_migration_migration_plan.rb +231 -0
- data/lib/pulp_2to3_migration_client/models/pulp2to3_migration_pulp2_content.rb +393 -0
- data/lib/pulp_2to3_migration_client/models/pulp2to3_migration_pulp2_repository.rb +444 -0
- data/lib/pulp_2to3_migration_client/version.rb +15 -0
- data/pulp_2to3_migration_client.gemspec +39 -0
- data/spec/api/migration_plans_api_spec.rb +102 -0
- data/spec/api/pulp2content_api_spec.rb +76 -0
- data/spec/api/pulp2repositories_api_spec.rb +69 -0
- data/spec/api_client_spec.rb +188 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/async_operation_response_spec.rb +41 -0
- data/spec/models/inline_response2001_spec.rb +59 -0
- data/spec/models/inline_response2002_spec.rb +59 -0
- data/spec/models/inline_response200_spec.rb +59 -0
- data/spec/models/migration_plan_run_spec.rb +47 -0
- data/spec/models/pulp2to3_migration_migration_plan_spec.rb +53 -0
- data/spec/models/pulp2to3_migration_pulp2_content_spec.rb +89 -0
- data/spec/models/pulp2to3_migration_pulp2_repository_spec.rb +107 -0
- data/spec/spec_helper.rb +111 -0
- metadata +157 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
=begin
|
4
|
+
#Pulp 3 API
|
5
|
+
|
6
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
7
|
+
|
8
|
+
The version of the OpenAPI document: v3
|
9
|
+
|
10
|
+
Generated by: https://openapi-generator.tech
|
11
|
+
OpenAPI Generator version: 4.2.3
|
12
|
+
|
13
|
+
=end
|
14
|
+
|
15
|
+
$:.push File.expand_path("../lib", __FILE__)
|
16
|
+
require "pulp_2to3_migration_client/version"
|
17
|
+
|
18
|
+
Gem::Specification.new do |s|
|
19
|
+
s.name = "pulp_2to3_migration_client"
|
20
|
+
s.version = Pulp2to3MigrationClient::VERSION
|
21
|
+
s.platform = Gem::Platform::RUBY
|
22
|
+
s.authors = ["OpenAPI-Generator"]
|
23
|
+
s.email = [""]
|
24
|
+
s.homepage = "https://openapi-generator.tech"
|
25
|
+
s.summary = "Pulp 3 API Ruby Gem"
|
26
|
+
s.description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
|
27
|
+
s.license = 'GPL-2.0+'
|
28
|
+
s.required_ruby_version = ">= 1.9"
|
29
|
+
|
30
|
+
s.add_runtime_dependency 'faraday', '>= 0.14.0'
|
31
|
+
s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
|
32
|
+
|
33
|
+
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
34
|
+
|
35
|
+
s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
|
36
|
+
s.test_files = `find spec/*`.split("\n")
|
37
|
+
s.executables = []
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
=begin
|
2
|
+
#Pulp 3 API
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v3
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for Pulp2to3MigrationClient::MigrationPlansApi
|
17
|
+
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'MigrationPlansApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
@api_instance = Pulp2to3MigrationClient::MigrationPlansApi.new
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
# run after each test
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test an instance of MigrationPlansApi' do
|
30
|
+
it 'should create an instance of MigrationPlansApi' do
|
31
|
+
expect(@api_instance).to be_instance_of(Pulp2to3MigrationClient::MigrationPlansApi)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# unit tests for create
|
36
|
+
# Create a migration plan
|
37
|
+
# MigrationPlan ViewSet.
|
38
|
+
# @param data
|
39
|
+
# @param [Hash] opts the optional parameters
|
40
|
+
# @return [Pulp2to3MigrationMigrationPlan]
|
41
|
+
describe 'create test' do
|
42
|
+
it 'should work' do
|
43
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# unit tests for delete
|
48
|
+
# Delete a migration plan
|
49
|
+
# MigrationPlan ViewSet.
|
50
|
+
# @param migration_plan_href URI of Migration Plan. e.g.: /pulp/api/v3/migration-plans/1/
|
51
|
+
# @param [Hash] opts the optional parameters
|
52
|
+
# @return [nil]
|
53
|
+
describe 'delete test' do
|
54
|
+
it 'should work' do
|
55
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# unit tests for list
|
60
|
+
# List migration plans
|
61
|
+
# MigrationPlan ViewSet.
|
62
|
+
# @param [Hash] opts the optional parameters
|
63
|
+
# @option opts [String] :ordering Which field to use when ordering the results.
|
64
|
+
# @option opts [Integer] :limit Number of results to return per page.
|
65
|
+
# @option opts [Integer] :offset The initial index from which to return the results.
|
66
|
+
# @option opts [String] :fields A list of fields to include in the response.
|
67
|
+
# @option opts [String] :exclude_fields A list of fields to exclude from the response.
|
68
|
+
# @return [InlineResponse200]
|
69
|
+
describe 'list test' do
|
70
|
+
it 'should work' do
|
71
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# unit tests for read
|
76
|
+
# Inspect a migration plan
|
77
|
+
# MigrationPlan ViewSet.
|
78
|
+
# @param migration_plan_href URI of Migration Plan. e.g.: /pulp/api/v3/migration-plans/1/
|
79
|
+
# @param [Hash] opts the optional parameters
|
80
|
+
# @option opts [String] :fields A list of fields to include in the response.
|
81
|
+
# @option opts [String] :exclude_fields A list of fields to exclude from the response.
|
82
|
+
# @return [Pulp2to3MigrationMigrationPlan]
|
83
|
+
describe 'read test' do
|
84
|
+
it 'should work' do
|
85
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# unit tests for run
|
90
|
+
# Run migration plan
|
91
|
+
# Trigger an asynchronous task to run a migration from Pulp 2.
|
92
|
+
# @param migration_plan_href URI of Migration Plan. e.g.: /pulp/api/v3/migration-plans/1/
|
93
|
+
# @param data
|
94
|
+
# @param [Hash] opts the optional parameters
|
95
|
+
# @return [AsyncOperationResponse]
|
96
|
+
describe 'run test' do
|
97
|
+
it 'should work' do
|
98
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
=begin
|
2
|
+
#Pulp 3 API
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v3
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for Pulp2to3MigrationClient::Pulp2contentApi
|
17
|
+
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'Pulp2contentApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
@api_instance = Pulp2to3MigrationClient::Pulp2contentApi.new
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
# run after each test
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test an instance of Pulp2contentApi' do
|
30
|
+
it 'should create an instance of Pulp2contentApi' do
|
31
|
+
expect(@api_instance).to be_instance_of(Pulp2to3MigrationClient::Pulp2contentApi)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# unit tests for list
|
36
|
+
# List pulp2 contents
|
37
|
+
# ViewSet for Pulp2Content model.
|
38
|
+
# @param [Hash] opts the optional parameters
|
39
|
+
# @option opts [String] :ordering Which field to use when ordering the results.
|
40
|
+
# @option opts [String] :pulp2_id
|
41
|
+
# @option opts [String] :pulp2_id__in Filter results where pulp2_id is in a comma-separated list of values
|
42
|
+
# @option opts [String] :pulp2_content_type_id
|
43
|
+
# @option opts [String] :pulp2_content_type_id__in Filter results where pulp2_content_type_id is in a comma-separated list of values
|
44
|
+
# @option opts [Float] :pulp2_last_updated__lt Filter results where pulp2_last_updated is less than value
|
45
|
+
# @option opts [Float] :pulp2_last_updated__lte Filter results where pulp2_last_updated is less than or equal to value
|
46
|
+
# @option opts [Float] :pulp2_last_updated__gt Filter results where pulp2_last_updated is greater than value
|
47
|
+
# @option opts [Float] :pulp2_last_updated__gte Filter results where pulp2_last_updated is greater than or equal to value
|
48
|
+
# @option opts [Float] :pulp2_last_updated__range Filter results where pulp2_last_updated is between two comma separated values
|
49
|
+
# @option opts [String] :pulp3_content Foreign Key referenced by HREF
|
50
|
+
# @option opts [String] :pulp2_last_updated ISO 8601 formatted dates are supported
|
51
|
+
# @option opts [Integer] :limit Number of results to return per page.
|
52
|
+
# @option opts [Integer] :offset The initial index from which to return the results.
|
53
|
+
# @option opts [String] :fields A list of fields to include in the response.
|
54
|
+
# @option opts [String] :exclude_fields A list of fields to exclude from the response.
|
55
|
+
# @return [InlineResponse2001]
|
56
|
+
describe 'list test' do
|
57
|
+
it 'should work' do
|
58
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# unit tests for read
|
63
|
+
# Inspect a pulp2 content
|
64
|
+
# ViewSet for Pulp2Content model.
|
65
|
+
# @param pulp2_content_href URI of Pulp2 Content. e.g.: /pulp/api/v3/pulp2content/1/
|
66
|
+
# @param [Hash] opts the optional parameters
|
67
|
+
# @option opts [String] :fields A list of fields to include in the response.
|
68
|
+
# @option opts [String] :exclude_fields A list of fields to exclude from the response.
|
69
|
+
# @return [Pulp2to3MigrationPulp2Content]
|
70
|
+
describe 'read test' do
|
71
|
+
it 'should work' do
|
72
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
=begin
|
2
|
+
#Pulp 3 API
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v3
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
# Unit tests for Pulp2to3MigrationClient::Pulp2repositoriesApi
|
17
|
+
# Automatically generated by openapi-generator (https://openapi-generator.tech)
|
18
|
+
# Please update as you see appropriate
|
19
|
+
describe 'Pulp2repositoriesApi' do
|
20
|
+
before do
|
21
|
+
# run before each test
|
22
|
+
@api_instance = Pulp2to3MigrationClient::Pulp2repositoriesApi.new
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
# run after each test
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'test an instance of Pulp2repositoriesApi' do
|
30
|
+
it 'should create an instance of Pulp2repositoriesApi' do
|
31
|
+
expect(@api_instance).to be_instance_of(Pulp2to3MigrationClient::Pulp2repositoriesApi)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# unit tests for list
|
36
|
+
# List pulp2 repositorys
|
37
|
+
# ViewSet for Pulp2Repositories model.
|
38
|
+
# @param [Hash] opts the optional parameters
|
39
|
+
# @option opts [String] :ordering Which field to use when ordering the results.
|
40
|
+
# @option opts [String] :pulp2_repo_id
|
41
|
+
# @option opts [String] :pulp2_repo_id__in Filter results where pulp2_repo_id is in a comma-separated list of values
|
42
|
+
# @option opts [String] :is_migrated
|
43
|
+
# @option opts [String] :not_in_plan
|
44
|
+
# @option opts [Integer] :limit Number of results to return per page.
|
45
|
+
# @option opts [Integer] :offset The initial index from which to return the results.
|
46
|
+
# @option opts [String] :fields A list of fields to include in the response.
|
47
|
+
# @option opts [String] :exclude_fields A list of fields to exclude from the response.
|
48
|
+
# @return [InlineResponse2002]
|
49
|
+
describe 'list test' do
|
50
|
+
it 'should work' do
|
51
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# unit tests for read
|
56
|
+
# Inspect a pulp2 repository
|
57
|
+
# ViewSet for Pulp2Repositories model.
|
58
|
+
# @param pulp2_repository_href URI of Pulp2 Repository. e.g.: /pulp/api/v3/pulp2repositories/1/
|
59
|
+
# @param [Hash] opts the optional parameters
|
60
|
+
# @option opts [String] :fields A list of fields to include in the response.
|
61
|
+
# @option opts [String] :exclude_fields A list of fields to exclude from the response.
|
62
|
+
# @return [Pulp2to3MigrationPulp2Repository]
|
63
|
+
describe 'read test' do
|
64
|
+
it 'should work' do
|
65
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
=begin
|
2
|
+
#Pulp 3 API
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v3
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
|
15
|
+
describe Pulp2to3MigrationClient::ApiClient do
|
16
|
+
context 'initialization' do
|
17
|
+
context 'URL stuff' do
|
18
|
+
context 'host' do
|
19
|
+
it 'removes http from host' do
|
20
|
+
Pulp2to3MigrationClient.configure { |c| c.host = 'http://example.com' }
|
21
|
+
expect(Pulp2to3MigrationClient::Configuration.default.host).to eq('example.com')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'removes https from host' do
|
25
|
+
Pulp2to3MigrationClient.configure { |c| c.host = 'https://wookiee.com' }
|
26
|
+
expect(Pulp2to3MigrationClient::ApiClient.default.config.host).to eq('wookiee.com')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'removes trailing path from host' do
|
30
|
+
Pulp2to3MigrationClient.configure { |c| c.host = 'hobo.com/v4' }
|
31
|
+
expect(Pulp2to3MigrationClient::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
|
+
Pulp2to3MigrationClient.configure { |c| c.base_path = 'v4/dog' }
|
38
|
+
expect(Pulp2to3MigrationClient::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
|
+
Pulp2to3MigrationClient.configure { |c| c.base_path = '/v4/dog' }
|
43
|
+
expect(Pulp2to3MigrationClient::Configuration.default.base_path).to eq('/v4/dog')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "ends up as a blank string if nil" do
|
47
|
+
Pulp2to3MigrationClient.configure { |c| c.base_path = nil }
|
48
|
+
expect(Pulp2to3MigrationClient::Configuration.default.base_path).to eq('')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#deserialize' do
|
55
|
+
it "handles Array<Integer>" do
|
56
|
+
api_client = Pulp2to3MigrationClient::ApiClient.new
|
57
|
+
headers = { 'Content-Type' => 'application/json' }
|
58
|
+
response = double('response', headers: headers, body: '[12, 34]')
|
59
|
+
data = api_client.deserialize(response, 'Array<Integer>')
|
60
|
+
expect(data).to be_instance_of(Array)
|
61
|
+
expect(data).to eq([12, 34])
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'handles Array<Array<Integer>>' do
|
65
|
+
api_client = Pulp2to3MigrationClient::ApiClient.new
|
66
|
+
headers = { 'Content-Type' => 'application/json' }
|
67
|
+
response = double('response', headers: headers, body: '[[12, 34], [56]]')
|
68
|
+
data = api_client.deserialize(response, 'Array<Array<Integer>>')
|
69
|
+
expect(data).to be_instance_of(Array)
|
70
|
+
expect(data).to eq([[12, 34], [56]])
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'handles Hash<String, String>' do
|
74
|
+
api_client = Pulp2to3MigrationClient::ApiClient.new
|
75
|
+
headers = { 'Content-Type' => 'application/json' }
|
76
|
+
response = double('response', headers: headers, body: '{"message": "Hello"}')
|
77
|
+
data = api_client.deserialize(response, 'Hash<String, String>')
|
78
|
+
expect(data).to be_instance_of(Hash)
|
79
|
+
expect(data).to eq(:message => 'Hello')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#object_to_hash" do
|
84
|
+
it 'ignores nils and includes empty arrays' do
|
85
|
+
# uncomment below to test object_to_hash for model
|
86
|
+
# api_client = Pulp2to3MigrationClient::ApiClient.new
|
87
|
+
# _model = Pulp2to3MigrationClient::ModelName.new
|
88
|
+
# update the model attribute below
|
89
|
+
# _model.id = 1
|
90
|
+
# update the expected value (hash) below
|
91
|
+
# expected = {id: 1, name: '', tags: []}
|
92
|
+
# expect(api_client.object_to_hash(_model)).to eq(expected)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#build_collection_param' do
|
97
|
+
let(:param) { ['aa', 'bb', 'cc'] }
|
98
|
+
let(:api_client) { Pulp2to3MigrationClient::ApiClient.new }
|
99
|
+
|
100
|
+
it 'works for csv' do
|
101
|
+
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'works for ssv' do
|
105
|
+
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'works for tsv' do
|
109
|
+
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'works for pipes' do
|
113
|
+
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'works for multi' do
|
117
|
+
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'fails for invalid collection format' do
|
121
|
+
expect{api_client.build_collection_param(param, :INVALID)}.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '#json_mime?' do
|
126
|
+
let(:api_client) { Pulp2to3MigrationClient::ApiClient.new }
|
127
|
+
|
128
|
+
it 'works' do
|
129
|
+
expect(api_client.json_mime?(nil)).to eq false
|
130
|
+
expect(api_client.json_mime?('')).to eq false
|
131
|
+
|
132
|
+
expect(api_client.json_mime?('application/json')).to eq true
|
133
|
+
expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
|
134
|
+
expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
|
135
|
+
|
136
|
+
expect(api_client.json_mime?('application/xml')).to eq false
|
137
|
+
expect(api_client.json_mime?('text/plain')).to eq false
|
138
|
+
expect(api_client.json_mime?('application/jsonp')).to eq false
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe '#select_header_accept' do
|
143
|
+
let(:api_client) { Pulp2to3MigrationClient::ApiClient.new }
|
144
|
+
|
145
|
+
it 'works' do
|
146
|
+
expect(api_client.select_header_accept(nil)).to be_nil
|
147
|
+
expect(api_client.select_header_accept([])).to be_nil
|
148
|
+
|
149
|
+
expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
|
150
|
+
expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
151
|
+
expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
152
|
+
|
153
|
+
expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
|
154
|
+
expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe '#select_header_content_type' do
|
159
|
+
let(:api_client) { Pulp2to3MigrationClient::ApiClient.new }
|
160
|
+
|
161
|
+
it 'works' do
|
162
|
+
expect(api_client.select_header_content_type(nil)).to eq('application/json')
|
163
|
+
expect(api_client.select_header_content_type([])).to eq('application/json')
|
164
|
+
|
165
|
+
expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
|
166
|
+
expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
167
|
+
expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
168
|
+
expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
|
169
|
+
expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe '#sanitize_filename' do
|
174
|
+
let(:api_client) { Pulp2to3MigrationClient::ApiClient.new }
|
175
|
+
|
176
|
+
it 'works' do
|
177
|
+
expect(api_client.sanitize_filename('sun')).to eq('sun')
|
178
|
+
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
|
179
|
+
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
|
180
|
+
expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
|
181
|
+
expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
|
182
|
+
expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
|
183
|
+
expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
|
184
|
+
expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
|
185
|
+
expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|