Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123463
D8702.id31418.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Subscribers
None
D8702.id31418.diff
View Options
diff --git a/requirements-swh.txt b/requirements-swh.txt
--- a/requirements-swh.txt
+++ b/requirements-swh.txt
@@ -1,4 +1,4 @@
swh.model >= 2.6.1
swh.storage >= 0.37.0
swh.scheduler >= 0.0.39
-swh.loader.core >= 3.0.0
+swh.loader.core >= 5.0.0
diff --git a/swh/loader/mercurial/tests/test_tasks.py b/swh/loader/mercurial/tests/test_tasks.py
--- a/swh/loader/mercurial/tests/test_tasks.py
+++ b/swh/loader/mercurial/tests/test_tasks.py
@@ -8,12 +8,8 @@
import pytest
from swh.scheduler.model import ListedOrigin, Lister
-from swh.scheduler.utils import create_origin_task_dict
-
-@pytest.fixture(autouse=True)
-def celery_worker_and_swh_config(swh_scheduler_celery_worker, swh_config):
- pass
+NAMESPACE = "swh.loader.mercurial"
@pytest.fixture
@@ -28,95 +24,41 @@
)
-def test_loader(
- mocker,
- swh_scheduler_celery_app,
-):
- mock_loader = mocker.patch("swh.loader.mercurial.loader.HgLoader.load")
- mock_loader.return_value = {"status": "eventful"}
-
- res = swh_scheduler_celery_app.send_task(
- "swh.loader.mercurial.tasks.LoadMercurial",
- kwargs={"url": "origin_url", "visit_date": "now"},
- )
-
- assert res
- res.wait()
- assert res.successful()
-
- assert res.result == {"status": "eventful"}
- mock_loader.assert_called_once_with()
-
-
-def test_loader_for_listed_origin(
- mocker,
- swh_scheduler_celery_app,
+@pytest.mark.parametrize("extra_loader_arguments", [{}, {"visit_date": "now"}])
+def test_mercurial_loader_for_listed_origin(
+ loading_task_creation_for_listed_origin_test,
hg_lister,
hg_listed_origin,
+ extra_loader_arguments,
):
- mock_loader = mocker.patch("swh.loader.mercurial.loader.HgLoader.load")
- mock_loader.return_value = {"status": "eventful"}
-
- task_dict = create_origin_task_dict(hg_listed_origin, hg_lister)
-
- res = swh_scheduler_celery_app.send_task(
- "swh.loader.mercurial.tasks.LoadMercurial",
- kwargs=task_dict["arguments"]["kwargs"],
- )
-
- assert res
- res.wait()
- assert res.successful()
-
- assert res.result == {"status": "eventful"}
- mock_loader.assert_called_once_with()
-
-
-def test_archive_loader(
- mocker,
- swh_scheduler_celery_app,
-):
- mock_loader = mocker.patch("swh.loader.mercurial.loader.HgArchiveLoader.load")
- mock_loader.return_value = {"status": "uneventful"}
+ hg_listed_origin.extra_loader_arguments = extra_loader_arguments
- res = swh_scheduler_celery_app.send_task(
- "swh.loader.mercurial.tasks.LoadArchiveMercurial",
- kwargs={
- "url": "another_url",
- "archive_path": "/some/tar.tgz",
- "visit_date": "now",
- },
+ loading_task_creation_for_listed_origin_test(
+ loader_class_name=f"{NAMESPACE}.loader.HgLoader",
+ task_function_name=f"{NAMESPACE}.tasks.LoadMercurial",
+ lister=hg_lister,
+ listed_origin=hg_listed_origin,
)
- assert res
- res.wait()
- assert res.successful()
-
- assert res.result == {"status": "uneventful"}
- mock_loader.assert_called_once_with()
-def test_archive_loader_for_listed_origin(
- mocker,
- swh_scheduler_celery_app,
+@pytest.mark.parametrize(
+ "extra_loader_arguments",
+ [
+ {"archive_path": "/some/tar.tgz"},
+ {"archive_path": "/some/tar.tgz", "visit_date": "now"},
+ ],
+)
+def test_mercurial_archive_loader_for_listed_origin(
+ loading_task_creation_for_listed_origin_test,
hg_lister,
hg_listed_origin,
+ extra_loader_arguments,
):
- mock_loader = mocker.patch("swh.loader.mercurial.loader.HgArchiveLoader.load")
- mock_loader.return_value = {"status": "uneventful"}
-
- hg_listed_origin.extra_loader_arguments = {
- "archive_path": "/some/tar.tgz",
- }
+ hg_listed_origin.extra_loader_arguments = extra_loader_arguments
- task_dict = create_origin_task_dict(hg_listed_origin, hg_lister)
-
- res = swh_scheduler_celery_app.send_task(
- "swh.loader.mercurial.tasks.LoadArchiveMercurial",
- kwargs=task_dict["arguments"]["kwargs"],
+ loading_task_creation_for_listed_origin_test(
+ loader_class_name=f"{NAMESPACE}.loader.HgArchiveLoader",
+ task_function_name=f"{NAMESPACE}.tasks.LoadArchiveMercurial",
+ lister=hg_lister,
+ listed_origin=hg_listed_origin,
)
- assert res
- res.wait()
- assert res.successful()
-
- assert res.result == {"status": "uneventful"}
- mock_loader.assert_called_once_with()
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 9:23 AM (15 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3217825
Attached To
D8702: tests: Simplify mercurial loading task creation tests implementation
Event Timeline
Log In to Comment