def test_no_period(): year = 2016 buggy_tbf = CountryTaxBenefitSystem() buggy_tbf.add_variable(income_tax_no_period) simulation = buggy_tbf.new_scenario().init_from_attributes( period=year, input_variables=dict(salary=2000, ), ).new_simulation() simulation.calculate_add('income_tax_no_period', year)
def _make_simulation(tbs, period, data): builder = SimulationBuilder() builder.default_period = period return builder.build_from_variables(tbs, data) return _make_simulation class goes_to_school(Variable): value_type = bool default_value = True entity = Person label = "The person goes to school (only relevant for children)" definition_period = MONTH tax_benefit_system.add_variable(goes_to_school) class WithBasicIncomeNeutralized(Reform): def apply(self): self.neutralize_variable('basic_income') def test_formula_neutralization(make_simulation): reform = WithBasicIncomeNeutralized(tax_benefit_system) period = '2017-01' simulation = make_simulation(reform.base_tax_benefit_system, period, {}) simulation.debug = True basic_income = simulation.calculate('basic_income', period = period)