sourceforge: Allow passing configuration arguments to task

The constructor allows it but not the celery task.

This also aligns the behavior with other lister tasks.
This commit is contained in:
Antoine R. Dumont (@ardumont) 2023-08-04 15:18:22 +02:00
parent b02144b4f9
commit 928d592e10
No known key found for this signature in database
GPG key ID: 52E2E9840D10C3B8
2 changed files with 15 additions and 11 deletions

View file

@ -1,4 +1,4 @@
# Copyright (C) 2019-2021 the Software Heritage developers
# Copyright (C) 2019-2023 the Software Heritage developers
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
@ -10,15 +10,17 @@ from swh.lister.sourceforge.lister import SourceForgeLister
@shared_task(name=__name__ + ".FullSourceForgeLister")
def list_sourceforge_full() -> Dict[str, int]:
def list_sourceforge_full(**lister_args) -> Dict[str, int]:
"""Full update of a SourceForge instance"""
return SourceForgeLister.from_configfile().run().dict()
return SourceForgeLister.from_configfile(**lister_args).run().dict()
@shared_task(name=__name__ + ".IncrementalSourceForgeLister")
def list_sourceforge_incremental() -> Dict[str, int]:
"""Full update of a SourceForge instance"""
return SourceForgeLister.from_configfile(incremental=True).run().dict()
def list_sourceforge_incremental(**lister_args) -> Dict[str, int]:
"""Incremental update of a SourceForge instance"""
return (
SourceForgeLister.from_configfile(incremental=True, **lister_args).run().dict()
)
@shared_task(name=__name__ + ".ping")

View file

@ -1,4 +1,4 @@
# 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
@ -24,14 +24,16 @@ def test_sourceforge_full_lister_task(
mock_lister.from_configfile.return_value = mock_lister
mock_lister.run.return_value = stats
kwargs = dict(enable_origins=False)
res = swh_scheduler_celery_app.send_task(
"swh.lister.sourceforge.tasks.FullSourceForgeLister"
"swh.lister.sourceforge.tasks.FullSourceForgeLister",
kwargs=kwargs,
)
assert res
res.wait()
assert res.successful()
mock_lister.from_configfile.assert_called_once()
mock_lister.from_configfile.assert_called_once_with(**kwargs)
mock_lister.run.assert_called_once()
assert res.result == stats.dict()
@ -45,12 +47,12 @@ def test_incremental_listing(
mock_lister.run.return_value = stats
res = swh_scheduler_celery_app.send_task(
"swh.lister.sourceforge.tasks.IncrementalSourceForgeLister"
"swh.lister.sourceforge.tasks.IncrementalSourceForgeLister",
)
assert res
res.wait()
assert res.successful()
mock_lister.from_configfile.assert_called_once()
mock_lister.from_configfile.assert_called_once_with(incremental=True)
mock_lister.run.assert_called_once()
assert res.result == stats.dict()