diff --git a/swh/loader/mercurial/tasks.py b/swh/loader/mercurial/tasks.py index 71fb259..1c8dabb 100644 --- a/swh/loader/mercurial/tasks.py +++ b/swh/loader/mercurial/tasks.py @@ -1,44 +1,44 @@ # Copyright (C) 2017-2021 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 typing import Optional from celery import shared_task from swh.loader.mercurial.utils import parse_visit_date -from .loader import HgArchiveBundle20Loader, HgBundle20Loader +from .from_disk import HgArchiveLoaderFromDisk, HgLoaderFromDisk @shared_task(name=__name__ + ".LoadMercurial") def load_hg( *, url: str, directory: Optional[str] = None, visit_date: Optional[str] = None ): """Mercurial repository loading Import a mercurial tarball into swh. - Args: see :func:`HgBundle20Loader.load`. + Args: see :func:`HgLoaderFromDisk.load`. """ - loader = HgBundle20Loader.from_configfile( + loader = HgLoaderFromDisk.from_configfile( url=url, directory=directory, visit_date=parse_visit_date(visit_date) ) return loader.load() @shared_task(name=__name__ + ".LoadArchiveMercurial") def load_hg_from_archive( *, url: str, archive_path: Optional[str] = None, visit_date: Optional[str] = None ): """Import a mercurial tarball into swh. - Args: see :func:`HgArchiveBundle20Loader.load`. + Args: see :func:`HgArchiveLoaderFromDisk.load`. """ - loader = HgArchiveBundle20Loader.from_configfile( + loader = HgArchiveLoaderFromDisk.from_configfile( url=url, archive_path=archive_path, visit_date=parse_visit_date(visit_date) ) return loader.load() diff --git a/swh/loader/mercurial/tests/test_tasks.py b/swh/loader/mercurial/tests/test_tasks.py index 8e70e00..68c4e40 100644 --- a/swh/loader/mercurial/tests/test_tasks.py +++ b/swh/loader/mercurial/tests/test_tasks.py @@ -1,47 +1,47 @@ # Copyright (C) 2018-2020 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 def test_loader( mocker, swh_config, swh_scheduler_celery_app, swh_scheduler_celery_worker ): - mock_loader = mocker.patch("swh.loader.mercurial.loader.HgBundle20Loader.load") + mock_loader = mocker.patch("swh.loader.mercurial.from_disk.HgLoaderFromDisk.load") mock_loader.return_value = {"status": "eventful"} res = swh_scheduler_celery_app.send_task( "swh.loader.mercurial.tasks.LoadMercurial", kwargs={"url": "origin_url", "directory": "/some/repo", "visit_date": "now",}, ) assert res res.wait() assert res.successful() assert res.result == {"status": "eventful"} mock_loader.assert_called_once_with() def test_archive_loader( mocker, swh_config, swh_scheduler_celery_app, swh_scheduler_celery_worker ): mock_loader = mocker.patch( - "swh.loader.mercurial.loader.HgArchiveBundle20Loader.load" + "swh.loader.mercurial.from_disk.HgArchiveLoaderFromDisk.load" ) mock_loader.return_value = {"status": "uneventful"} res = swh_scheduler_celery_app.send_task( "swh.loader.mercurial.tasks.LoadArchiveMercurial", kwargs={ "url": "another_url", "archive_path": "/some/tar.tgz", "visit_date": "now", }, ) assert res res.wait() assert res.successful() assert res.result == {"status": "uneventful"} mock_loader.assert_called_once_with()