示例#1
0
def check_fails_with_message(file_name, keywords):
    path = os.path.join(BASE_DIR, file_name) + '.yaml'
    try:
        load_parameter_file(path, file_name)
    except ParameterParsingError as e:
        content = str(e)
        for keyword in keywords:
            assert keyword in content
        raise
示例#2
0
def check(file_name, keywords):
    path = os.path.join(BASE_DIR, file_name) + '.yaml'
    try:
        load_parameter_file(path, file_name)
    except ParameterParsingError as e:
        content = str(e)
        for keyword in keywords:
            assert_in(keyword, content)
        raise
示例#3
0
def test_parameter_repr(tax_benefit_system):
    parameters = tax_benefit_system.parameters
    tf = tempfile.NamedTemporaryFile(delete=False)
    tf.write(repr(parameters).encode('utf-8'))
    tf.close()
    tf_parameters = load_parameter_file(file_path=tf.name)
    assert repr(parameters) == repr(tf_parameters)
def test_parameter_repr():
    parameters = tax_benefit_system.parameters
    tf = tempfile.NamedTemporaryFile(delete = False)
    tf.write(repr(parameters).encode('utf-8'))
    tf.close()
    tf_parameters = load_parameter_file(file_path = tf.name)
    assert repr(parameters) == repr(tf_parameters)
示例#5
0
def test_build_api_values_history():
    file_path = os.path.join(dir_path, 'test_helpers.yaml')
    parameter = load_parameter_file(name='dummy_name', file_path=file_path)

    values = {
        '2017-01-01': 0.02,
        '2015-01-01': 0.04,
        '2013-01-01': 0.03,
        }
    assert parameters.build_api_values_history(parameter) == values
示例#6
0
def test_transform_values_history():
    file_path = os.path.join(dir_path, 'test_helpers.yaml')
    parameter = load_parameter_file(name='dummy_name', file_path=file_path)

    values = {
        '2017-01-01': 0.02,
        '2015-01-01': 0.04,
        '2013-01-01': 0.03,
    }
    assert_equal(transform_values_history(parameter), values)
示例#7
0
def test_build_api_values_history():
    file_path = os.path.join(dir_path, 'test_helpers.yaml')
    parameter = load_parameter_file(name='dummy_name', file_path=file_path)

    values = {
        '2017-01-01': 0.02,
        '2015-01-01': 0.04,
        '2013-01-01': 0.03,
        }
    assert build_api_values_history(parameter) == values
def test_build_api_values_history_with_stop_date():
    file_path = os.path.join(dir_path, 'test_helpers_with_stop_date.yaml')
    parameter = load_parameter_file(name='dummy_name', file_path=file_path)

    values = {
        '2018-01-01': None,
        '2017-01-01': 0.02,
        '2015-01-01': 0.04,
        '2013-01-01': 0.03,
    }

    assert_equal(build_api_values_history(parameter), values)
示例#9
0
def test_array_type():
    path = os.path.join(BASE_DIR, 'array_type.yaml')
    load_parameter_file(path, 'array_type')
示例#10
0
 def modify_parameters(parameters: ParameterNode):
     file_path = Path(__file__).parent / "reform_parameters.yaml"
     reform_parameters_subtree = load_parameter_file(file_path)
     parameters.add_child("reforms", reform_parameters_subtree.reforms)
     return parameters