示例#1
0
def test_add_registry(config, test_assets_dir):
    expected_registry_store = json.loads(
        (test_assets_dir / "registry_store" / "init.json").read_text())
    add_registry(URI_1, "mine", config)
    actual_registry_store = json.loads(
        (config.xdg_ethpmcli_root / REGISTRY_STORE).read_text())
    assert actual_registry_store == expected_registry_store
示例#2
0
def test_activate_aliased_registry(test_assets_dir, config):
    add_registry(URI_1, "mine", config)
    add_registry(URI_2, "other", config)
    activate_registry("other", config)
    store_data = json.loads(
        (config.xdg_ethpmcli_root / REGISTRY_STORE).read_text())
    assert store_data[URI_2]["active"] is True
    assert store_data[URI_1]["active"] is False
示例#3
0
def test_remove_aliased_registry(test_assets_dir, config):
    add_registry(URI_1, "mine", config)
    add_registry(URI_2, "other", config)
    remove_registry("other", config)
    expected_registry_store = json.loads(
        (test_assets_dir / "registry_store" / "init.json").read_text())
    actual_registry_store = json.loads(
        (config.xdg_ethpmcli_root / REGISTRY_STORE).read_text())
    assert actual_registry_store == expected_registry_store
示例#4
0
def registry_add_cmd(args: argparse.Namespace) -> None:
    config = Config(args)
    add_registry(args.uri, args.alias, config)
    if args.alias:
        log_msg = (
            f"Registry @ {args.uri} (alias: {args.alias}) added to registry store."
        )
    else:
        log_msg = f"Registry @ {args.uri} added to registry store."
    cli_logger.info(log_msg)
示例#5
0
def test_remove_active_registry_raises_error(config):
    add_registry(URI_1, "mine", config)
    with pytest.raises(InstallError):
        remove_registry(URI_2, config)
示例#6
0
def test_remove_nonexisting_aliased_registry_raises_exception(config):
    add_registry(URI_1, "mine", config)
    with pytest.raises(InstallError):
        remove_registry("other", config)
示例#7
0
def test_adding_an_existing_registry_raises_exception(config):
    add_registry(URI_1, "mine", config)
    with pytest.raises(InstallError, match="already stored."):
        add_registry(URI_1, "mine", config)
示例#8
0
def test_unable_to_activate_nonexistent_aliased_registry(config):
    add_registry(URI_1, "mine", config)
    with pytest.raises(InstallError):
        activate_registry("other", config)