Merge ppa-dev-tools:add-filter-packages-to-results into ppa-dev-tools:main
- Git
- lp:ppa-dev-tools
- add-filter-packages-to-results
- Merge into main
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merge reported by: | Bryce Harrington | ||||||||
Merged at revision: | f414712385cc9ff782fd8097f70fcf444da035e3 | ||||||||
Proposed branch: | ppa-dev-tools:add-filter-packages-to-results | ||||||||
Merge into: | ppa-dev-tools:main | ||||||||
Diff against target: |
518 lines (+211/-67) 9 files modified
RELEASING.md (+0/-3) ppa/io.py (+10/-5) ppa/job.py (+14/-6) ppa/ppa.py (+33/-9) scripts/ppa (+5/-5) tests/test_job.py (+140/-30) tests/test_ppa.py (+2/-2) tests/test_result.py (+5/-5) tests/test_scripts_ppa.py (+2/-2) |
||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andreas Hasenack (community) | Approve | ||
PpaDevTools Developers | Pending | ||
Canonical Server Reporter | Pending | ||
Review via email: mp+462844@code.launchpad.net |
Commit message
Description of the change
This implements a new feature for LP: #2025483 to expand the --packages option to also filter results and running or waiting jobs. It also includes a minor fix for excessive warnings displayed for non-existent results (this is cosmetic regression caused in an earlier enhancement), and a couple fixes to recently introduced regressions.
Probably most straightforward way to test this is against the reporter's PPA:
$ ./scripts/ppa tests -r noble bdrung/ppa -p initramfs-tools
Without this fix, that currently displays results for initramfs-tools and apport. With this fix applied, that same command will only display the initramfs-tools results.
Andreas Hasenack (ahasenack) : | # |
Andreas Hasenack (ahasenack) : | # |
Andreas Hasenack (ahasenack) wrote : | # |
The rest is ok. If that test in ppa/job.py is the "old way of running tests" and doesn't even work anymore, then perhaps it can be removed?
Bryce Harrington (bryce) wrote : | # |
Thanks for finding the parameter issue, it's fixed and I've squashed and re-pushed.
Bryce Harrington (bryce) wrote : | # |
Thanks; landed:
stirling: ~/src/PpaDevToo
Updating e83c53f..f414712
Fast-forward
RELEASING.md | 3 --
ppa/io.py | 15 +++++---
ppa/job.py | 20 +++++++---
ppa/ppa.py | 42 +++++++
scripts/ppa | 10 ++---
tests/test_job.py | 170 +++++++
tests/test_ppa.py | 4 +-
tests/
tests/
9 files changed, 211 insertions(+), 67 deletions(-)
stirling: ~/src/PpaDevToo
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To git+ssh:
e83c53f..f414712 main -> main
stirling: ~/src/PpaDevToo
Preview Diff
1 | diff --git a/RELEASING.md b/RELEASING.md |
2 | index f5677b2..eaed535 100644 |
3 | --- a/RELEASING.md |
4 | +++ b/RELEASING.md |
5 | @@ -83,9 +83,6 @@ Generate the snap |
6 | * Verify the snap |
7 | $ sudo snap install ppa-dev-tools_<version>_amd64.snap --devmode |
8 | ppa-dev-tools <version> installed |
9 | - $ snap alias ppa-dev-tools.ppa ppa |
10 | - Added: |
11 | - - ppa-dev-tools.ppa as ppa |
12 | $ ppa --version |
13 | ppa 0.4.0 |
14 | |
15 | diff --git a/ppa/io.py b/ppa/io.py |
16 | index cea3b1f..0bd5326 100644 |
17 | --- a/ppa/io.py |
18 | +++ b/ppa/io.py |
19 | @@ -26,8 +26,13 @@ def open_url(url, desc="data"): |
20 | try: |
21 | return urllib.request.urlopen(request) |
22 | except urllib.error.HTTPError as e: |
23 | - # 401 here means nothing is published or ran yet. |
24 | - # This is a rather common case, so skip mention of it |
25 | - if e.code != 401: |
26 | - sys.stderr.write(f"Error: Could not retrieve {desc} from {url}: {e}") |
27 | - return None |
28 | + if e.code == 401: |
29 | + # 401 means access denied. Launchpad sometimes returns this |
30 | + # when something is not published yet. |
31 | + return None |
32 | + elif e.code == 404: |
33 | + # 404 means not found; prefer not to emit error messages |
34 | + return None |
35 | + else: |
36 | + sys.stderr.write(f"Error: Could not retrieve {desc} from {url}: {e}\n") |
37 | + return None |
38 | diff --git a/ppa/job.py b/ppa/job.py |
39 | index c9a5ee8..c1cadb9 100755 |
40 | --- a/ppa/job.py |
41 | +++ b/ppa/job.py |
42 | @@ -92,7 +92,7 @@ class Job: |
43 | return f"{URL_AUTOPKGTEST}/request.cgi?{parameter_str}" |
44 | |
45 | |
46 | -def get_running(response, releases=None, ppa=None) -> Iterator[Job]: |
47 | +def get_running(response, releases=None, sources=None, ppa=None) -> Iterator[Job]: |
48 | """Return iterator currently running autopkgtests for given criteria. |
49 | |
50 | Filters the list of running autopkgtest jobs by the given series |
51 | @@ -102,12 +102,16 @@ def get_running(response, releases=None, ppa=None) -> Iterator[Job]: |
52 | results for that series or ppa. |
53 | |
54 | :param HTTPResponse response: Context manager; the response from urlopen() |
55 | - :param list[str] releases: The Ubuntu series codename(s), or None. |
56 | + :param List[str] releases: The Ubuntu series codename(s), or None. |
57 | + :param List[str] sources: Only retrieve results for these |
58 | + source packages, or all if blank or None. |
59 | :param str ppa: The PPA address criteria, or None. |
60 | :rtype: Iterator[Job] |
61 | :returns: Currently running jobs, if any, or an empty list on error |
62 | """ |
63 | for pkg, jobs in json.loads(response.read().decode('utf-8') or '{}').items(): |
64 | + if sources and (pkg not in sources): |
65 | + continue |
66 | for handle in jobs: |
67 | for codename in jobs[handle]: |
68 | for arch, jobinfo in jobs[handle][codename].items(): |
69 | @@ -122,7 +126,7 @@ def get_running(response, releases=None, ppa=None) -> Iterator[Job]: |
70 | yield job |
71 | |
72 | |
73 | -def get_waiting(response, releases=None, ppa=None) -> Iterator[Job]: |
74 | +def get_waiting(response, releases=None, sources=None, ppa=None) -> Iterator[Job]: |
75 | """Return iterator of queued autopkgtests for given criteria. |
76 | |
77 | Filters the list of autopkgtest jobs waiting for execution by the |
78 | @@ -132,7 +136,9 @@ def get_waiting(response, releases=None, ppa=None) -> Iterator[Job]: |
79 | available results for that series or ppa. |
80 | |
81 | :param HTTPResponse response: Context manager; the response from urlopen() |
82 | - :param list[str] releases: The Ubuntu series codename(s), or None. |
83 | + :param List[str] releases: The Ubuntu series codename(s), or None. |
84 | + :param List[str] sources: Only retrieve results for these |
85 | + source packages, or all if blank or None. |
86 | :param str ppa: The PPA address criteria, or None. |
87 | :rtype: Iterator[Job] |
88 | :returns: Currently waiting jobs, if any, or an empty list on error |
89 | @@ -145,6 +151,8 @@ def get_waiting(response, releases=None, ppa=None) -> Iterator[Job]: |
90 | if key == 'private job': |
91 | continue |
92 | (pkg, json_data) = key.split(maxsplit=1) |
93 | + if sources and (pkg not in sources): |
94 | + continue |
95 | jobinfo = json.loads(json_data) |
96 | n += 1 |
97 | triggers = jobinfo.get('triggers', None) |
98 | @@ -225,13 +233,13 @@ if __name__ == "__main__": |
99 | |
100 | print("running:") |
101 | response = urlopen(f"file://{root_dir}/tests/data/running-20220822.json") |
102 | - for job in get_running(response, ['kinetic'], ppa): |
103 | + for job in get_running(response, releases=['kinetic'], sources=None, ppa=ppa): |
104 | print(job) |
105 | print() |
106 | |
107 | print("waiting:") |
108 | response = urlopen(f"file://{root_dir}/tests/data/queues-20220822.json") |
109 | - for job in get_waiting(response, ['kinetic'], ppa): |
110 | + for job in get_waiting(response, releases=['kinetic'], sources=None, ppa=ppa): |
111 | print(job) |
112 | print() |
113 | |
114 | diff --git a/ppa/ppa.py b/ppa/ppa.py |
115 | index 5fd8056..7651f61 100755 |
116 | --- a/ppa/ppa.py |
117 | +++ b/ppa/ppa.py |
118 | @@ -18,11 +18,12 @@ import enum |
119 | from datetime import datetime |
120 | from functools import lru_cache |
121 | from itertools import chain |
122 | +from typing import Iterator, List |
123 | from lazr.restfulclient.errors import BadRequest, NotFound, Unauthorized |
124 | |
125 | from .constants import URL_AUTOPKGTEST |
126 | from .io import open_url |
127 | -from .job import (get_waiting, get_running) |
128 | +from .job import Job, get_waiting, get_running |
129 | from .result import get_results |
130 | |
131 | |
132 | @@ -534,41 +535,60 @@ class Ppa: |
133 | print("Successfully published all builds for all architectures") |
134 | return retval |
135 | |
136 | - def get_autopkgtest_waiting(self, releases: list[str]): |
137 | + def get_autopkgtest_waiting( |
138 | + self, |
139 | + releases: 'List[str] | None', |
140 | + sources: 'List[str] | None' = None |
141 | + ) -> Iterator[Job]: |
142 | """Return iterator of queued autopkgtests for this PPA. |
143 | |
144 | See get_waiting() for details |
145 | |
146 | - :param list[str] releases: The Ubuntu series codename(s), or None. |
147 | + :param List[str] releases: The Ubuntu series codename(s), or None. |
148 | + :param List[str] sources: Only retrieve results for these |
149 | + source packages, or all if blank or None. |
150 | :rtype: Iterator[Job] |
151 | :returns: Currently waiting jobs, if any, or an empty list on error |
152 | """ |
153 | response = open_url(f"{URL_AUTOPKGTEST}/queues.json", "waiting autopkgtests") |
154 | if response: |
155 | - return get_waiting(response, releases=releases, ppa=str(self)) |
156 | + return get_waiting(response, releases=releases, sources=sources, ppa=str(self)) |
157 | return [] |
158 | |
159 | - def get_autopkgtest_running(self, releases: list[str]): |
160 | + def get_autopkgtest_running( |
161 | + self, |
162 | + releases: 'List[str] | None', |
163 | + sources: 'List[str] | None' = None |
164 | + ) -> Iterator[Job]: |
165 | """Return iterator of queued autopkgtests for this PPA. |
166 | |
167 | See get_running() for details |
168 | |
169 | - :param list[str] releases: The Ubuntu series codename(s), or None. |
170 | + :param List[str] releases: The Ubuntu series codename(s), or None. |
171 | + :param List[str] packages: Only retrieve results for these |
172 | + source packages, or all if blank or None. |
173 | :rtype: Iterator[Job] |
174 | :returns: Currently running jobs, if any, or an empty list on error |
175 | """ |
176 | response = open_url(f"{URL_AUTOPKGTEST}/static/running.json", "running autopkgtests") |
177 | if response: |
178 | - return get_running(response, releases=releases, ppa=str(self)) |
179 | + return get_running(response, releases=releases, sources=sources, ppa=str(self)) |
180 | return [] |
181 | |
182 | - def get_autopkgtest_results(self, releases: list[str], architectures: list[str]): |
183 | + def get_autopkgtest_results( |
184 | + self, |
185 | + releases: 'List[str] | None', |
186 | + architectures: 'List[str] | None', |
187 | + sources: 'List[str] | None' = None |
188 | + ) -> Iterator[dict]: |
189 | """Returns iterator of results from autopkgtest runs for this PPA. |
190 | |
191 | See get_results() for details |
192 | |
193 | :param list[str] releases: The Ubuntu series codename(s), or None. |
194 | :param list[str] architectures: The hardware architectures. |
195 | + :param list[str] sources: Only retrieve results for these |
196 | + source packages, or all if blank or None. |
197 | :rtype: Iterator[dict] |
198 | :returns: Autopkgtest results, if any, or an empty list on error |
199 | """ |
200 | @@ -579,7 +599,11 @@ class Ppa: |
201 | response = open_url(f"{base_results_url}?format=plain") |
202 | if response: |
203 | trigger_sets = {} |
204 | - for result in get_results(response, base_results_url, arches=architectures): |
205 | + for result in get_results( |
206 | + response=response, |
207 | + base_url=base_results_url, |
208 | + arches=architectures, |
209 | + sources=sources): |
210 | trigger = ', '.join([str(r) for r in result.get_triggers()]) |
211 | trigger_sets.setdefault(trigger, []) |
212 | trigger_sets[trigger].append(result) |
213 | diff --git a/scripts/ppa b/scripts/ppa |
214 | index 2172740..c2f803d 100755 |
215 | --- a/scripts/ppa |
216 | +++ b/scripts/ppa |
217 | @@ -1057,15 +1057,16 @@ def command_tests(lp: Lp, config: dict[str, str]) -> int: |
218 | ) |
219 | |
220 | # Results |
221 | - show_results(the_ppa.get_autopkgtest_results(releases, architectures), |
222 | + the_ppa.get_autopkgtest_results(releases, architectures, packages) |
223 | + show_results(the_ppa.get_autopkgtest_results(releases, architectures, packages), |
224 | config.get('show_urls')) |
225 | |
226 | # Running Queue |
227 | - show_running(sorted(the_ppa.get_autopkgtest_running(releases), |
228 | + show_running(sorted(the_ppa.get_autopkgtest_running(releases, packages), |
229 | key=lambda k: str(k.submit_time))) |
230 | |
231 | # Waiting Queue |
232 | - show_waiting(the_ppa.get_autopkgtest_waiting(releases)) |
233 | + show_waiting(the_ppa.get_autopkgtest_waiting(releases, packages)) |
234 | |
235 | return os.EX_OK |
236 | except KeyboardInterrupt: |
237 | @@ -1115,11 +1116,10 @@ def main(args: argparse.Namespace) -> int: |
238 | dbg(config) |
239 | |
240 | command = args.command |
241 | - |
242 | try: |
243 | func, param = COMMANDS[command] |
244 | except KeyError: |
245 | - parser.error(f"No such command {args.command}") |
246 | + parser.error(f"No such command {command}") |
247 | return os.EX_USAGE |
248 | if param: |
249 | return func(lp, config, param) |
250 | diff --git a/tests/test_job.py b/tests/test_job.py |
251 | index 4e2f7c6..95f86dd 100644 |
252 | --- a/tests/test_job.py |
253 | +++ b/tests/test_job.py |
254 | @@ -101,7 +101,7 @@ def test_ppas(): |
255 | (['t/1', 'u/2'], '?release=c&arch=d&package=b&trigger=t%2F1&trigger=u%2F2'), |
256 | ]) |
257 | def test_request_url(triggers, endswith): |
258 | - """Checks Job object textual presentation.""" |
259 | + """Checks Job object can create valid URLs for starting the test runs.""" |
260 | jobinfo = { |
261 | 'triggers': triggers, |
262 | 'ppas': ['ppa:a/b', 'ppa:c/d'] |
263 | @@ -111,37 +111,147 @@ def test_request_url(triggers, endswith): |
264 | assert job.request_url.endswith(endswith) |
265 | |
266 | |
267 | -def test_get_running(): |
268 | - """Checks output from the get_running() command.""" |
269 | - json_text = ('{"mypackage": {"my-job-id": {"focal": { "arm64": [' |
270 | - '{"submit-time": "2022-08-19 20:59:01", ' |
271 | - '"triggers": ["yourpackage/1.2.3"], ' |
272 | - '"ppas": ["ppa:me/myppa"]}, ' |
273 | - '1234, ' |
274 | - '"Log Output Here"' |
275 | - '] } } } }') |
276 | +@pytest.mark.parametrize('json_text, params, expected', [ |
277 | + ( |
278 | + # No Jobs returned if nothing is running in autopkgtest |
279 | + '', |
280 | + {'releases': [], 'sources': None}, |
281 | + {'repr': '', 'triggers': [], 'ppas': []} |
282 | + ), |
283 | + ( |
284 | + # No Jobs returned if nothing is running for the specified PPA |
285 | + ( |
286 | + '{"x": {"x-job-id": {"focal": { "x": [' |
287 | + '{"submit-time": "2022-08-19 20:59:01", ' |
288 | + '"triggers": ["x/1.2.3"], ' |
289 | + '"ppas": ["ppa:x/x"]}, ' |
290 | + '1234, ' |
291 | + '"Log Output Here"' |
292 | + '] } } } }' |
293 | + ), |
294 | + {'releases': [], 'ppa': 'ppa:me/myppa', 'sources': None}, |
295 | + {'repr': '', 'triggers': [], 'ppas': []} |
296 | + ), |
297 | + ( |
298 | + # No Jobs returned if nothing running for the PPA matches the specified release |
299 | + ( |
300 | + '{"x": {"x-job-id": {"focal": { "x": [' |
301 | + '{"submit-time": "2022-08-19 20:59:01", ' |
302 | + '"triggers": ["x/1.2.3"], ' |
303 | + '"ppas": ["ppa:me/myppa"]}, ' |
304 | + '1234, ' |
305 | + '"Log Output Here"' |
306 | + '] } } } }' |
307 | + ), |
308 | + {'releases': ['jammy'], 'ppa': 'ppa:me/myppa', 'sources': None}, |
309 | + {'repr': '', 'triggers': [], 'ppas': []} |
310 | + ), |
311 | + ( |
312 | + # No Jobs returned if nothing running for the PPA matches the specified package |
313 | + ( |
314 | + '{"x": {"x-job-id": {"focal": { "arm64": [' |
315 | + '{"submit-time": "2022-08-19 20:59:01", ' |
316 | + '"triggers": ["x/1.2.3"], ' |
317 | + '"ppas": ["ppa:me/myppa"]}, ' |
318 | + '1234, ' |
319 | + '"Log Output Here"' |
320 | + '] } } } }' |
321 | + ), |
322 | + {'releases': None, 'ppa': 'ppa:me/myppa', 'sources': ['mypackage']}, |
323 | + {'repr': '', 'triggers': [], 'ppas': []} |
324 | + ), |
325 | + ( |
326 | + # Correct Job should be returned for matching criteria |
327 | + ( |
328 | + '{"mypackage": {"x-job-id": {"focal": { "arm64": [' |
329 | + '{"submit-time": "2022-08-19 20:59:01", ' |
330 | + '"triggers": ["x/1.2.3"], ' |
331 | + '"ppas": ["ppa:me/myppa"]}, ' |
332 | + '1234, ' |
333 | + '"Log Output Here"' |
334 | + '] } } } }' |
335 | + ), |
336 | + {'releases': ['focal'], 'ppa': 'ppa:me/myppa', 'sources': None}, |
337 | + { |
338 | + 'repr': "Job(source_package='mypackage', series='focal', arch='arm64')", |
339 | + 'triggers': ["x/1.2.3"], |
340 | + 'ppas': ["ppa:me/myppa"] |
341 | + } |
342 | + ), |
343 | +]) |
344 | +def test_get_running(json_text, params, expected): |
345 | + """Checks result of the get_running() command.""" |
346 | fake_response = RequestResponseMock(json_text) |
347 | - job = next(get_running(fake_response, releases=['focal'], ppa='ppa:me/myppa')) |
348 | - assert repr(job) == "Job(source_package='mypackage', series='focal', arch='arm64')" |
349 | - assert job.triggers == ["yourpackage/1.2.3"] |
350 | - assert job.ppas == ["ppa:me/myppa"] |
351 | + |
352 | + try: |
353 | + job = next(get_running(fake_response, **params)) |
354 | + assert repr(job) == expected['repr'] |
355 | + assert job.triggers == expected['triggers'] |
356 | + assert job.ppas == expected['ppas'] |
357 | + except StopIteration: |
358 | + assert expected['repr'] == '' |
359 | + assert expected['triggers'] == [] |
360 | + assert expected['ppas'] == [] |
361 | |
362 | |
363 | -def test_get_waiting(): |
364 | - """Checks output from the get_waiting() command.""" |
365 | +@pytest.mark.parametrize('json_text, params, expected', [ |
366 | + ( |
367 | + # No Jobs returned if nothing is running in autopkgtest |
368 | + "", |
369 | + {'releases': [], 'sources': None}, |
370 | + {'repr': '', 'source_package': [], 'triggers': [], 'ppas': []} |
371 | + ), |
372 | + ( |
373 | + # No Jobs returned if nothing is running for the specified PPA |
374 | + ( |
375 | + '{ "ubuntu": { "focal": { "amd64": [' |
376 | + ' "a\\n{\\"requester\\": \\"you\\",' |
377 | + ' \\"submit-time\\": \\"2022-08-19 07:37:56\\",' |
378 | + ' \\"triggers\\": [ \\"a/1.2-3\\", \\"b/1-1\\" ] }",' |
379 | + ' "b\\n{\\"requester\\": \\"you\\",' |
380 | + ' \\"submit-time\\": \\"2022-08-19 07:37:57\\",' |
381 | + ' \\"ppas\\": [ \\"ppa:x/x\\" ],' |
382 | + ' \\"triggers\\": [ \\"c/3.2-1\\", \\"d/2-2\\" ] }"' |
383 | + '] } } }' |
384 | + ), |
385 | + {'releases': None, 'ppa': 'ppa:me/myppa', 'sources': None}, |
386 | + {'repr': '', 'source_package': None, 'triggers': [], 'ppas': []} |
387 | + ), |
388 | + ( |
389 | + # Correct Job should be returned for matching criteria |
390 | + ( |
391 | + '{ "ubuntu": { "focal": { "amd64": [' |
392 | + ' "a\\n{\\"requester\\": \\"you\\",' |
393 | + ' \\"submit-time\\": \\"2022-08-19 07:37:56\\",' |
394 | + ' \\"triggers\\": [ \\"a/1.2-3\\", \\"b/1-1\\" ] }",' |
395 | + ' "b\\n{\\"requester\\": \\"you\\",' |
396 | + ' \\"submit-time\\": \\"2022-08-19 07:37:57\\",' |
397 | + ' \\"ppas\\": [ \\"ppa:me/myppa\\" ],' |
398 | + ' \\"triggers\\": [ \\"c/3.2-1\\", \\"d/2-2\\" ] }"' |
399 | + '] } } }' |
400 | + ), |
401 | + {'releases': ['focal'], 'ppa': 'ppa:me/myppa', 'sources': None}, |
402 | + { |
403 | + 'repr': "Job(source_package='b', series='focal', arch='amd64')", |
404 | + 'source_package': 'b', |
405 | + 'triggers': ['c/3.2-1', 'd/2-2'], |
406 | + 'ppas': ['ppa:me/myppa'] |
407 | + } |
408 | + ), |
409 | +]) |
410 | +def test_get_waiting(json_text, params, expected): |
411 | + """Checks result of the get_waiting() command.""" |
412 | # TODO: I think ppas need to be in "ppa" instead of under "ubuntu" but need to doublecheck. |
413 | - json_text = ('{ "ubuntu": { "focal": { "amd64": [' |
414 | - ' "a\\n{\\"requester\\": \\"you\\",' |
415 | - ' \\"submit-time\\": \\"2022-08-19 07:37:56\\",' |
416 | - ' \\"triggers\\": [ \\"a/1.2-3\\", \\"b/1-1\\" ] }",' |
417 | - ' "b\\n{\\"requester\\": \\"you\\",' |
418 | - ' \\"submit-time\\": \\"2022-08-19 07:37:57\\",' |
419 | - ' \\"ppas\\": [ \\"ppa:me/myppa\\" ],' |
420 | - ' \\"triggers\\": [ \\"c/3.2-1\\", \\"d/2-2\\" ] }"' |
421 | - '] } } }') |
422 | fake_response = RequestResponseMock(json_text) |
423 | - job = next(get_waiting(fake_response, releases=['focal'], ppa='ppa:me/myppa')) |
424 | - assert job |
425 | - assert job.source_package == "b" |
426 | - assert job.ppas == ['ppa:me/myppa'] |
427 | - assert job.triggers == ['c/3.2-1', 'd/2-2'] |
428 | + try: |
429 | + job = next(get_waiting(fake_response, **params)) |
430 | + assert job |
431 | + |
432 | + assert repr(job) == expected['repr'] |
433 | + assert job.source_package == expected['source_package'] |
434 | + assert job.triggers == expected['triggers'] |
435 | + assert job.ppas == expected['ppas'] |
436 | + except StopIteration: |
437 | + assert expected['repr'] == '' |
438 | + assert expected['triggers'] == [] |
439 | + assert expected['ppas'] == [] |
440 | diff --git a/tests/test_ppa.py b/tests/test_ppa.py |
441 | index 1f8fc65..dcdf15d 100644 |
442 | --- a/tests/test_ppa.py |
443 | +++ b/tests/test_ppa.py |
444 | @@ -98,8 +98,8 @@ def test_get_autopkgtest_results(mock_open_url, mock_get_results, |
445 | result.get_triggers = lambda: "x" |
446 | fake_results[k].append(result) |
447 | |
448 | - def fake_get_results(response, url, arches): |
449 | - return fake_results[url] |
450 | + def fake_get_results(response, base_url, arches, sources): |
451 | + return fake_results[base_url] |
452 | mock_get_results.side_effect = fake_get_results |
453 | |
454 | ppa = Ppa(ppa_name, owner_name) |
455 | diff --git a/tests/test_result.py b/tests/test_result.py |
456 | index a3597af..89a6c8f 100644 |
457 | --- a/tests/test_result.py |
458 | +++ b/tests/test_result.py |
459 | @@ -62,7 +62,7 @@ def test_str(): |
460 | [], |
461 | True, |
462 | """ + ✅ source on series for arch @ 01.02.03 04:05:06 |
463 | - • Log: file:///home/bryce/src/PpaDevTools/ppa-dev-tools-feature-rdepends-testing/tests/data/x |
464 | + • Log: file://<DATA_DIR>/x |
465 | """ |
466 | ), |
467 | ( |
468 | @@ -70,7 +70,7 @@ def test_str(): |
469 | '20030201_040506', |
470 | [], |
471 | False, |
472 | - """ + ✅ source on series for arch @ 01.02.03 04:05:06 \x1b]8;;file:///home/bryce/src/PpaDevTools/ppa-dev-tools-feature-rdepends-testing/tests/data/x\x1b\\Log️ 🗒️ \x1b]8;;\x1b\\ |
473 | + """ + ✅ source on series for arch @ 01.02.03 04:05:06 \x1b]8;;file://<DATA_DIR>/x\x1b\\Log️ 🗒️ \x1b]8;;\x1b\\ |
474 | """ |
475 | ), |
476 | ( |
477 | @@ -79,7 +79,7 @@ def test_str(): |
478 | [Subtest('x PASS'), Subtest('y PASS'), Subtest('z SKIP')], |
479 | True, |
480 | """ + ✅ source on series for arch @ 01.02.03 04:05:06 |
481 | - • Log: file:///home/bryce/src/PpaDevTools/ppa-dev-tools-feature-rdepends-testing/tests/data/x |
482 | + • Log: file://<DATA_DIR>/x |
483 | """ |
484 | ), |
485 | ( |
486 | @@ -88,7 +88,7 @@ def test_str(): |
487 | [Subtest('x PASS'), Subtest('y FAIL'), Subtest('z SKIP')], |
488 | True, |
489 | """ + ❌ source on series for arch @ 01.02.03 04:05:06 |
490 | - • Log: file:///home/bryce/src/PpaDevTools/ppa-dev-tools-feature-rdepends-testing/tests/data/x |
491 | + • Log: file://<DATA_DIR>/x |
492 | • Status: FAIL |
493 | • x PASS 🟩 |
494 | • y FAIL 🟥 |
495 | @@ -105,7 +105,7 @@ def test_to_bullet_tree(timestamp, subtests, show_urls, expected): |
496 | result.get_subtests = lambda: subtests |
497 | |
498 | out = result.to_bullet_tree(show_urls) |
499 | - assert out == expected |
500 | + assert out == expected.replace("<DATA_DIR>", DATA_DIR) |
501 | |
502 | |
503 | def test_timestamp(): |
504 | diff --git a/tests/test_scripts_ppa.py b/tests/test_scripts_ppa.py |
505 | index 07a1b32..0f321dd 100644 |
506 | --- a/tests/test_scripts_ppa.py |
507 | +++ b/tests/test_scripts_ppa.py |
508 | @@ -794,8 +794,8 @@ def test_command_tests(urlopen_mock, |
509 | '''Checks that the tests command retrieves and displays correct results.''' |
510 | lp = LpServiceMock() |
511 | urlopen_mock.return_value = "{}" |
512 | - Ppa.get_autopkgtest_running = lambda x, y: [] |
513 | - Ppa.get_autopkgtest_waiting = lambda x, y: [] |
514 | + Ppa.get_autopkgtest_running = lambda x, y, z: [] |
515 | + Ppa.get_autopkgtest_waiting = lambda x, y, z: [] |
516 | |
517 | # Create a default PPA, for modification later |
518 | owner = lp.people[fake_config['owner_name']] |
A forgotten old test needs updating?