Commit 418cca5d authored by David Trudgian's avatar David Trudgian
Browse files

Always stringify params, inc. Int Ranges

parent 83695f3d
......@@ -316,7 +316,7 @@ class IntRange(object):
vals.append(None)
while current <= max_val:
vals.append(current)
vals.append(str(current))
current = (current * scale) + step
return vals
......
......@@ -27,7 +27,7 @@ class TestParams:
# min: 0
# max: 32
# step: 2
assert md.vals['parameters'][0]['range'] == range(0, 32 + 1, 2)
assert md.vals['parameters'][0]['range'] == ['0', '2', '4', '6', '8', '10', '12', '14', '16', '18', '20', '22', '24', '26', '28', '30', '32']
# optional: true
# min: 0.1
# max: 100
......@@ -41,24 +41,24 @@ class TestParams:
def test_int_range_single(self):
ir = IntRange({'id': 'test', 'min': 0, 'max': 5})
assert ir.to_list() == [0, 1, 2, 3, 4, 5]
assert ir.to_list() == ['0', '1', '2', '3', '4', '5']
def test_int_range_step(self):
ir = IntRange({'id': 'test', 'min': 0, 'max': 10, 'step': 2})
assert ir.to_list() == [0, 2, 4, 6, 8, 10]
assert ir.to_list() == ['0', '2', '4', '6', '8', '10']
def test_int_range_scale(self):
ir = IntRange({'id': 'test', 'min': 1, 'max': 10000, 'scale': 10})
assert ir.to_list() == [1, 10, 100, 1000, 10000]
assert ir.to_list() == ['1', '10', '100', '1000', '10000']
def test_int_range_step_scale(self):
ir = IntRange(
{'id': 'test', 'min': 0, 'max': 10000, 'scale': 10, 'step': 9})
assert ir.to_list() == [0, 9, 99, 999, 9999]
assert ir.to_list() == ['0', '9', '99', '999', '9999']
def test_int_range_optional(self):
ir = IntRange({'id': 'test', 'min': 0, 'max': 5, 'optional': True})
assert ir.to_list() == [None, 0, 1, 2, 3, 4, 5]
assert ir.to_list() == [None, '0', '1', '2', '3', '4', '5']
def test_real_range_single(self):
rr = RealRange({'id': 'test', 'min': '0.1', 'max': '5.1'})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment