Exemplo n.º 1
0
def test_simulation(tax_benefit_system):
    input_yaml = """
        salary:
            2016-10: 12000
    """

    simulation = SimulationBuilder().build_from_dict(
        tax_benefit_system, test_runner.yaml.safe_load(input_yaml))

    assert simulation.get_array("salary", "2016-10") == 12000
    simulation.calculate("income_tax", "2016-10")
    simulation.calculate("total_taxes", "2016-10")
Exemplo n.º 2
0
def test_vectorial_input(tax_benefit_system):
    input_yaml = """
        salary:
            2016-10: [12000, 20000]
    """

    simulation = SimulationBuilder().build_from_dict(
        tax_benefit_system, test_runner.yaml.safe_load(input_yaml))

    tools.assert_near(simulation.get_array("salary", "2016-10"),
                      [12000, 20000])
    simulation.calculate("income_tax", "2016-10")
    simulation.calculate("total_taxes", "2016-10")
Exemplo n.º 3
0
def test_simulation_with_axes(tax_benefit_system):
    input_yaml = """
        persons:
          Alicia: {salary: {2018-11: 0}}
          Javier: {}
          Tom: {}
        households:
          housea:
            parents: [Alicia, Javier]
          houseb:
            parents: [Tom]
        axes:
            -
                - count: 2
                  name: rent
                  min: 0
                  max: 3000
                  period: 2018-11
    """
    data = test_runner.yaml.safe_load(input_yaml)
    simulation = SimulationBuilder().build_from_dict(tax_benefit_system, data)
    assert simulation.get_array('salary', '2018-11') == pytest.approx([0, 0, 0, 0, 0, 0])
    assert simulation.get_array('rent', '2018-11') == pytest.approx([0, 0, 3000, 0])