Page MenuHomeSoftware Heritage

D7117.id25805.diff
No OneTemporary

D7117.id25805.diff

diff --git a/mypy.ini b/mypy.ini
--- a/mypy.ini
+++ b/mypy.ini
@@ -16,3 +16,6 @@
[mypy-breezy.*]
ignore_missing_imports = True
+
+[mypy-celery.*]
+ignore_missing_imports = True
diff --git a/swh/loader/bzr/tasks.py b/swh/loader/bzr/tasks.py
new file mode 100644
--- /dev/null
+++ b/swh/loader/bzr/tasks.py
@@ -0,0 +1,26 @@
+# 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 typing import Optional
+
+from celery import shared_task
+
+from swh.loader.core.utils import parse_visit_date
+
+from .loader import BazaarLoader
+
+
+@shared_task(name=__name__ + ".LoadBazaar")
+def load_bzr(
+ *, url: str, directory: Optional[str] = None, visit_date: Optional[str] = None
+):
+ """Bazaar repository loading
+
+ Args: see :func:`BazaarLoader` constructor.
+ """
+ loader = BazaarLoader.from_configfile(
+ url=url, directory=directory, visit_date=parse_visit_date(visit_date)
+ )
+ return loader.load()
diff --git a/swh/loader/bzr/tests/test_tasks.py b/swh/loader/bzr/tests/test_tasks.py
new file mode 100644
--- /dev/null
+++ b/swh/loader/bzr/tests/test_tasks.py
@@ -0,0 +1,23 @@
+# 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
+
+
+def test_loader(
+ mocker, swh_config, swh_scheduler_celery_app, swh_scheduler_celery_worker
+):
+ mock_loader = mocker.patch("swh.loader.bzr.loader.BazaarLoader.load")
+ mock_loader.return_value = {"status": "eventful"}
+
+ res = swh_scheduler_celery_app.send_task(
+ "swh.loader.bzr.tasks.LoadBazaar",
+ 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()

File Metadata

Mime Type
text/plain
Expires
Nov 5 2024, 1:24 AM (10 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3223694

Event Timeline