Skip to content

Commit

Permalink
Fix missing data-dir mock
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-stakewise committed Oct 10, 2023
1 parent 7b42439 commit 3854dc2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/commands/tests/test_create_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def test_basic(
str(vault_address),
'--data-dir',
str(data_dir),
'--pool-size',
'2',
]
result = runner.invoke(create_keys, args)
assert result.exit_code == 0
Expand Down Expand Up @@ -76,6 +78,8 @@ def test_per_keystore_password(
str(vault_address),
'--data-dir',
str(data_dir),
'--pool-size',
'2',
'--per-keystore-password',
]
result = runner.invoke(create_keys, args)
Expand Down
44 changes: 36 additions & 8 deletions src/commands/tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,62 @@

@patch('src.common.language.get_mnemonic', return_value=mnemonic)
class TestCreateMnemonic:
def test_basic(self, mnemonic_mock, runner: CliRunner):
def test_basic(self, mnemonic_mock, data_dir, runner: CliRunner):
vault = faker.eth_address()
args = ['--language', 'english', '--vault', vault, '--network', 'goerli']
args = [
'--data-dir',
str(data_dir),
'--language',
'english',
'--vault',
vault,
'--network',
'goerli',
]
result = runner.invoke(init, args, input=f'\n{mnemonic}\n')
assert result.exit_code == 0
mnemonic_mock.assert_called_once()
assert mnemonic in result.output.strip()
assert 'Successfully initialized configuration' in result.output.strip()

def test_bad_verify(self, mnemonic_mock, runner: CliRunner):
def test_bad_verify(self, mnemonic_mock, data_dir, runner: CliRunner):
vault = faker.eth_address()
args = ['--language', 'english', '--vault', vault, '--network', 'goerli']
args = [
'--data-dir',
str(data_dir),
'--language',
'english',
'--vault',
vault,
'--network',
'goerli',
]
result = runner.invoke(init, args, input=f'\n{mnemonic} bad\n\n{mnemonic}\n')
assert result.exit_code == 0
mnemonic_mock.assert_called_once()
assert mnemonic in result.output.strip()
assert 'Successfully initialized configuration' in result.output.strip()

def test_no_verify(self, mnemonic_mock, runner: CliRunner):
def test_no_verify(self, mnemonic_mock, data_dir, runner: CliRunner):
vault = faker.eth_address()
args = ['--language', 'english', '--no-verify', '--vault', vault, '--network', 'goerli']
args = [
'--data-dir',
str(data_dir),
'--language',
'english',
'--no-verify',
'--vault',
vault,
'--network',
'goerli',
]
result = runner.invoke(init, args)
assert result.exit_code == 0
mnemonic_mock.assert_called_once()
assert mnemonic == result.output.strip()

def test_bad_language(self, _, runner: CliRunner):
args = ['--language', 'bad', '--no-verify']
def test_bad_language(self, data_dir, runner: CliRunner):
args = ['--data-dir', str(data_dir), '--language', 'bad', '--no-verify']
result = runner.invoke(init, args)
assert result.exit_code == 2
assert "Invalid value for '--language': 'bad' is not one of" in result.output.strip()

0 comments on commit 3854dc2

Please sign in to comment.