Skip to content

Commit

Permalink
Use immutibility pattern for release_cmd and add test for ipfs pin
Browse files Browse the repository at this point in the history
  • Loading branch information
corydickson committed Feb 13, 2020
1 parent e105e06 commit c176265
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ethpm_cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}."
)

Expand Down
13 changes: 13 additions & 0 deletions tests/core/_utils/test_ipfs.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit c176265

Please sign in to comment.