Skip to content

Commit

Permalink
fix: remove alias arg instead of opt
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Dec 21, 2023
1 parent 368a400 commit b99c065
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 43 deletions.
1 change: 1 addition & 0 deletions ape_safe/_cli/click_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def _safe_callback(ctx, param, value):


safe_option = click.option("--safe", callback=_safe_callback)
safe_argument = click.argument("safe", callback=_safe_callback)


def _txn_ids_callback(ctx, param, value):
Expand Down
4 changes: 2 additions & 2 deletions ape_safe/_cli/safe_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ape.types import AddressType
from eth_typing import ChecksumAddress

from ape_safe._cli.click_ext import SafeCliContext, safe_cli_ctx, safe_option
from ape_safe._cli.click_ext import SafeCliContext, safe_argument, safe_cli_ctx
from ape_safe.client import ExecutedTxData


Expand Down Expand Up @@ -84,7 +84,7 @@ def add(cli_ctx: SafeCliContext, ecosystem, network, address, alias):

@click.command()
@safe_cli_ctx()
@safe_option
@safe_argument
def remove(cli_ctx: SafeCliContext, safe):
"""
Stop tracking a locally-tracked Safe
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added tests/integration/__init__.py
Empty file.
28 changes: 28 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import shutil

import pytest
from click.testing import CliRunner

from ape_safe._cli import cli as CLI


@pytest.fixture
def runner():
return CliRunner()


@pytest.fixture
def cli():
return CLI


@pytest.fixture
def no_safes(data_folder):
shutil.rmtree(data_folder, ignore_errors=True)


@pytest.fixture
def one_safe(data_folder, safes, safe):
shutil.rmtree(data_folder)
safes.save_account(safe.alias, safe.address)
return safes.load_account(safe.alias)
3 changes: 3 additions & 0 deletions tests/integration/test_pending_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_help(runner, cli):
result = runner.invoke(cli, ["--help"], catch_exceptions=False)
assert result.exit_code == 0, result.output
25 changes: 25 additions & 0 deletions tests/integration/test_safe_mgmt_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def test_list_no_safes(runner, cli, no_safes):
result = runner.invoke(cli, ["list"], catch_exceptions=False)
assert result.exit_code == 0, result.output
assert "No Safes found" in result.output


def test_list_one_safe(runner, cli, one_safe):
result = runner.invoke(cli, ["list"], catch_exceptions=False)
assert result.exit_code == 0, result.output
assert "Found 1 Safe" in result.output
assert "0x5FbDB2315678afecb367f032d93F642f64180aa3" in result.output


def test_add_safe(runner, cli, no_safes, safe):
result = runner.invoke(
cli, ["add", safe.address, safe.alias], catch_exceptions=False, input="y\n"
)
assert result.exit_code == 0, result.output
assert "SUCCESS" in result.output, result.output


def test_remove_safe(runner, cli, one_safe, safe):
result = runner.invoke(cli, ["remove", safe.alias], catch_exceptions=False, input="y\n")
assert result.exit_code == 0, result.output
assert "SUCCESS" in result.output, result.output
41 changes: 0 additions & 41 deletions tests/test_cli.py

This file was deleted.

0 comments on commit b99c065

Please sign in to comment.