Skip to content

Commit

Permalink
Problem: Election type not casted for runnign command (#2551)
Browse files Browse the repository at this point in the history
Solution: Replace '-' with '_' before running election sub-command
  • Loading branch information
kansi authored and ttmc committed Sep 17, 2018
1 parent 528ba07 commit cf6fa6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion bigchaindb/commands/bigchaindb.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def run_election(args):


def run_election_new(args, bigchain):
globals()[f'run_election_new_{args.election_type}'](args, bigchain)
election_type = args.election_type.replace('-', '_')
globals()[f'run_election_new_{election_type}'](args, bigchain)


def create_new_election(sk, bigchain, election_class, data):
Expand Down
10 changes: 5 additions & 5 deletions tests/commands/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def test_election_new_upsert_validator_with_tendermint(b, priv_validator_path, u
from bigchaindb.commands.bigchaindb import run_election_new_upsert_validator

new_args = Namespace(action='new',
election_type='upsert_validator',
election_type='upsert-validator',
public_key='HHG0IQRybpT6nJMIWWFWhMczCLHt6xcm7eP52GnGuPY=',
power=1,
node_id='unique_node_id_for_test_upsert_validator_new_with_tendermint',
Expand All @@ -330,7 +330,7 @@ def mock_write(tx, mode):
b.write_transaction = mock_write

args = Namespace(action='new',
election_type='upsert_validator',
election_type='upsert-validator',
public_key='CJxdItf4lz2PwEf4SmYNAu/c/VpmX39JEgC5YpH7fxg=',
power=1,
node_id='fb7140f03a4ffad899fabbbf655b97e0321add66',
Expand Down Expand Up @@ -384,7 +384,7 @@ def test_election_new_upsert_validator_invalid_election(caplog, b, priv_validato
from bigchaindb.commands.bigchaindb import run_election_new_upsert_validator

args = Namespace(action='new',
election_type='upsert_validator',
election_type='upsert-validator',
public_key='CJxdItf4lz2PwEf4SmYNAu/c/VpmX39JEgC5YpH7fxg=',
power=10,
node_id='fb7140f03a4ffad899fabbbf655b97e0321add66',
Expand All @@ -408,7 +408,7 @@ def mock_write(tx, mode):
b.write_transaction = mock_write
b.get_validators = mock_get_validators
args = Namespace(action='new',
election_type='upsert_validator',
election_type='upsert-validator',
public_key='CJxdItf4lz2PwEf4SmYNAu/c/VpmX39JEgC5YpH7fxg=',
power=10,
node_id='fb7140f03a4ffad899fabbbf655b97e0321add66',
Expand All @@ -427,7 +427,7 @@ def test_election_approve_with_tendermint(b, priv_validator_path, user_sk, valid

public_key = 'CJxdItf4lz2PwEf4SmYNAu/c/VpmX39JEgC5YpH7fxg='
new_args = Namespace(action='new',
election_type='upsert_validator',
election_type='upsert-validator',
public_key=public_key,
power=1,
node_id='fb7140f03a4ffad899fabbbf655b97e0321add66',
Expand Down

0 comments on commit cf6fa6b

Please sign in to comment.