Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7066214
D7117.id25805.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D7117.id25805.diff
View Options
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
Details
Attached
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
Attached To
D7117: Add bzr loader task
Event Timeline
Log In to Comment