Case insensitive "unspent" and "operation" parameters"

This commit is contained in:
Scott Sadler
2017-01-26 13:59:52 +01:00
parent 05fdcef670
commit 1243322aad
2 changed files with 8 additions and 10 deletions

View File

@@ -8,6 +8,7 @@ def valid_txid(txid):
def valid_bool(val):
val = val.lower()
if val == 'true':
return True
if val == 'false':
@@ -23,6 +24,7 @@ def valid_ed25519(key):
def valid_operation(op):
op = op.upper()
if op == 'CREATE':
return 'CREATE'
if op == 'TRANSFER':

View File

@@ -24,11 +24,9 @@ def test_valid_bool():
assert valid_bool('true') is True
assert valid_bool('false') is False
assert valid_bool('tRUE') is True
assert valid_bool('fALSE') is False
with pytest.raises(ValueError):
valid_bool('TRUE')
with pytest.raises(ValueError):
valid_bool('FALSE')
with pytest.raises(ValueError):
valid_bool('0')
with pytest.raises(ValueError):
@@ -64,13 +62,11 @@ def test_valid_ed25519():
def test_valid_operation():
from bigchaindb.web.views.parameters import valid_operation
assert valid_operation('CREATE') == 'CREATE'
assert valid_operation('TRANSFER') == 'TRANSFER'
assert valid_operation('create') == 'CREATE'
assert valid_operation('transfer') == 'TRANSFER'
assert valid_operation('CREATe') == 'CREATE'
assert valid_operation('TRANSFEr') == 'TRANSFER'
with pytest.raises(ValueError):
valid_operation('create')
with pytest.raises(ValueError):
valid_operation('transfer')
with pytest.raises(ValueError):
valid_operation('GENESIS')
with pytest.raises(ValueError):