def test_simple_key_creation(params: HABApp.parameters.parameters): Parameter('file', 'key') assert params.get_parameter_file('file') == {'key': 'ToDo'} Parameter('file', 'key2') assert params.get_parameter_file('file') == {'key': 'ToDo', 'key2': 'ToDo'}
def test_structured_default_value(params: HABApp.parameters.parameters): Parameter('file', 'key1', 'key1', default_value=123) Parameter('file', 'key1', 'key2', default_value=[1, 2, 3]) assert params.get_parameter_file('file') == { 'key1': { 'key1': 123, 'key2': [1, 2, 3] } }
def test_structured_key_creation(params: HABApp.parameters.parameters): Parameter('file', 'key1', 'key1') Parameter('file', 'key1', 'key2') assert params.get_parameter_file('file') == { 'key1': { 'key1': 'ToDo', 'key2': 'ToDo' } }
def test_lookup(params: HABApp.parameters.parameters): data = {'key1': {'key2': 'value2'}} params.set_parameter_file('file1', data) p = Parameter('file1', 'key1', 'key2') assert p == 'value2' data['key1']['key2'] = 3 assert p == 3
def test_float_operators(params: HABApp.parameters.parameters): params.set_parameter_file('file', {'key': 5.5}) p = Parameter('file', 'key') assert p < 6 assert not p <= 5 assert p >= 5 assert p > 4
def test_arithmetic(params: HABApp.parameters.parameters): params.set_parameter_file('file', {'key': 1}) p = Parameter('file', 'key') assert int(p) == 1 assert p + 1 == 2 assert p - 1 == 0 assert p * 3 == 3 assert p / 2 == 0.5 assert p // 2 == 0 assert p << 1 == 2 assert p >> 1 == 0 assert p | 2 == 3 assert p & 2 == 0
def test_int_operators(params: HABApp.parameters.parameters): params.set_parameter_file('file', {'key': 5}) p = Parameter('file', 'key') assert p == 5 assert p != 6 assert p < 6 assert p <= 5 assert p >= 5 assert p > 4 params.set_parameter_file('file', {'key': 15}) assert not p < 6 assert not p <= 5 assert p >= 5 assert p > 4