forked from rpm-software-management/ci-dnf-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage-query.feature
More file actions
295 lines (275 loc) · 9.25 KB
/
package-query.feature
File metadata and controls
295 lines (275 loc) · 9.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
@not.with_dnf=4
Feature: api: query packages
Scenario: Construct queries and filter packages by name
Given I use repository "simple-base"
When I execute python libdnf5 api script with setup
"""
from libdnf5.common import QueryCmp_CONTAINS, QueryCmp_GLOB
query = libdnf5.rpm.PackageQuery(base)
query.filter_name(["labirinto"])
for pkg in query:
print(pkg.get_nevra())
query = libdnf5.rpm.PackageQuery(base)
query.filter_name(["*dal?-*"], QueryCmp_GLOB)
for pkg in query:
print(pkg.get_nevra())
query = libdnf5.rpm.PackageQuery(base)
query.filter_name(["gar"], QueryCmp_CONTAINS)
for pkg in query:
print(pkg.get_nevra())
"""
Then the exit code is 0
And stdout is
"""
labirinto-1.0-1.fc29.src
labirinto-1.0-1.fc29.x86_64
dedalo-signed-1.0-1.fc29.src
dedalo-signed-1.0-1.fc29.x86_64
vagare-1.0-1.fc29.src
vagare-1.0-1.fc29.x86_64
"""
Scenario: Construct query and filter fails due to bad argument type
Given I use repository "simple-base"
When I execute python libdnf5 api script with setup
"""
query = libdnf5.rpm.PackageQuery(base)
query.filter_name(99)
for pkg in query:
print(pkg.get_nevra())
"""
Then the exit code is 1
And stdout is empty
And stderr contains "TypeError: Wrong number or type of arguments for overloaded function 'PackageQuery_filter_name'."
Scenario: Construct queries and filter packages by arch
Given I use repository "dnf-ci-fedora"
When I execute python libdnf5 api script with setup
"""
from libdnf5.common import QueryCmp_NEQ, QueryCmp_NOT_GLOB
query = libdnf5.rpm.PackageQuery(base)
query.filter_arch(["noarch"])
for pkg in query:
print(pkg.get_na())
query = libdnf5.rpm.PackageQuery(base)
query.filter_arch(["x86*","*arch","?rc"], QueryCmp_NOT_GLOB)
for pkg in query:
print(pkg.get_na())
query = libdnf5.rpm.PackageQuery(base)
query.filter_arch(["x86_64","noarch","src"], QueryCmp_NEQ)
for pkg in query:
print(pkg.get_nevra())
"""
Then the exit code is 0
And stdout is
"""
abcde.noarch
basesystem.noarch
fedora-release.noarch
nodejs-docs.noarch
setup.noarch
lz4.i686
lz4-debuginfo.i686
lz4-devel.i686
lz4-static.i686
lz4-1.7.5-2.fc26.i686
lz4-debuginfo-1.7.5-2.fc26.i686
lz4-devel-1.7.5-2.fc26.i686
lz4-static-1.7.5-2.fc26.i686
"""
Scenario: Construct queries and filter packages by conflicts
Given I use repository "dnf-ci-rich"
When I execute python libdnf5 api script with setup
"""
query = libdnf5.rpm.PackageQuery(base)
query.filter_name(["milk"])
query.filter_arch(["x86_64"])
# milk conflicts with water; we get a conflict-list of milk first
# (it's a ReldepList containing water) and then we filter all packages
# that conflict with water (it's only milk)
query2 = libdnf5.rpm.PackageQuery(base)
for pkg in query:
query2.filter_conflicts(pkg.get_conflicts())
for pkg in query2:
print(pkg.get_nevra())
# now find water's conflicts differently: via PackageSet with Package
# objects
query3 = libdnf5.rpm.PackageQuery(base)
query3.filter_name(["water"])
query3.filter_arch(["x86_64"])
query4 = libdnf5.rpm.PackageQuery(base)
query4.filter_conflicts(query3)
for pkg in query4:
print(pkg.get_name())
"""
Then the exit code is 0
And stdout is
"""
milk-1.0-1.x86_64
milk
"""
Scenario: Construct queries and filter packages by description
Given I use repository "simple-base"
When I execute python libdnf5 api script with setup
"""
from libdnf5.common import QueryCmp_GLOB
query = libdnf5.rpm.PackageQuery(base)
query.filter_arch(["x86_64"])
query.filter_description(["*script*"], QueryCmp_GLOB)
filtered = [pkg.get_name() for pkg in query]
for pkg in sorted(filtered):
print(pkg)
query2 = libdnf5.rpm.PackageQuery(base)
query2.filter_arch(["x86_64"])
query2.filter_description(["vagare description"])
for pkg in query2:
print(pkg.get_nevra())
"""
Then the exit code is 0
And stdout is
"""
dedalo-signed
labirinto
vagare
vagare-1.0-1.fc29.x86_64
"""
Scenario: Construct queries and filter packages by files
Given I use repository "dnf-ci-fedora"
And I use repository "plugins-callbacks"
When I execute dnf with args "install glibc watermelon"
And I execute python libdnf5 api script with setup
"""
from libdnf5.common import QueryCmp_IEXACT, QueryCmp_GLOB
query = libdnf5.rpm.PackageQuery(base)
query.filter_arch(["x86_64"])
query.filter_file(["*dnf-plugin*"], QueryCmp_GLOB)
# NOTE: filtered files are not in primary, only in filelists, so
# no available pkgs (3 versions of watermelon in the repo) are found.
# config.get_optional_metadata_types_option().set(libdnf5.conf.METADATA_TYPE_FILELISTS)
# can be used before the repo is loaded to get also filelists
for pkg in query:
print(pkg.get_nevra())
query2 = libdnf5.rpm.PackageQuery(base)
query2.filter_arch(["x86_64"])
query2.filter_file(["/ETC/ld.so.conf"], QueryCmp_IEXACT)
query2.filter_installed()
# NOTE: without filter_installed, there would be glibc twice;
# the file is in primary, so available pkg in the repo is found, too
for pkg in query2:
print(pkg.get_nevra())
"""
Then the exit code is 0
And stdout is
"""
watermelon-3.0-1.fc29.x86_64
glibc-2.28-9.fc29.x86_64
"""
Scenario: Construct queries and filter packages by epoch
Given I use repository "repoquery-main"
When I execute python libdnf5 api script with setup
"""
from libdnf5.common import QueryCmp_NEQ
query = libdnf5.rpm.PackageQuery(base)
query.filter_arch(["x86_64"])
query.filter_epoch(["2"])
for pkg in query:
print(pkg.get_nevra())
query2 = libdnf5.rpm.PackageQuery(base)
query2.filter_epoch(["1","0"], QueryCmp_NEQ)
for pkg in query2:
print(pkg.get_nevra())
"""
Then the exit code is 0
And stdout is
"""
top-a-2:2.0-2.x86_64
top-a-2:2.0-2.src
top-a-2:2.0-2.x86_64
"""
Scenario: Construct queries and filter packages by repo_id
Given I use repository "simple-base"
And I use repository "dnf-ci-fedora"
When I execute python libdnf5 api script with setup
"""
from libdnf5.common import QueryCmp_GLOB
query = libdnf5.rpm.PackageQuery(base)
query.filter_arch(["x86_64"])
query.filter_repo_id(["simple-base"])
pkgs = [pkg.get_name() for pkg in query]
for pkg in sorted(pkgs):
print(pkg)
query2 = libdnf5.rpm.PackageQuery(base)
query2.filter_repo_id(["*base"], QueryCmp_GLOB)
pkgs2 = [pkg.get_nevra() for pkg in query2]
for pkg in sorted(pkgs2):
print(pkg)
"""
Then the exit code is 0
And stdout is
"""
dedalo-signed
labirinto
vagare
dedalo-signed-1.0-1.fc29.src
dedalo-signed-1.0-1.fc29.x86_64
labirinto-1.0-1.fc29.src
labirinto-1.0-1.fc29.x86_64
vagare-1.0-1.fc29.src
vagare-1.0-1.fc29.x86_64
"""
Scenario: Construct queries and filter packages by sourcerpm
Given I use repository "dnf-ci-fedora-updates"
When I execute python libdnf5 api script with setup
"""
from libdnf5.common import QueryCmp_GLOB
query = libdnf5.rpm.PackageQuery(base)
query.filter_arch(["x86_64"])
query.filter_sourcerpm(["flac-1.3.3-2.fc29.src.rpm"])
pkgs = [pkg.get_nevra() for pkg in query]
for pkg in sorted(pkgs):
print(pkg)
query2 = libdnf5.rpm.PackageQuery(base)
query.filter_arch(["x86_64"])
query2.filter_sourcerpm(["flac*"], QueryCmp_GLOB)
pkgs2 = [pkg.get_nevra() for pkg in query2]
for pkg in sorted(pkgs2):
print(pkg)
"""
Then the exit code is 0
And stdout is
"""
flac-1.3.3-2.fc29.x86_64
flac-libs-1.3.3-2.fc29.x86_64
flac-1.3.3-1.fc29.x86_64
flac-1.3.3-2.fc29.x86_64
flac-1.3.3-3.fc29.x86_64
flac-libs-1.3.3-1.fc29.x86_64
flac-libs-1.3.3-2.fc29.x86_64
flac-libs-1.3.3-3.fc29.x86_64
"""
Scenario: Construct queries and filter upgradable/upgrades
Given I use repository "dnf-ci-fedora"
When I execute dnf with args "install flac dwm wget"
And I use repository "dnf-ci-fedora-updates"
And I execute python libdnf5 api script with setup
"""
query = libdnf5.rpm.PackageQuery(base)
query.filter_arch(["x86_64"])
query.filter_upgradable()
pkgs = [pkg.get_nevra() for pkg in query]
for pkg in sorted(pkgs):
print(pkg)
query2 = libdnf5.rpm.PackageQuery(base)
query2.filter_upgrades()
pkgs2 = [pkg.get_nevra() for pkg in query2]
for pkg in sorted(pkgs2):
print(pkg)
"""
Then the exit code is 0
And stdout is
"""
flac-1.3.2-8.fc29.x86_64
wget-1.19.5-5.fc29.x86_64
flac-1.3.3-1.fc29.x86_64
flac-1.3.3-2.fc29.x86_64
flac-1.3.3-3.fc29.x86_64
wget-1.19.6-5.fc29.x86_64
"""