# -*- coding: utf-8 -*-


# OpenFisca -- A versatile microsimulation software
# By: OpenFisca Team <contact@openfisca.fr>
#
# Copyright (C) 2011, 2012, 2013, 2014, 2015 OpenFisca Team
# https://github.com/openfisca
#
# This file is part of OpenFisca.
#
# OpenFisca is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# OpenFisca is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program,  If not, see <http://www.gnu.org/licenses/>.


import datetime


from openfisca_core import periods
from openfisca_core.tools import assert_near
from openfisca_france.reforms import cesthra_invalidee
from openfisca_france.tests import base


def test_cesthra_invalidee():
    year = 2012
    reform = cesthra_invalidee.build_reform(base.tax_benefit_system)
    scenario = reform.new_scenario().init_single_entity(
        axes = [
            dict(
                count = 10,
                max = 30000,
                min = 0,
                name = 'salaire_imposable',
                ),
            ],
        period = periods.period('year', year),
        parent1 = dict(birth = datetime.date(year - 40, 1, 1)),
        parent2 = dict(birth = datetime.date(year - 40, 1, 1)),
        enfants = [
            dict(birth = datetime.date(year - 9, 1, 1)),
            dict(birth = datetime.date(year - 9, 1, 1)),
            ],
        )

    reference_simulation = scenario.new_simulation(debug = True, reference = True)

    reference_impo = reference_simulation.calculate('impo')
    reference_revdisp = reference_simulation.calculate('revdisp', period = periods.period('year', year))

    reform_impo = reference_simulation.calculate('impo')
    reform_revdisp = reference_simulation.calculate('revdisp', period = periods.period('year', year))


if __name__ == '__main__':
    import logging
    import sys
    logging.basicConfig(level = logging.ERROR, stream = sys.stdout)
    test_cesthra_invalidee()

@@ -954,53 +954,8 @@
 ods%0A
-from openfisca_core.tools import assert_near%0A
 from
@@ -1093,16 +1093,58 @@
  = 2012%0A
+    period = periods.period('year', year)%0A
     refo
@@ -1479,38 +1479,16 @@
 = period
-s.period('year', year)
 ,%0A      
@@ -1852,17 +1852,16 @@
 = True)%0A
-%0A
     refe
@@ -1908,24 +1908,62 @@
 ate('impo')%0A
+    assert reference_impo is not None%0A
     referenc
@@ -2035,32 +2035,113 @@
 riod
-s.period('year', year))%0A
+)%0A    assert reference_revdisp is not None%0A%0A    reform_simulation = scenario.new_simulation(debug = True)
 %0A   
@@ -2150,38 +2150,35 @@
 eform_impo = ref
-erence
+orm
 _simulation.calc
@@ -2187,24 +2187,59 @@
 ate('impo')%0A
+    assert reform_impo is not None%0A
     reform_r
@@ -2242,38 +2242,35 @@
 rm_revdisp = ref
-erence
+orm
 _simulation.calc
@@ -2305,31 +2305,47 @@
 riod
-s.period('year', year))
+)%0A    assert reform_revdisp is not None
 %0A%0A%0Ai

Update test