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

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.
parent b02144b4
No related branches found
No related tags found
1 merge request!497sourceforge: Allow passing configuration arguments to task
# 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 # License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information # See top-level LICENSE file for more information
...@@ -10,15 +10,17 @@ from swh.lister.sourceforge.lister import SourceForgeLister ...@@ -10,15 +10,17 @@ from swh.lister.sourceforge.lister import SourceForgeLister
@shared_task(name=__name__ + ".FullSourceForgeLister") @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""" """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") @shared_task(name=__name__ + ".IncrementalSourceForgeLister")
def list_sourceforge_incremental() -> Dict[str, int]: def list_sourceforge_incremental(**lister_args) -> Dict[str, int]:
"""Full update of a SourceForge instance""" """Incremental update of a SourceForge instance"""
return SourceForgeLister.from_configfile(incremental=True).run().dict() return (
SourceForgeLister.from_configfile(incremental=True, **lister_args).run().dict()
)
@shared_task(name=__name__ + ".ping") @shared_task(name=__name__ + ".ping")
......
# 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 # See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version # License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information # See top-level LICENSE file for more information
...@@ -24,14 +24,16 @@ def test_sourceforge_full_lister_task( ...@@ -24,14 +24,16 @@ def test_sourceforge_full_lister_task(
mock_lister.from_configfile.return_value = mock_lister mock_lister.from_configfile.return_value = mock_lister
mock_lister.run.return_value = stats mock_lister.run.return_value = stats
kwargs = dict(enable_origins=False)
res = swh_scheduler_celery_app.send_task( res = swh_scheduler_celery_app.send_task(
"swh.lister.sourceforge.tasks.FullSourceForgeLister" "swh.lister.sourceforge.tasks.FullSourceForgeLister",
kwargs=kwargs,
) )
assert res assert res
res.wait() res.wait()
assert res.successful() 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() mock_lister.run.assert_called_once()
assert res.result == stats.dict() assert res.result == stats.dict()
...@@ -45,12 +47,12 @@ def test_incremental_listing( ...@@ -45,12 +47,12 @@ def test_incremental_listing(
mock_lister.run.return_value = stats mock_lister.run.return_value = stats
res = swh_scheduler_celery_app.send_task( res = swh_scheduler_celery_app.send_task(
"swh.lister.sourceforge.tasks.IncrementalSourceForgeLister" "swh.lister.sourceforge.tasks.IncrementalSourceForgeLister",
) )
assert res assert res
res.wait() res.wait()
assert res.successful() 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() mock_lister.run.assert_called_once()
assert res.result == stats.dict() assert res.result == stats.dict()
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