pdc 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +23 -0
- data/.travis.yml +3 -4
- data/Gemfile +0 -1
- data/docs/sphinx_deployment.mk +1 -1
- data/examples/local_pdc_dev.rb +10 -1
- data/examples/logger.rb +7 -14
- data/examples/pdc_global_component_contact.rb +18 -0
- data/examples/pdc_release_rpm_mapping.rb +2 -2
- data/examples/pdc_resource_tests.rb +3 -3
- data/examples/pdc_test_cache.rb +1 -1
- data/examples/prod_failures.rb +1 -1
- data/examples/prod_pdc.rb +10 -1
- data/examples/test_no_ssl_verification.rb +1 -1
- data/examples/url.rb +4 -4
- data/lib/pdc.rb +1 -1
- data/lib/pdc/base.rb +1 -0
- data/lib/pdc/config.rb +0 -7
- data/lib/pdc/http/request/token_fetcher.rb +1 -1
- data/lib/pdc/http/response/pagination.rb +0 -2
- data/lib/pdc/resource.rb +1 -0
- data/lib/pdc/resource/associations.rb +39 -0
- data/lib/pdc/resource/associations/association.rb +21 -0
- data/lib/pdc/resource/associations/builder.rb +46 -0
- data/lib/pdc/resource/associations/has_many.rb +26 -0
- data/lib/pdc/resource/attributes.rb +13 -4
- data/lib/pdc/resource/identity.rb +1 -1
- data/lib/pdc/resource/relation.rb +5 -0
- data/lib/pdc/resource/relation/pagination.rb +4 -4
- data/lib/pdc/resource/rest_api.rb +1 -1
- data/lib/pdc/resource/scopes.rb +1 -1
- data/lib/pdc/v1.rb +4 -0
- data/lib/pdc/v1/global_component_contact.rb +5 -0
- data/lib/pdc/v1/multi_destination.rb +8 -0
- data/lib/pdc/v1/release.rb +3 -1
- data/lib/pdc/v1/release_variant.rb +6 -1
- data/lib/pdc/v1/released_file.rb +10 -0
- data/lib/pdc/v1/variant_cpe.rb +7 -0
- data/lib/pdc/version.rb +1 -1
- data/pdc.gemspec +8 -10
- data/spec/fixtures/vcr/_page_count_returns_total_count.yml +6 -6
- data/spec/fixtures/vcr/behaves_like_an_array.yml +141 -0
- data/spec/fixtures/vcr/brew_can_be_nil.yml +23 -14
- data/spec/fixtures/vcr/brew_may_be_present.yml +4 -2
- data/spec/fixtures/vcr/caches_multiple_response.yml +42 -36
- data/spec/fixtures/vcr/caches_response_with_a_query.yml +16 -16
- data/spec/fixtures/vcr/caches_response_with_multiple_query.yml +16 -16
- data/spec/fixtures/vcr/caches_response_without_query.yml +14 -14
- data/spec/fixtures/vcr/can_find_global_contact_by_component_name.yml +47 -0
- data/spec/fixtures/vcr/can_get_release_by_multi_product_version.yml +9 -9
- data/spec/fixtures/vcr/can_iterate_using_each.yml +8 -8
- data/spec/fixtures/vcr/content_delivery_repos_must_return_a_record.yml +2 -2
- data/spec/fixtures/vcr/cpe_returns_number.yml +44 -0
- data/spec/fixtures/vcr/cpe_works_with_where.yml +85 -0
- data/spec/fixtures/vcr/destination_returns_count.yml +44 -0
- data/spec/fixtures/vcr/destination_works_with_where.yml +44 -0
- data/spec/fixtures/vcr/fetches_variants_of_a_release.yml +20 -20
- data/spec/fixtures/vcr/find_on_has_many_association.yml +48 -0
- data/spec/fixtures/vcr/get_released_files_by_file_primary_key.yml +44 -0
- data/spec/fixtures/vcr/get_released_files_by_release_id.yml +44 -0
- data/spec/fixtures/vcr/has_many_association.yml +48 -0
- data/spec/fixtures/vcr/has_serveral_cdn_content_delivery_repos.yml +1 -1
- data/spec/fixtures/vcr/must_has_compose.yml +45 -1
- data/spec/fixtures/vcr/must_has_version__attributes.yml +2 -2
- data/spec/fixtures/vcr/must_return_number_of_resources.yml +62 -14
- data/spec/fixtures/vcr/preserves_the_filters.yml +2 -2
- data/spec/fixtures/vcr/returns_a_contact_email.yml +47 -0
- data/spec/fixtures/vcr/returns_a_gloabl_contact_id.yml +47 -0
- data/spec/fixtures/vcr/returns_a_mail_name.yml +47 -0
- data/spec/fixtures/vcr/returns_contact_for_component.yml +47 -0
- data/spec/fixtures/vcr/returns_contact_role.yml +48 -0
- data/spec/fixtures/vcr/returns_cpe.yml +88 -0
- data/spec/fixtures/vcr/returns_number_of_released_files.yml +48 -0
- data/spec/fixtures/vcr/returns_release_file_by_retrieve.yml +44 -0
- data/spec/fixtures/vcr/returns_resources_on_that_page.yml +2 -2
- data/spec/fixtures/vcr/returns_the_total_count_and_not_items_in_page.yml +6 -6
- data/spec/fixtures/vcr/returns_url_of_a_release.yml +2 -2
- data/spec/fixtures/vcr/returns_url_of_a_release_variant.yml +7 -7
- data/spec/fixtures/vcr/scopes_on_associations.yml +48 -0
- data/spec/fixtures/vcr/should_not_be_in_the_list_of_attributes.yml +4 -4
- data/spec/fixtures/vcr/works_with_where.yml +45 -1
- data/spec/pdc/resource/associations_spec.rb +111 -0
- data/spec/pdc/resource/attributes_spec.rb +30 -20
- data/spec/pdc/resource/cache_spec.rb +1 -1
- data/spec/pdc/resource/identity_spec.rb +10 -10
- data/spec/pdc/resource/path_spec.rb +1 -1
- data/spec/pdc/resource/relation_spec.rb +1 -1
- data/spec/pdc/v1/content_delivery_repo_spec.rb +6 -6
- data/spec/pdc/v1/global_component_contact_spec.rb +64 -0
- data/spec/pdc/v1/multi_destination_sepc.rb +27 -0
- data/spec/pdc/v1/release_spec.rb +10 -10
- data/spec/pdc/v1/release_variant_spec.rb +8 -0
- data/spec/pdc/v1/released_file_spec.rb +37 -0
- data/spec/pdc/v1/variant_cpe_spec.rb +29 -0
- data/spec/spec_helper.rb +1 -4
- data/spec/support/fixtures.rb +29 -2
- metadata +77 -20
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PDC::Resource::Associations do
|
4
|
+
subject { PDC::Resource::Associations }
|
5
|
+
|
6
|
+
before do
|
7
|
+
VCR.insert_cassette fixture_name
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
VCR.eject_cassette
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:site) { 'https://example.com' }
|
15
|
+
|
16
|
+
let(:releases_url1) do
|
17
|
+
URI.join(site, PDC.config.api_root, 'v1/releases/?product_version=ceph-1&release_id=ceph-1.3@rhel-7')
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:releases_url2) do
|
21
|
+
URI.join(site, PDC.config.api_root, 'v1/releases/?product_version=ceph-1')
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'association' do
|
25
|
+
it 'association independence' do
|
26
|
+
assert_kind_of subject::HasMany, Fixtures::ProductVersion.new.releases
|
27
|
+
assert_raises NoMethodError do
|
28
|
+
Fixtures::ProductVersion.new.non_existings
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'has many association' do
|
33
|
+
releases = Fixtures::ProductVersion.new(product_version_id: 'dp-1').releases.to_a
|
34
|
+
assert_equal 'dp-1.0', releases.first.release_id
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'find on has many association' do
|
38
|
+
release = Fixtures::ProductVersion.new(product_version_id: 'dp-1').releases.find('dp-1.0')
|
39
|
+
assert_equal 'dp-1.0', release.release_id
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'scopes on associations' do
|
43
|
+
releases = Fixtures::ProductVersion.new(product_version_id: 'dp-1').releases.where(release_id: 'dp-1.0').to_a
|
44
|
+
assert_equal 'dp-1.0', releases.first.release_id
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'array like' do
|
49
|
+
it 'behaves like an array' do
|
50
|
+
product_version = Fixtures::ProductVersion.new(product_version_id: 'ceph-1')
|
51
|
+
assert_equal %w[ceph-1.3@rhel-7 ceph-1.3-updates@rhel-7], product_version.releases[0..1].map(&:release_id)
|
52
|
+
assert_equal 'ceph-1.3@rhel-7', product_version.releases.first.release_id
|
53
|
+
assert_equal 'ceph-1.3-updates@rhel-7', product_version.releases.last.release_id
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'cache' do
|
58
|
+
it 'cached result for associations' do
|
59
|
+
endpoint1 = stub_request(:get, releases_url1)\
|
60
|
+
.to_return_json('data':
|
61
|
+
[{ 'release_id': 'ceph-1.3@rhel-7', 'short': 'ceph',
|
62
|
+
'version': '1.3', 'name': 'Red Hat Ceph Storage',
|
63
|
+
'base_product': 'rhel-7', 'active': true,
|
64
|
+
'product_version': 'ceph-1', 'release_type': 'ga',
|
65
|
+
'compose_set': [], 'integrated_with': 'null', 'sigkey': 'null',
|
66
|
+
'allow_buildroot_push': true, 'allowed_debuginfo_services': [],
|
67
|
+
'allowed_push_targets': [], 'bugzilla': 'null',
|
68
|
+
'dist_git': 'null', 'brew': 'null', 'product_pages': 'null',
|
69
|
+
'errata': 'null' }])
|
70
|
+
endpoint2 = stub_request(:get, releases_url2)\
|
71
|
+
.to_return_json('data':
|
72
|
+
[{ 'release_id': 'ceph-1.3@rhel-7', 'short': 'ceph',
|
73
|
+
'version': '1.3', 'name': 'Red Hat Ceph Storage',
|
74
|
+
'base_product': 'rhel-7', 'active': true,
|
75
|
+
'product_version': 'ceph-1', 'release_type': 'ga',
|
76
|
+
'compose_set': [], 'integrated_with': 'null', 'sigkey': 'null',
|
77
|
+
'allow_buildroot_push': true, 'allowed_debuginfo_services': [],
|
78
|
+
'allowed_push_targets': [], 'bugzilla': 'null',
|
79
|
+
'dist_git': 'null', 'brew': 'null', 'product_pages': 'null',
|
80
|
+
'errata': 'null' },
|
81
|
+
{ 'release_id': 'ceph-1.3-updates@rhel-7', 'short': 'ceph',
|
82
|
+
'version': '1.3', 'name': 'Red Hat Ceph Storage',
|
83
|
+
'base_product': 'rhel-7', 'active': true,
|
84
|
+
'product_version': 'ceph-1', 'release_type': 'updates',
|
85
|
+
'compose_set': [], 'integrated_with': 'null', 'sigkey': 'null',
|
86
|
+
'allow_buildroot_push': false, 'allowed_debuginfo_services': [],
|
87
|
+
'allowed_push_targets': [], 'bugzilla': 'null',
|
88
|
+
'dist_git': 'null', 'brew': 'null', 'product_pages': 'null',
|
89
|
+
'errata': 'null' }])
|
90
|
+
|
91
|
+
product_version = Fixtures::ProductVersion.new(product_version_id: 'ceph-1')
|
92
|
+
releases = product_version.releases.where(release_id: 'ceph-1.3@rhel-7')
|
93
|
+
releases.any?
|
94
|
+
releases.to_a
|
95
|
+
assert_requested endpoint1, times: 1
|
96
|
+
|
97
|
+
product_version.releases.to_a
|
98
|
+
assert_requested endpoint2, times: 1
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe 'reflect' do
|
103
|
+
it 'reflect on association' do
|
104
|
+
assert_equal Fixtures::Release, Fixtures::ProductVersion.reflect_on_association(:release).klass
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'custom class name' do
|
108
|
+
assert_equal Fixtures::Release, Fixtures::ProductVersion.reflect_on_association(:active_release).klass
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -20,15 +20,15 @@ end
|
|
20
20
|
|
21
21
|
describe PDC::Resource::Attributes do
|
22
22
|
it 'returns all attributes' do
|
23
|
-
Product.attributes.wont_be_empty
|
23
|
+
Fixtures::Product.attributes.wont_be_empty
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'primary_key will be in attributes by default' do
|
27
|
-
Product.attributes.must_include Product.primary_key
|
27
|
+
Fixtures::Product.attributes.must_include Fixtures::Product.primary_key
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'allows block initialization' do
|
31
|
-
prod = Product.new do |p|
|
31
|
+
prod = Fixtures::Product.new do |p|
|
32
32
|
p.name = 'RHEL'
|
33
33
|
p.description = 'Enterprise Linux'
|
34
34
|
end
|
@@ -38,13 +38,12 @@ describe PDC::Resource::Attributes do
|
|
38
38
|
|
39
39
|
it 'can handle predicate' do
|
40
40
|
stub_get('products/1').to_return_json(data: [{ id: 1, name: 'RHEL' }])
|
41
|
-
product = Product.find(1)
|
41
|
+
product = Fixtures::Product.find(1)
|
42
42
|
assert_equal true, product.name?
|
43
|
-
assert_equal false, product.description?
|
44
43
|
end
|
45
44
|
|
46
45
|
it 'can assign a hash' do
|
47
|
-
product = Product.new(id: 2)
|
46
|
+
product = Fixtures::Product.new(id: 2)
|
48
47
|
product.attributes = { name: 'RHEL' }
|
49
48
|
|
50
49
|
product.name.must_equal 'RHEL'
|
@@ -52,24 +51,24 @@ describe PDC::Resource::Attributes do
|
|
52
51
|
end
|
53
52
|
|
54
53
|
it 'can get and set value' do
|
55
|
-
product = Product.new
|
54
|
+
product = Fixtures::Product.new
|
56
55
|
product.name = 'RHEL'
|
57
56
|
product.name.must_equal 'RHEL'
|
58
57
|
end
|
59
58
|
|
60
59
|
it 'works with []' do
|
61
|
-
product = Product.new(name: 'Fedora')
|
60
|
+
product = Fixtures::Product.new(name: 'Fedora')
|
62
61
|
product[:name].must_equal 'Fedora'
|
63
62
|
end
|
64
63
|
|
65
64
|
it 'works with []=' do
|
66
|
-
product = Product.new
|
65
|
+
product = Fixtures::Product.new
|
67
66
|
product[:name] = 'bar'
|
68
67
|
product.name.must_equal 'bar'
|
69
68
|
end
|
70
69
|
|
71
70
|
it 'allows assigning unknown attributes' do
|
72
|
-
product = Product.new
|
71
|
+
product = Fixtures::Product.new
|
73
72
|
|
74
73
|
product.wont_respond_to :foobar
|
75
74
|
product.must_respond_to :foobar=
|
@@ -78,35 +77,47 @@ describe PDC::Resource::Attributes do
|
|
78
77
|
product.foobar.must_equal 'bar'
|
79
78
|
end
|
80
79
|
|
80
|
+
it 'return error when no such method' do
|
81
|
+
stub_get('products/1').to_return_json(data: [{ id: 1, name: 'RHEL' }])
|
82
|
+
|
83
|
+
product = Fixtures::Product.find(1)
|
84
|
+
assert_raises NoMethodError do
|
85
|
+
product.no_such_thing?
|
86
|
+
end
|
87
|
+
assert_raises NoMethodError do
|
88
|
+
product.no_such_thing
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
81
92
|
describe '#respond_to' do
|
82
93
|
it 'returns true for known attributes' do
|
83
94
|
stub_get('products/1').to_return_json(data: [{ id: 1, name: 'RHEL' }])
|
84
95
|
|
85
|
-
product = Product.find(1)
|
96
|
+
product = Fixtures::Product.find(1)
|
86
97
|
product.must_respond_to :name
|
87
98
|
end
|
88
99
|
|
89
100
|
it 'returns false for unknown attributes that are not set' do
|
90
101
|
stub_get('products/1').to_return_json(data: [{ id: 1, name: 'RHEL' }])
|
91
102
|
|
92
|
-
product = Product.find(1)
|
103
|
+
product = Fixtures::Product.find(1)
|
93
104
|
product.wont_respond_to :title
|
94
105
|
end
|
95
106
|
|
96
107
|
it 'returns true for unknown attributes after it is set' do
|
97
|
-
product = Product.new
|
108
|
+
product = Fixtures::Product.new
|
98
109
|
product.wont_respond_to :foobar
|
99
110
|
|
100
111
|
product.foobar = 'bar'
|
101
112
|
product.must_respond_to :foobar
|
102
|
-
Product.attributes.wont_include :foobar
|
113
|
+
Fixtures::Product.attributes.wont_include :foobar
|
103
114
|
end
|
104
115
|
end
|
105
116
|
end
|
106
117
|
|
107
118
|
describe 'nested hash attributes' do
|
108
119
|
it 'returns OpenStruct for nested hash' do
|
109
|
-
allowed_tags = %w
|
120
|
+
allowed_tags = %w[foo bar baz]
|
110
121
|
stub_get('nested-models/1').to_return_json(
|
111
122
|
data: [{
|
112
123
|
id: 1, name: 'RHEL',
|
@@ -117,7 +128,7 @@ describe 'nested hash attributes' do
|
|
117
128
|
}]
|
118
129
|
)
|
119
130
|
|
120
|
-
model = NestedModel.find(1)
|
131
|
+
model = Fixtures::NestedModel.find(1)
|
121
132
|
model.must_respond_to :nested
|
122
133
|
model.nested.must_be_instance_of OpenStruct
|
123
134
|
model.nested.must_respond_to :tag
|
@@ -138,7 +149,7 @@ describe 'nested hash attributes' do
|
|
138
149
|
}]
|
139
150
|
)
|
140
151
|
|
141
|
-
model = NestedModel.find(1)
|
152
|
+
model = Fixtures::NestedModel.find(1)
|
142
153
|
model.must_respond_to :nested
|
143
154
|
|
144
155
|
model.nested.must_respond_to :second_level
|
@@ -157,7 +168,7 @@ describe 'nested hash attributes' do
|
|
157
168
|
}]
|
158
169
|
)
|
159
170
|
|
160
|
-
model = NestedModel.find(1)
|
171
|
+
model = Fixtures::NestedModel.find(1)
|
161
172
|
model.must_respond_to :unregistered_nested
|
162
173
|
model.unregistered_nested.must_be_instance_of OpenStruct
|
163
174
|
model.unregistered_nested.must_respond_to :value
|
@@ -166,7 +177,7 @@ describe 'nested hash attributes' do
|
|
166
177
|
end
|
167
178
|
|
168
179
|
describe 'Custom ValueParser' do
|
169
|
-
subject { CustomParserModel }
|
180
|
+
subject { Fixtures::CustomParserModel }
|
170
181
|
it 'must return fixnum for age' do
|
171
182
|
stub_get('custom-parser-models/1').to_return_json(
|
172
183
|
data: [{
|
@@ -176,7 +187,6 @@ describe 'Custom ValueParser' do
|
|
176
187
|
|
177
188
|
model = subject.find(1)
|
178
189
|
model.must_respond_to :age
|
179
|
-
model.age.must_be_instance_of Fixnum
|
180
190
|
model.age.must_equal 20
|
181
191
|
end
|
182
192
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'ap'
|
3
3
|
|
4
|
-
describe ModelWithIdentity do
|
5
|
-
subject { ModelWithIdentity }
|
4
|
+
describe Fixtures::ModelWithIdentity do
|
5
|
+
subject { Fixtures::ModelWithIdentity }
|
6
6
|
|
7
7
|
describe '##primary_key' do
|
8
8
|
it 'must exist' do
|
@@ -43,8 +43,8 @@ describe ModelWithIdentity do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
describe CustomPrimaryKeyModel do
|
47
|
-
subject { CustomPrimaryKeyModel }
|
46
|
+
describe Fixtures::CustomPrimaryKeyModel do
|
47
|
+
subject { Fixtures::CustomPrimaryKeyModel }
|
48
48
|
|
49
49
|
describe '##primary_key' do
|
50
50
|
it 'can be set' do
|
@@ -66,8 +66,8 @@ describe CustomPrimaryKeyModel do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
describe V1::Foobar do
|
70
|
-
subject { V1::Foobar }
|
69
|
+
describe Fixtures::V1::Foobar do
|
70
|
+
subject { Fixtures::V1::Foobar }
|
71
71
|
it 'must have a pkey' do
|
72
72
|
subject.primary_key.must_equal 'foobar_id'
|
73
73
|
end
|
@@ -79,15 +79,15 @@ end
|
|
79
79
|
|
80
80
|
describe 'attributes' do
|
81
81
|
it 'base must have primary key' do
|
82
|
-
ModelBase.new.id.must_be_nil
|
83
|
-
base = ModelBase.new(model_base_id: 1)
|
82
|
+
Fixtures::ModelBase.new.id.must_be_nil
|
83
|
+
base = Fixtures::ModelBase.new(model_base_id: 1)
|
84
84
|
base.id.must_equal 1
|
85
85
|
base.attributes.must_include :model_base_id
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'sub must not have primary key of base' do
|
89
|
-
Model.new.id.must_be_nil
|
90
|
-
model = Model.new(model_id: 3)
|
89
|
+
Fixtures::Model.new.id.must_be_nil
|
90
|
+
model = Fixtures::Model.new(model_id: 3)
|
91
91
|
model.id.must_equal 3
|
92
92
|
model.attributes.must_include :model_id
|
93
93
|
model.attributes.wont_include :model_base_id
|
@@ -13,7 +13,7 @@ describe PDC::Resource::Path do
|
|
13
13
|
path = subject.new('/users/:user_id/recipes/(:id)',
|
14
14
|
user_id: 1, status: 'published')
|
15
15
|
|
16
|
-
assert_equal [
|
16
|
+
assert_equal %i[user_id id], path.variables
|
17
17
|
assert_equal '/users/1/recipes', path.expanded
|
18
18
|
end
|
19
19
|
|
@@ -11,8 +11,9 @@ describe PDC::V1::ContentDeliveryRepo do
|
|
11
11
|
|
12
12
|
describe 'count' do
|
13
13
|
it 'has serveral cdn content delivery repos' do
|
14
|
-
content_delivery_repos = PDC::V1::ContentDeliveryRepo
|
15
|
-
|
14
|
+
content_delivery_repos = PDC::V1::ContentDeliveryRepo.where(
|
15
|
+
release_id: 'ceph-2.1-updates@rhel-7', service: 'pulp'
|
16
|
+
)
|
16
17
|
assert_equal 18, content_delivery_repos.count
|
17
18
|
end
|
18
19
|
end
|
@@ -20,13 +21,12 @@ describe PDC::V1::ContentDeliveryRepo do
|
|
20
21
|
describe 'find' do
|
21
22
|
it 'content delivery repos must return a record' do
|
22
23
|
repo_class = PDC::V1::ContentDeliveryRepo
|
23
|
-
existing_repo = PDC::V1::ContentDeliveryRepo
|
24
|
-
|
25
|
-
|
24
|
+
existing_repo = PDC::V1::ContentDeliveryRepo.where(
|
25
|
+
release_id: 'ceph-2.1-updates@rhel-7', service: 'pulp'
|
26
|
+
).first
|
26
27
|
found = repo_class.find(existing_repo.id)
|
27
28
|
found.must_be_instance_of repo_class
|
28
29
|
found.name.must_equal existing_repo.name
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
32
|
-
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PDC::V1::GlobalComponentContact do
|
4
|
+
before do
|
5
|
+
VCR.insert_cassette fixture_name
|
6
|
+
end
|
7
|
+
|
8
|
+
after do
|
9
|
+
VCR.eject_cassette
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:contact) { PDC::V1::GlobalComponentContact }
|
13
|
+
|
14
|
+
it 'must has compose' do
|
15
|
+
contact.where(component: 'vlgothic-fonts').first.contact.must_be_instance_of OpenStruct
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'count' do
|
19
|
+
it 'must return number of resources' do
|
20
|
+
count = contact.count
|
21
|
+
count.must_equal 12_546
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'works with where' do
|
25
|
+
count = contact.where(component: 'vlgothic-fonts').count
|
26
|
+
count.must_equal 3 # as there is 3 fields per entry
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'can find global contact by component name' do
|
30
|
+
count = contact.where(component: 'vlgothic-fonts').count
|
31
|
+
count.must_equal 3
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#contact' do
|
36
|
+
it 'returns contact for component' do
|
37
|
+
vf = contact.where(component: 'vlgothic-fonts').first
|
38
|
+
vf.contact.wont_be_nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns a contact email' do
|
42
|
+
vf = contact.where(component: 'vlgothic-fonts').first
|
43
|
+
vf.contact.email.must_equal 'qe-i18n-bugs@redhat.com'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'returns a mail_name' do
|
47
|
+
vf = contact.where(component: 'vlgothic-fonts').first
|
48
|
+
vf.contact.mail_name.must_equal 'I18N'
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'returns a gloabl contact id' do
|
52
|
+
vf = contact.where(component: 'vlgothic-fonts').first
|
53
|
+
vf.contact.id.must_equal 5
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#role' do
|
58
|
+
it 'returns contact role' do
|
59
|
+
bash_contact = contact.where(component: 'bash').first
|
60
|
+
bash_contact.role.wont_be_nil
|
61
|
+
bash_contact.role.must_equal 'QE_Group'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# WebMock.disable! # enable to re-record
|
4
|
+
|
5
|
+
describe PDC::V1::MultiDestination do
|
6
|
+
before do
|
7
|
+
VCR.insert_cassette fixture_name
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
VCR.eject_cassette
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:multi_destonations) { PDC::V1::MultiDestination }
|
15
|
+
|
16
|
+
describe 'count' do
|
17
|
+
it 'destination returns count' do
|
18
|
+
count = multi_destonations.count
|
19
|
+
count.must_equal 1
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'destination works with where' do
|
23
|
+
count = multi_destonations.where(active: false).count
|
24
|
+
count.must_equal 0
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|