diff --git a/conftest.py b/conftest.py --- a/conftest.py +++ b/conftest.py @@ -72,5 +72,5 @@ 'swh.loader.package.deposit.tasks', 'swh.loader.package.npm.tasks', 'swh.loader.package.pypi.tasks', - 'swh.loader.package.functional.tasks', + 'swh.loader.package.nixguix.tasks', ] diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -56,7 +56,7 @@ loader.cran=swh.loader.package.cran:register loader.debian=swh.loader.package.debian:register loader.deposit=swh.loader.package.deposit:register - loader.functional=swh.loader.package.functional:register + loader.nixguix=swh.loader.package.nixguix:register loader.npm=swh.loader.package.npm:register loader.pypi=swh.loader.package.pypi:register [swh.cli.subcommands] diff --git a/swh/loader/package/functional/__init__.py b/swh/loader/package/nixguix/__init__.py rename from swh/loader/package/functional/__init__.py rename to swh/loader/package/nixguix/__init__.py --- a/swh/loader/package/functional/__init__.py +++ b/swh/loader/package/nixguix/__init__.py @@ -9,8 +9,8 @@ def register() -> Mapping[str, Any]: """Register the current worker module's definition""" - from .loader import FunctionalLoader + from .loader import NixGuixLoader return { 'task_modules': [f'{__name__}.tasks'], - 'loader': FunctionalLoader, + 'loader': NixGuixLoader, } diff --git a/swh/loader/package/functional/loader.py b/swh/loader/package/nixguix/loader.py rename from swh/loader/package/functional/loader.py rename to swh/loader/package/nixguix/loader.py --- a/swh/loader/package/functional/loader.py +++ b/swh/loader/package/nixguix/loader.py @@ -29,12 +29,12 @@ return json.loads(response.content.decode('utf-8')) -class FunctionalLoader(PackageLoader): +class NixGuixLoader(PackageLoader): """Load sources from a sources.json file. This loader is used to load sources used by functional package manager (eg. Nix and Guix). """ - visit_type = 'functional' + visit_type = 'nixguix' def __init__(self, url): super().__init__(url=url) diff --git a/swh/loader/package/functional/tasks.py b/swh/loader/package/nixguix/tasks.py rename from swh/loader/package/functional/tasks.py rename to swh/loader/package/nixguix/tasks.py --- a/swh/loader/package/functional/tasks.py +++ b/swh/loader/package/nixguix/tasks.py @@ -5,12 +5,12 @@ from celery import shared_task -from swh.loader.package.functional.loader import ( - FunctionalLoader +from swh.loader.package.nixguix.loader import ( + NixGuixLoader ) -@shared_task(name=__name__ + '.LoadFunctional') -def load_functional(*, url=None): +@shared_task(name=__name__ + '.LoadNixguix') +def load_nixguix(*, url=None): """Load functional (e.g. guix/nix) package""" - return FunctionalLoader(url).load() + return NixGuixLoader(url).load() diff --git a/swh/loader/package/functional/tests/data/https_example.com/file.txt b/swh/loader/package/nixguix/tests/data/https_example.com/file.txt rename from swh/loader/package/functional/tests/data/https_example.com/file.txt rename to swh/loader/package/nixguix/tests/data/https_example.com/file.txt diff --git a/swh/loader/package/functional/tests/data/https_fail.com/truncated-archive.tgz b/swh/loader/package/nixguix/tests/data/https_fail.com/truncated-archive.tgz rename from swh/loader/package/functional/tests/data/https_fail.com/truncated-archive.tgz rename to swh/loader/package/nixguix/tests/data/https_fail.com/truncated-archive.tgz diff --git a/swh/loader/package/functional/tests/data/https_github.com/owner-1_repository-1_revision-1.tgz b/swh/loader/package/nixguix/tests/data/https_github.com/owner-1_repository-1_revision-1.tgz rename from swh/loader/package/functional/tests/data/https_github.com/owner-1_repository-1_revision-1.tgz rename to swh/loader/package/nixguix/tests/data/https_github.com/owner-1_repository-1_revision-1.tgz diff --git a/swh/loader/package/functional/tests/data/https_github.com/owner-2_repository-1_revision-1.tgz b/swh/loader/package/nixguix/tests/data/https_github.com/owner-2_repository-1_revision-1.tgz rename from swh/loader/package/functional/tests/data/https_github.com/owner-2_repository-1_revision-1.tgz rename to swh/loader/package/nixguix/tests/data/https_github.com/owner-2_repository-1_revision-1.tgz diff --git a/swh/loader/package/functional/tests/data/https_nix-community.github.io/nixpkgs-swh_sources-EOFError.json b/swh/loader/package/nixguix/tests/data/https_nix-community.github.io/nixpkgs-swh_sources-EOFError.json rename from swh/loader/package/functional/tests/data/https_nix-community.github.io/nixpkgs-swh_sources-EOFError.json rename to swh/loader/package/nixguix/tests/data/https_nix-community.github.io/nixpkgs-swh_sources-EOFError.json diff --git a/swh/loader/package/functional/tests/data/https_nix-community.github.io/nixpkgs-swh_sources.json b/swh/loader/package/nixguix/tests/data/https_nix-community.github.io/nixpkgs-swh_sources.json rename from swh/loader/package/functional/tests/data/https_nix-community.github.io/nixpkgs-swh_sources.json rename to swh/loader/package/nixguix/tests/data/https_nix-community.github.io/nixpkgs-swh_sources.json diff --git a/swh/loader/package/functional/tests/data/https_nix-community.github.io/nixpkgs-swh_sources.json_visit1 b/swh/loader/package/nixguix/tests/data/https_nix-community.github.io/nixpkgs-swh_sources.json_visit1 rename from swh/loader/package/functional/tests/data/https_nix-community.github.io/nixpkgs-swh_sources.json_visit1 rename to swh/loader/package/nixguix/tests/data/https_nix-community.github.io/nixpkgs-swh_sources.json_visit1 diff --git a/swh/loader/package/functional/tests/test_functional.py b/swh/loader/package/nixguix/tests/test_functional.py rename from swh/loader/package/functional/tests/test_functional.py rename to swh/loader/package/nixguix/tests/test_functional.py --- a/swh/loader/package/functional/tests/test_functional.py +++ b/swh/loader/package/nixguix/tests/test_functional.py @@ -6,8 +6,8 @@ import pytest from json.decoder import JSONDecodeError -from swh.loader.package.functional.loader import ( - FunctionalLoader, retrieve_sources +from swh.loader.package.nixguix.loader import ( + NixGuixLoader, retrieve_sources ) from swh.loader.package.tests.common import ( @@ -25,16 +25,16 @@ def test_retrieve_non_existing(swh_config, requests_mock_datadir): with pytest.raises(ValueError): - FunctionalLoader('https://non-existing-url') + NixGuixLoader('https://non-existing-url') def test_retrieve_non_json(swh_config, requests_mock_datadir): with pytest.raises(JSONDecodeError): - FunctionalLoader('https://example.com/file.txt') + NixGuixLoader('https://example.com/file.txt') def test_loader_one_visit(swh_config, requests_mock_datadir): - loader = FunctionalLoader(sources_url) + loader = NixGuixLoader(sources_url) res = loader.load() assert res['status'] == 'eventful' @@ -55,7 +55,7 @@ # The visit is partial because urls pointing to non tarball file # are not handled yet assert origin_visit['status'] == 'partial' - assert origin_visit['type'] == 'functional' + assert origin_visit['type'] == 'nixguix' def test_uncompress_failure(swh_config, requests_mock_datadir): @@ -67,7 +67,7 @@ created (with a status partial since all files are not archived). """ - loader = FunctionalLoader(sources_url) + loader = NixGuixLoader(sources_url) loader_status = loader.load() urls = [s['url'][0] for s in loader.sources] @@ -85,10 +85,10 @@ downloaded by the previous visit. """ - loader = FunctionalLoader(sources_url) + loader = NixGuixLoader(sources_url) load_status = loader.load() - loader = FunctionalLoader(sources_url) + loader = NixGuixLoader(sources_url) loader.load() expected_snapshot_id = '0c5881c74283793ebe9a09a105a9381e41380383' assert load_status == { @@ -130,7 +130,7 @@ another tarball. """ - loader = FunctionalLoader(sources_url) + loader = NixGuixLoader(sources_url) load_status = loader.load() expected_snapshot_id = '0c5881c74283793ebe9a09a105a9381e41380383' assert load_status == { @@ -168,7 +168,7 @@ 'snapshot': 1 } == stats - loader = FunctionalLoader(sources_url) + loader = NixGuixLoader(sources_url) load_status = loader.load() expected_snapshot_id = 'b0bfa75cbd0cc90aac3b9e95fb0f59c731176d97' assert load_status == { @@ -215,7 +215,7 @@ def test_resolve_revision_from(swh_config, requests_mock_datadir): - loader = FunctionalLoader(sources_url) + loader = NixGuixLoader(sources_url) known_artifacts = { 'id1': {'extrinsic': {'raw': {'url': "url1"}}}, @@ -229,7 +229,7 @@ def test_evaluation_branch(swh_config, requests_mock_datadir): - loader = FunctionalLoader(sources_url) + loader = NixGuixLoader(sources_url) res = loader.load() assert res['status'] == 'eventful' @@ -259,7 +259,7 @@ """ sources = "https://nix-community.github.io/nixpkgs-swh/sources-EOFError.json" # noqa - loader = FunctionalLoader(sources) + loader = NixGuixLoader(sources) loader.load() expected_branches = { diff --git a/swh/loader/package/functional/tests/test_tasks.py b/swh/loader/package/nixguix/tests/test_tasks.py rename from swh/loader/package/functional/tests/test_tasks.py rename to swh/loader/package/nixguix/tests/test_tasks.py --- a/swh/loader/package/functional/tests/test_tasks.py +++ b/swh/loader/package/nixguix/tests/test_tasks.py @@ -4,20 +4,20 @@ # See top-level LICENSE file for more information -def test_functional_loader(mocker, swh_app, celery_session_worker, swh_config): +def test_nixguix_loader(mocker, swh_app, celery_session_worker, swh_config): mock_loader = mocker.patch( - 'swh.loader.package.functional.loader.FunctionalLoader.load') + 'swh.loader.package.nixguix.loader.NixGuixLoader.load') mock_loader.return_value = {'status': 'eventful'} mock_retrieve_sources = mocker.patch( - 'swh.loader.package.functional.loader.retrieve_sources') + 'swh.loader.package.nixguix.loader.retrieve_sources') mock_retrieve_sources.return_value = { 'sources': [], 'revision': 'some-revision' } res = swh_app.send_task( - 'swh.loader.package.functional.tasks.LoadFunctional', + 'swh.loader.package.nixguix.tasks.LoadNixguix', kwargs=dict(url='some-url')) assert res res.wait() diff --git a/swh/loader/tests/test_cli.py b/swh/loader/tests/test_cli.py --- a/swh/loader/tests/test_cli.py +++ b/swh/loader/tests/test_cli.py @@ -60,7 +60,7 @@ result = runner.invoke(run, ['-h']) assert result.exit_code == 0 - expected_help_msg = """Usage: run [OPTIONS] [archive|cran|debian|deposit|functional|npm|pypi] URL + expected_help_msg = """Usage: run [OPTIONS] [archive|cran|debian|deposit|nixguix|npm|pypi] URL [OPTIONS]... Ingest with loader the origin located at @@ -90,7 +90,7 @@ runner = CliRunner() result = runner.invoke(list, ['--help']) assert result.exit_code == 0 - expected_help_msg = """Usage: list [OPTIONS] [[all|archive|cran|debian|deposit|functional|npm|pypi]] + expected_help_msg = """Usage: list [OPTIONS] [[all|archive|cran|debian|deposit|nixguix|npm|pypi]] List supported loaders and optionally their arguments