From c1762658681abc294513d52034fc15b591684010 Mon Sep 17 00:00:00 2001 From: cd10012 Date: Wed, 12 Feb 2020 18:17:56 -0700 Subject: [PATCH] Use immutibility pattern for release_cmd and add test for ipfs pin --- ethpm_cli/parser.py | 17 ++++++++++------- tests/core/_utils/test_ipfs.py | 13 +++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 tests/core/_utils/test_ipfs.py diff --git a/ethpm_cli/parser.py b/ethpm_cli/parser.py index fb33fda..03a20ea 100644 --- a/ethpm_cli/parser.py +++ b/ethpm_cli/parser.py @@ -150,11 +150,6 @@ def add_package_name_and_package_version_to_parser( def release_cmd(args: argparse.Namespace) -> None: config = Config(args) - manifest_uri = args.manifest_uri - - package_name = args.package_name - package_version = args.package_version - if args.manifest_path: (package_name, package_version, manifest_uri) = pin_local_manifest( args.manifest_path @@ -163,10 +158,18 @@ def release_cmd(args: argparse.Namespace) -> None: f"Retrieving manifest info from local file @ {args.manifest_path} " ) - release_package(package_name, package_version, manifest_uri, config) + release_package(package_name, package_version, manifest_uri, config) + cli_logger.info( + f"{package_name} v{package_version} @ {manifest_uri} " + ) + else: + release_package(args.package_name, args.package_version, args.manifest_uri, config) + cli_logger.info( + f"{args.package_name} v{args.package_version} @ {args.manifest_uri} " + ) + active_registry = get_active_registry(config.xdg_ethpmcli_root / REGISTRY_STORE) cli_logger.info( - f"{package_name} v{package_version} @ {manifest_uri} " f"released to registry @ {active_registry.uri}." ) diff --git a/tests/core/_utils/test_ipfs.py b/tests/core/_utils/test_ipfs.py new file mode 100644 index 0000000..d4f018c --- /dev/null +++ b/tests/core/_utils/test_ipfs.py @@ -0,0 +1,13 @@ +import json +from ethpm_cli._utils.ipfs import pin_local_manifest + + +def test_pin_local_manifest(test_assets_dir): + local_manifest_path = test_assets_dir / "owned" / "1.0.0.json" + expected_manifest = json.loads( + local_manifest_path.read_text() + ) + (package_name, package_version, manifest_uri) = pin_local_manifest(local_manifest_path) + assert package_name == expected_manifest["package_name"] + assert package_version == expected_manifest["version"] + assert manifest_uri == "ipfs://QmbeVyFLSuEUxiXKwSsEjef6icpdTdA4kGG9BcrJXKNKUW"