Page MenuHomeSoftware Heritage

D8699.id31422.diff
No OneTemporary

D8699.id31422.diff

diff --git a/requirements-swh.txt b/requirements-swh.txt
--- a/requirements-swh.txt
+++ b/requirements-swh.txt
@@ -1,4 +1,4 @@
swh.storage >= 0.11.3
swh.model >= 6.6.0
swh.scheduler >= 0.0.39
-swh.loader.core >= 3.0.0
+swh.loader.core >= 5.0.0
diff --git a/swh/loader/svn/tests/test_task.py b/swh/loader/svn/tests/test_task.py
--- a/swh/loader/svn/tests/test_task.py
+++ b/swh/loader/svn/tests/test_task.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.svn"
@pytest.fixture
@@ -28,129 +24,55 @@
)
-@pytest.fixture
-def task_dict(svn_lister, svn_listed_origin):
- return create_origin_task_dict(svn_listed_origin, svn_lister)
-
-
-def test_svn_loader(
- mocker,
- swh_scheduler_celery_app,
-):
- mock_loader = mocker.patch("swh.loader.svn.loader.SvnLoader.load")
- mock_loader.return_value = {"status": "eventful"}
-
- res = swh_scheduler_celery_app.send_task(
- "swh.loader.svn.tasks.LoadSvnRepository",
- kwargs=dict(
- url="some-technical-url", origin_url="origin-url", visit_date="now"
- ),
- )
- assert res
- res.wait()
- assert res.successful()
-
- assert res.result == {"status": "eventful"}
-
-
+@pytest.mark.parametrize("extra_loader_arguments", [{}, {"visit_date": "now"}])
def test_svn_loader_for_listed_origin(
- mocker,
- swh_scheduler_celery_app,
- task_dict,
-):
- mock_loader = mocker.patch("swh.loader.svn.loader.SvnLoader.load")
- mock_loader.return_value = {"status": "eventful"}
-
- res = swh_scheduler_celery_app.send_task(
- "swh.loader.svn.tasks.LoadSvnRepository",
- args=task_dict["arguments"]["args"],
- kwargs=task_dict["arguments"]["kwargs"],
- )
- assert res
- res.wait()
- assert res.successful()
-
- assert res.result == {"status": "eventful"}
-
-
-def test_svn_loader_from_dump(
- mocker,
- swh_scheduler_celery_app,
+ loading_task_creation_for_listed_origin_test,
+ svn_lister,
+ svn_listed_origin,
+ extra_loader_arguments,
):
- mock_loader = mocker.patch("swh.loader.svn.loader.SvnLoaderFromDumpArchive.load")
- mock_loader.return_value = {"status": "eventful"}
+ svn_listed_origin.extra_loader_arguments = extra_loader_arguments
- res = swh_scheduler_celery_app.send_task(
- "swh.loader.svn.tasks.MountAndLoadSvnRepository",
- kwargs=dict(url="some-url", archive_path="some-path", visit_date="now"),
+ loading_task_creation_for_listed_origin_test(
+ loader_class_name=f"{NAMESPACE}.loader.SvnLoader",
+ task_function_name=f"{NAMESPACE}.tasks.LoadSvnRepository",
+ lister=svn_lister,
+ listed_origin=svn_listed_origin,
)
- assert res
- res.wait()
- assert res.successful()
-
- assert res.result == {"status": "eventful"}
+@pytest.mark.parametrize(
+ "extra_loader_arguments",
+ [{"archive_path": "some-path"}, {"archive_path": "some-path", "visit_date": "now"}],
+)
def test_svn_loader_from_dump_for_listed_origin(
- mocker,
- swh_scheduler_celery_app,
+ loading_task_creation_for_listed_origin_test,
svn_lister,
svn_listed_origin,
+ extra_loader_arguments,
):
- mock_loader = mocker.patch("swh.loader.svn.loader.SvnLoaderFromDumpArchive.load")
- mock_loader.return_value = {"status": "eventful"}
-
- svn_listed_origin.extra_loader_arguments = {"archive_path": "some-path"}
-
- task_dict = create_origin_task_dict(svn_listed_origin, svn_lister)
-
- res = swh_scheduler_celery_app.send_task(
- "swh.loader.svn.tasks.MountAndLoadSvnRepository",
- args=task_dict["arguments"]["args"],
- kwargs=task_dict["arguments"]["kwargs"],
- )
- assert res
- res.wait()
- assert res.successful()
+ svn_listed_origin.extra_loader_arguments = extra_loader_arguments
- assert res.result == {"status": "eventful"}
-
-
-def test_svn_loader_from_remote_dump(
- mocker,
- swh_scheduler_celery_app,
-):
- mock_loader = mocker.patch("swh.loader.svn.loader.SvnLoaderFromRemoteDump.load")
- mock_loader.return_value = {"status": "eventful"}
-
- res = swh_scheduler_celery_app.send_task(
- "swh.loader.svn.tasks.DumpMountAndLoadSvnRepository",
- kwargs=dict(
- url="some-remote-dump-url", origin_url="origin-url", visit_date="now"
- ),
+ loading_task_creation_for_listed_origin_test(
+ loader_class_name=f"{NAMESPACE}.loader.SvnLoaderFromDumpArchive",
+ task_function_name=f"{NAMESPACE}.tasks.MountAndLoadSvnRepository",
+ lister=svn_lister,
+ listed_origin=svn_listed_origin,
)
- assert res
- res.wait()
- assert res.successful()
-
- assert res.result == {"status": "eventful"}
+@pytest.mark.parametrize("extra_loader_arguments", [{}, {"visit_date": "now"}])
def test_svn_loader_from_remote_dump_for_listed_origin(
- mocker,
- swh_scheduler_celery_app,
- task_dict,
+ loading_task_creation_for_listed_origin_test,
+ svn_lister,
+ svn_listed_origin,
+ extra_loader_arguments,
):
- mock_loader = mocker.patch("swh.loader.svn.loader.SvnLoaderFromRemoteDump.load")
- mock_loader.return_value = {"status": "eventful"}
+ svn_listed_origin.extra_loader_arguments = extra_loader_arguments
- res = swh_scheduler_celery_app.send_task(
- "swh.loader.svn.tasks.DumpMountAndLoadSvnRepository",
- args=task_dict["arguments"]["args"],
- kwargs=task_dict["arguments"]["kwargs"],
+ loading_task_creation_for_listed_origin_test(
+ loader_class_name=f"{NAMESPACE}.loader.SvnLoaderFromRemoteDump",
+ task_function_name=f"{NAMESPACE}.tasks.DumpMountAndLoadSvnRepository",
+ lister=svn_lister,
+ listed_origin=svn_listed_origin,
)
- assert res
- res.wait()
- assert res.successful()
-
- assert res.result == {"status": "eventful"}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 9:26 AM (12 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3219783

Event Timeline