nixguix: Register task
Related to T3781
This commit is contained in:
parent
fbfdf88ea4
commit
6d2e7aa178
5 changed files with 47 additions and 1 deletions
|
@ -8,5 +8,5 @@ def register():
|
|||
|
||||
return {
|
||||
"lister": NixGuixLister,
|
||||
"task_modules": ["%s.tasks" % __name__],
|
||||
"task_modules": [f"{__name__}.tasks"],
|
||||
}
|
||||
|
|
14
swh/lister/nixguix/tasks.py
Normal file
14
swh/lister/nixguix/tasks.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Copyright (C) 2022 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
|
||||
|
||||
from celery import shared_task
|
||||
|
||||
|
||||
@shared_task(name=__name__ + ".NixGuixListerTask")
|
||||
def list_nixguix(**lister_args):
|
||||
"""Lister task for Arch Linux"""
|
||||
from swh.lister.nixguix.lister import NixGuixLister
|
||||
|
||||
return NixGuixLister.from_configfile(**lister_args).run().dict()
|
27
swh/lister/nixguix/tests/test_tasks.py
Normal file
27
swh/lister/nixguix/tests/test_tasks.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Copyright (C) 2022 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
|
||||
|
||||
from swh.lister.pattern import ListerStats
|
||||
|
||||
NAMESPACE = "swh.lister.nixguix"
|
||||
|
||||
|
||||
def test_nixguix_lister(swh_scheduler_celery_app, swh_scheduler_celery_worker, mocker):
|
||||
# setup the mocked ArchLister
|
||||
lister = mocker.patch(f"{NAMESPACE}.lister.NixGuixLister")
|
||||
lister.from_configfile.return_value = lister
|
||||
stats = ListerStats(pages=1, origins=42)
|
||||
lister.run.return_value = stats
|
||||
|
||||
res = swh_scheduler_celery_app.send_task(
|
||||
f"{NAMESPACE}.tasks.NixGuixListerTask",
|
||||
)
|
||||
assert res
|
||||
res.wait()
|
||||
assert res.successful()
|
||||
assert res.result == stats.dict()
|
||||
|
||||
lister.from_configfile.assert_called_once_with()
|
||||
lister.run.assert_called_once_with()
|
Loading…
Add table
Add a link
Reference in a new issue