From 8785fc1a4e783870c96b57521add8f2539ba310a Mon Sep 17 00:00:00 2001 From: David Douard Date: Tue, 3 Sep 2019 11:57:36 +0200 Subject: [PATCH] cgit: fix cgit's task module and tests forgot some `url_prefix` there. --- swh/lister/cgit/tasks.py | 10 +--------- swh/lister/cgit/tests/test_tasks.py | 25 +------------------------ 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/swh/lister/cgit/tasks.py b/swh/lister/cgit/tasks.py index 31148dd..723d44d 100644 --- a/swh/lister/cgit/tasks.py +++ b/swh/lister/cgit/tasks.py @@ -7,17 +7,9 @@ from swh.scheduler.celery_backend.config import app from .lister import CGitLister -def new_lister(url='https://git.kernel.org/', - url_prefix=None, - instance='kernal', **kw): - return CGitLister(url=url, instance=instance, url_prefix=url_prefix, - **kw) - - @app.task(name=__name__ + '.CGitListerTask') def cgit_lister(**lister_args): - lister = new_lister(**lister_args) - lister.run() + CGitLister(**lister_args).run() @app.task(name=__name__ + '.ping') diff --git a/swh/lister/cgit/tests/test_tasks.py b/swh/lister/cgit/tests/test_tasks.py index 4a36a05..38bf7b7 100644 --- a/swh/lister/cgit/tests/test_tasks.py +++ b/swh/lister/cgit/tests/test_tasks.py @@ -11,7 +11,7 @@ def test_ping(swh_app, celery_session_worker): @patch('swh.lister.cgit.tasks.CGitLister') -def test_lister_no_url_prefix(lister, swh_app, celery_session_worker): +def test_lister(lister, swh_app, celery_session_worker): # setup the mocked CGitLister lister.return_value = lister lister.run.return_value = None @@ -25,29 +25,6 @@ def test_lister_no_url_prefix(lister, swh_app, celery_session_worker): lister.assert_called_once_with( url='https://git.kernel.org/', - url_prefix=None, instance='kernel') lister.db_last_index.assert_not_called() lister.run.assert_called_once_with() - - -@patch('swh.lister.cgit.tasks.CGitLister') -def test_lister_with_url_prefix(lister, swh_app, celery_session_worker): - # setup the mocked CGitLister - lister.return_value = lister - lister.run.return_value = None - - res = swh_app.send_task( - 'swh.lister.cgit.tasks.CGitListerTask', - kwargs=dict(url='https://cgit.kde.org/', - url_prefix='https://anongit.kde.org/', instance='kde')) - assert res - res.wait() - assert res.successful() - - lister.assert_called_once_with( - url='https://cgit.kde.org/', - url_prefix='https://anongit.kde.org/', - instance='kde') - lister.db_last_index.assert_not_called() - lister.run.assert_called_once_with()