Skip to content
Snippets Groups Projects
Verified Commit fcfb7004 authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

pypi: Allow passing configuration arguments to task

The constructor allows it but not the celery task.

This also aligns the behavior with other lister tasks.
parent 928d592e
No related branches found
Tags v5.9.6
1 merge request!497sourceforge: Allow passing configuration arguments to task
Pipeline #3762 passed
# Copyright (C) 2018-2021 the Software Heritage developers
# Copyright (C) 2018-2023 the Software Heritage developers
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
......@@ -8,9 +8,9 @@ from .lister import PyPILister
@shared_task(name=f"{__name__}.PyPIListerTask")
def list_pypi():
def list_pypi(**lister_args):
"Full listing of the PyPI registry"
lister = PyPILister.from_configfile()
lister = PyPILister.from_configfile(**lister_args)
return lister.run().dict()
......
# Copyright (C) 2019-2021 The Software Heritage developers
# Copyright (C) 2019-2023 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
......@@ -21,10 +21,13 @@ def test_pypi_full_lister(
lister.from_configfile.return_value = lister
lister.run.return_value = ListerStats(pages=1, origins=0)
res = swh_scheduler_celery_app.send_task("swh.lister.pypi.tasks.PyPIListerTask")
kwargs = dict(enable_origins=False)
res = swh_scheduler_celery_app.send_task(
"swh.lister.pypi.tasks.PyPIListerTask", kwargs=kwargs
)
assert res
res.wait()
assert res.successful()
lister.from_configfile.assert_called_once_with()
lister.from_configfile.assert_called_once_with(**kwargs)
lister.run.assert_called_once_with()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment