def test_variable_with_reference(make_isolated_simulation): tax_benefit_system = CountryTaxBenefitSystem() # Work in isolation simulation_base = make_isolated_simulation(tax_benefit_system, {'salary': 4000}) revenu_disponible_avant_reforme = simulation_base.calculate( 'disposable_income', "2016-01") assert (revenu_disponible_avant_reforme > 0) class disposable_income(Variable): definition_period = MONTH def formula(household, period): return household.empty_array() tax_benefit_system.update_variable(disposable_income) simulation_reform = make_isolated_simulation(tax_benefit_system, {'salary': 4000}) revenu_disponible_apres_reforme = simulation_reform.calculate( 'disposable_income', "2016-01") assert (revenu_disponible_apres_reforme == 0)
def test_variable_with_reference(): tax_benefit_system = CountryTaxBenefitSystem() # Work in isolation def new_simulation(): return tax_benefit_system.new_scenario().init_from_attributes( period="2016-01", input_variables=dict(salary=4000, ), ).new_simulation() revenu_disponible_avant_reforme = new_simulation().calculate( 'disposable_income', "2016-01") assert (revenu_disponible_avant_reforme > 0) class disposable_income(Variable): definition_period = MONTH def formula(self, simulation, period): return self.zeros() tax_benefit_system.update_variable(disposable_income) revenu_disponible_apres_reforme = new_simulation().calculate( 'disposable_income', "2016-01") assert (revenu_disponible_apres_reforme == 0)