def test_dict_conversion(): param_orig = Parameter(name='temperature') param_dict = param_orig.to_dict() param_dict['low'] = 0. param_dict['high'] = 273. param_conv = Parameter().from_dict(param_dict) assert param_conv.low == param_dict['low'] assert param_conv.high == param_dict['high'] assert param_conv.name == param_orig.name
def test_json_conversion(): param_orig = Parameter(name='temperature') param_json = param_orig.to_json() param_dict = json.loads(param_json) param_dict['low'] = 0. param_dict['high'] = 273. param_conv = Parameter().from_json(json.dumps(param_dict)) assert param_conv.low == param_dict['low'] assert param_conv.high == param_dict['high'] assert param_conv.name == param_orig.name
def test_abstract_parameter_dict_conversion(name, param_type, low, high): param_orig = Parameter(name = name, type = param_type, low = low, high = high) param_dict = param_orig.to_dict() param_conv = Parameter().from_dict(param_dict) for attr in ['name', 'type', 'low', 'high']: assert param_conv.get(attr) == param_orig.get(attr)
def test_abstract_parameter(name, paramtype, low, high): param = Parameter(name=name, type=paramtype, low=low, high=high) for attr, value in {'name': name, 'type': paramtype, 'low': low, 'high': high}.items(): assert param[attr] == value
def test_abstract_parameter_defaults(): param = Parameter() for attr, value in {'name': 'parameter', 'type': 'continuous', 'low': 0.0, 'high': 1.0}.items(): assert param[attr] == value
def test_update(): param = Parameter(name='temperature') param.update('name', 'pressure') assert param.name == 'pressure'
def test_set_get_methods_generation(): param = Parameter(name='temperature') param.set_name('pressure') assert param.get_name() == 'pressure'
def test_contains(): param = Parameter() assert 'name' in param