mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Merge pull request #1103 from bigchaindb/http-case-insensitive-parameters
Case insensitive "unspent" and "operation" parameters"
This commit is contained in:
commit
d55ed7adf4
@ -8,6 +8,7 @@ def valid_txid(txid):
|
|||||||
|
|
||||||
|
|
||||||
def valid_bool(val):
|
def valid_bool(val):
|
||||||
|
val = val.lower()
|
||||||
if val == 'true':
|
if val == 'true':
|
||||||
return True
|
return True
|
||||||
if val == 'false':
|
if val == 'false':
|
||||||
@ -23,6 +24,7 @@ def valid_ed25519(key):
|
|||||||
|
|
||||||
|
|
||||||
def valid_operation(op):
|
def valid_operation(op):
|
||||||
|
op = op.upper()
|
||||||
if op == 'CREATE':
|
if op == 'CREATE':
|
||||||
return 'CREATE'
|
return 'CREATE'
|
||||||
if op == 'TRANSFER':
|
if op == 'TRANSFER':
|
||||||
|
@ -24,11 +24,9 @@ def test_valid_bool():
|
|||||||
|
|
||||||
assert valid_bool('true') is True
|
assert valid_bool('true') is True
|
||||||
assert valid_bool('false') is False
|
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):
|
with pytest.raises(ValueError):
|
||||||
valid_bool('0')
|
valid_bool('0')
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
@ -64,13 +62,11 @@ def test_valid_ed25519():
|
|||||||
def test_valid_operation():
|
def test_valid_operation():
|
||||||
from bigchaindb.web.views.parameters import valid_operation
|
from bigchaindb.web.views.parameters import valid_operation
|
||||||
|
|
||||||
assert valid_operation('CREATE') == 'CREATE'
|
assert valid_operation('create') == 'CREATE'
|
||||||
assert valid_operation('TRANSFER') == 'TRANSFER'
|
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):
|
with pytest.raises(ValueError):
|
||||||
valid_operation('GENESIS')
|
valid_operation('GENESIS')
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user