def test_dict_config_override(): dict_parser = parsers.Dict(val_parser=parsers.PriceFloat(decimals=4)) dict_parser.init_config({"ED_PRICE_DECIMALS": 3}) assert dict_parser.parse({"price": "123.4537"}) == {"price": 123.4537}
def test_price_float_config(config_name, config_value, test_data, result): price_parser = parsers.PriceFloat() price_parser.init_config({config_name: config_value}) assert price_parser.parse(test_data) == result
def test_price_float_decimals(decimals, test_data, result): price_parser = parsers.PriceFloat(decimals=decimals) assert price_parser.parse(test_data) == result
def test_price_float_max_value(max_value, test_data, result): price_parser = parsers.PriceFloat(max_value=max_value) assert price_parser.parse(test_data) == result
def test_price_float(test_data, result): price_parser = parsers.PriceFloat() assert price_parser.parse(test_data) == result