1
|
require 'rubygems'
|
2
|
require 'minitest/autorun'
|
3
|
|
4
|
require './lib/runcible'
|
5
|
require './test/extensions/unit_base'
|
6
|
require './test/support/repository_support'
|
7
|
|
8
|
module Extensions
|
9
|
class TestRpm < MiniTest::Unit::TestCase
|
10
|
def self.before_suite
|
11
|
self.support = RepositorySupport.new
|
12
|
@@extension = TestRuncible.server.extensions.rpm
|
13
|
self.support.create_and_sync_repo(:importer => true)
|
14
|
end
|
15
|
|
16
|
def self.after_suite
|
17
|
self.support.destroy_repo
|
18
|
end
|
19
|
|
20
|
def test_content_type
|
21
|
assert_equal 'rpm', @@extension.content_type
|
22
|
end
|
23
|
|
24
|
def test_all
|
25
|
response = @@extension.all
|
26
|
|
27
|
assert_equal 200, response.code
|
28
|
refute_empty response
|
29
|
end
|
30
|
|
31
|
def test_find
|
32
|
assert_raises(NotImplementedError) { @@extension.find }
|
33
|
end
|
34
|
|
35
|
def test_find_all
|
36
|
assert_raises(NotImplementedError) { @@extension.find_all }
|
37
|
end
|
38
|
|
39
|
def test_find_by_unit_id
|
40
|
id = @@extension.all.sort_by { |p| p['_id'] }.first['_id']
|
41
|
response = @@extension.find_by_unit_id(id)
|
42
|
|
43
|
refute_empty response
|
44
|
assert_equal id, response['_id']
|
45
|
end
|
46
|
|
47
|
def test_find_unknown
|
48
|
response = @@extension.find_all_by_unit_ids(['f'])
|
49
|
|
50
|
assert_empty response
|
51
|
end
|
52
|
|
53
|
def test_find_all_by_unit_ids
|
54
|
pkgs = @@extension.all.sort_by { |p| p['_id'] }
|
55
|
ids = pkgs[0..2].map { |p| p['_id'] }
|
56
|
response = @@extension.find_all_by_unit_ids(ids)
|
57
|
|
58
|
assert_equal 200, response.code
|
59
|
assert_equal ids.length, response.length
|
60
|
end
|
61
|
|
62
|
def test_find_all_by_unit_ids_no_repos
|
63
|
pkgs = @@extension.all.sort_by { |p| p['_id'] }
|
64
|
ids = pkgs[0..2].map { |p| p['_id'] }
|
65
|
response = @@extension.find_all_by_unit_ids(ids, [:name], :include_repos => false)
|
66
|
|
67
|
assert_equal 200, response.code
|
68
|
assert_nil response.first[:repository_memberships]
|
69
|
end
|
70
|
end
|
71
|
|
72
|
class TestRpmCopy < UnitCopyBase
|
73
|
def self.extension_class
|
74
|
TestRuncible.server.extensions.rpm
|
75
|
end
|
76
|
|
77
|
def test_copy
|
78
|
response = self.class.extension_class.copy(RepositorySupport.repo_id, self.class.clone_name)
|
79
|
|
80
|
tasks = assert_async_response(response)
|
81
|
assert_includes tasks.first['tags'], 'pulp:action:associate'
|
82
|
end
|
83
|
|
84
|
def test_copy_with_filters
|
85
|
response = self.class.extension_class.copy(
|
86
|
RepositorySupport.repo_id,
|
87
|
self.class.clone_name,
|
88
|
:filters => {
|
89
|
:unit => {
|
90
|
'$and' => [{'name' => {'$regex' => 'p.*'}},
|
91
|
{'version' => {'$gt' => '1.0'}}]
|
92
|
}}
|
93
|
)
|
94
|
tasks = assert_async_response(response)
|
95
|
assert_includes tasks.first['tags'], 'pulp:action:associate'
|
96
|
end
|
97
|
end
|
98
|
|
99
|
class TestRpmUnassociate < UnitUnassociateBase
|
100
|
def self.extension_class
|
101
|
TestRuncible.server.extensions.rpm
|
102
|
end
|
103
|
|
104
|
def setup
|
105
|
response = TestRuncible.server.extensions.repository.unit_copy(self.class.clone_name, RepositorySupport.repo_id)
|
106
|
self.class.support.wait_on_response(response)
|
107
|
end
|
108
|
|
109
|
def test_unassociate_ids_from_repo
|
110
|
ids = content_ids(RepositorySupport.repo_id)
|
111
|
refute_empty ids
|
112
|
assert_raises(NotImplementedError) do
|
113
|
self.class.extension_class.unassociate_ids_from_repo(self.class.clone_name, [ids.first])
|
114
|
end
|
115
|
end
|
116
|
|
117
|
def test_unassociate_unit_ids_from_repo
|
118
|
ids = unit_ids(self.class.clone_name)
|
119
|
refute_empty ids
|
120
|
response = self.class.extension_class.unassociate_unit_ids_from_repo(self.class.clone_name, [ids.first])
|
121
|
|
122
|
assert_async_response(response)
|
123
|
assert_equal((ids.length - 1), unit_ids(self.class.clone_name).length)
|
124
|
end
|
125
|
|
126
|
def test_unassociate_from_repo
|
127
|
ids = unit_ids(self.class.clone_name)
|
128
|
refute_empty ids
|
129
|
response = self.class.extension_class.unassociate_from_repo(self.class.clone_name,
|
130
|
:association => {'unit_id' => {'$in' => [ids.first]}})
|
131
|
assert_async_response(response)
|
132
|
assert_equal((ids.length - 1), unit_ids(self.class.clone_name).length)
|
133
|
end
|
134
|
end
|
135
|
end
|