1
1
import pytest
2
2
3
3
from pubtools .pulplib import (
4
- FakeController ,
5
4
Criteria ,
6
- Matcher ,
7
- RpmUnit ,
8
5
ErratumUnit ,
6
+ FakeController ,
7
+ Matcher ,
9
8
ModulemdUnit ,
10
- YumRepository ,
11
9
RpmDependency ,
10
+ RpmUnit ,
11
+ YumRepository ,
12
12
)
13
13
14
14
@@ -32,6 +32,13 @@ def populated_repo(controller):
32
32
sourcerpm = "glibc-5.0-1.el5_11.1.src.rpm" ,
33
33
provides = [RpmDependency (name = "gcc" )],
34
34
),
35
+ RpmUnit (
36
+ name = "jq" ,
37
+ version = "4.0" ,
38
+ release = "1" ,
39
+ arch = "x86_64" ,
40
+ files = ["/some/file" , "/another/file" , "/yet/another/file" , "/script" ],
41
+ ),
35
42
ModulemdUnit (
36
43
name = "module1" , stream = "s1" , version = 1234 , context = "a1b2" , arch = "x86_64"
37
44
),
@@ -91,7 +98,7 @@ def test_search_content_default_crit(populated_repo):
91
98
"""search_content with default criteria on populated repo finds all units"""
92
99
93
100
units = list (populated_repo .search_content ())
94
- assert len (units ) == 6
101
+ assert len (units ) == 7
95
102
96
103
97
104
def test_search_content_by_type (populated_repo ):
@@ -118,6 +125,15 @@ def test_search_content_by_type(populated_repo):
118
125
repository_memberships = ["repo1" ],
119
126
provides = [RpmDependency (name = "gcc" )],
120
127
),
128
+ RpmUnit (
129
+ name = "jq" ,
130
+ version = "4.0" ,
131
+ release = "1" ,
132
+ arch = "x86_64" ,
133
+ repository_memberships = ["repo1" ],
134
+ unit_id = "23a7711a-8133-2876-37eb-dcd9e87a1613" ,
135
+ files = ["/some/file" , "/another/file" , "/yet/another/file" , "/script" ],
136
+ ),
121
137
]
122
138
123
139
@@ -156,6 +172,14 @@ def test_search_content_with_fields(populated_repo):
156
172
arch = "x86_64" ,
157
173
repository_memberships = ["repo1" ],
158
174
),
175
+ RpmUnit (
176
+ name = "jq" ,
177
+ version = "4.0" ,
178
+ release = "1" ,
179
+ arch = "x86_64" ,
180
+ repository_memberships = ["repo1" ],
181
+ unit_id = "23a7711a-8133-2876-37eb-dcd9e87a1613" ,
182
+ ),
159
183
]
160
184
161
185
@@ -166,7 +190,7 @@ def test_search_erratum_by_type(populated_repo):
166
190
units = list (populated_repo .search_content (crit ))
167
191
assert units == [
168
192
ErratumUnit (
169
- unit_id = "85776e9a-dd84-f39e-7154-5a137a1d5006 " ,
193
+ unit_id = "d71037d1-b83e-90ec-17e0-aa3c03983ca8 " ,
170
194
id = "RHBA-1234:56" ,
171
195
summary = "The best advisory" ,
172
196
repository_memberships = ["repo1" ],
@@ -207,7 +231,7 @@ def test_search_content_by_unit_type(populated_repo):
207
231
units = list (populated_repo .search_content (crit ))
208
232
assert sorted (units ) == [
209
233
ModulemdUnit (
210
- unit_id = "23a7711a-8133-2876-37eb-dcd9e87a1613 " ,
234
+ unit_id = "e6f4590b-9a16-4106-cf6a-659eb4862b21 " ,
211
235
name = "module1" ,
212
236
stream = "s1" ,
213
237
version = 1234 ,
@@ -216,7 +240,7 @@ def test_search_content_by_unit_type(populated_repo):
216
240
repository_memberships = ["repo1" ],
217
241
),
218
242
ModulemdUnit (
219
- unit_id = "e6f4590b-9a16-4106-cf6a-659eb4862b21 " ,
243
+ unit_id = "85776e9a-dd84-f39e-7154-5a137a1d5006 " ,
220
244
name = "module2" ,
221
245
stream = "s2" ,
222
246
version = 1234 ,
@@ -239,7 +263,7 @@ def test_search_content_mixed_fields(populated_repo):
239
263
# Note: sorting different types not natively supported, hence sorting by repr
240
264
assert sorted (units , key = repr ) == [
241
265
ModulemdUnit (
242
- unit_id = "23a7711a-8133-2876-37eb-dcd9e87a1613 " ,
266
+ unit_id = "e6f4590b-9a16-4106-cf6a-659eb4862b21 " ,
243
267
name = "module1" ,
244
268
stream = "s1" ,
245
269
version = 1234 ,
@@ -266,7 +290,7 @@ def test_search_content_subfields(populated_repo):
266
290
crit = Criteria .and_ (
267
291
Criteria .with_unit_type (RpmUnit ), Criteria .with_field ("provides.name" , "gcc" )
268
292
)
269
- units = list (populated_repo .search_content (crit ))
293
+ units = list (populated_repo .search_content (crit ). result () )
270
294
271
295
assert units == [
272
296
RpmUnit (
@@ -280,3 +304,26 @@ def test_search_content_subfields(populated_repo):
280
304
repository_memberships = ["repo1" ],
281
305
)
282
306
]
307
+
308
+
309
+ def test_search_content_files (populated_repo ):
310
+ """
311
+ search_content using files subfield in attributes that are lists of strings.
312
+ """
313
+ crit = Criteria .and_ (
314
+ Criteria .with_unit_type (RpmUnit ),
315
+ Criteria .with_field ("files" , "/some/file" ),
316
+ )
317
+ units = list (populated_repo .search_content (crit ).result ())
318
+
319
+ assert units == [
320
+ RpmUnit (
321
+ name = "jq" ,
322
+ version = "4.0" ,
323
+ release = "1" ,
324
+ arch = "x86_64" ,
325
+ repository_memberships = ["repo1" ],
326
+ unit_id = "23a7711a-8133-2876-37eb-dcd9e87a1613" ,
327
+ files = ["/some/file" , "/another/file" , "/yet/another/file" , "/script" ],
328
+ )
329
+ ]
0 commit comments