From a13fdc58f63cceb8f623dd116ec0b682042f5f8d Mon Sep 17 00:00:00 2001 From: Allan - CodeWorks Date: Mon, 4 Dec 2023 14:46:31 +0100 Subject: [PATCH] =?UTF-8?q?L=C3=A8ve=20une=20NotImplementedError=20si=20un?= =?UTF-8?q?=20fichier=20d'aide=20dispose=20de=202=20profils=20identiques?= =?UTF-8?q?=20avec=20des=20conditions=20de=20m=C3=AAme=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../convert_benefit_conditions_to_parameters.py | 5 +++++ .../benefits/test_double_profile_meme_type.yml | 15 +++++++++++++++ .../benefit.yml | 15 +++++++++++++++ .../aides_jeunes/test_aides_jeunes_reform.py | 1 + 4 files changed, 36 insertions(+) create mode 100644 test_data/benefits/test_double_profile_meme_type.yml create mode 100644 test_data/bogus_benefits/test_2_same_type_profils_with_same_type_condition/benefit.yml diff --git a/openfisca_france_local/convert_benefit_conditions_to_parameters.py b/openfisca_france_local/convert_benefit_conditions_to_parameters.py index 7f11d7b6..91cf821c 100644 --- a/openfisca_france_local/convert_benefit_conditions_to_parameters.py +++ b/openfisca_france_local/convert_benefit_conditions_to_parameters.py @@ -114,6 +114,11 @@ def add_profil_with_conditions(data: dict, profil: dict): profil_condition = data['profils'][profil['type']]['conditions'] conditions_in_node_data = conditions_to_node_data(profil['conditions'])['conditions'] + + for type in profil_condition.keys(): + if type in conditions_in_node_data: + raise NotImplementedError('Une aide avec deux profils de même type ne peux pas avoir de conditions de même type pour chacun de ses profils') + profil_condition.update(conditions_in_node_data) def add_boolean_profil(data: dict, profil: dict): diff --git a/test_data/benefits/test_double_profile_meme_type.yml b/test_data/benefits/test_double_profile_meme_type.yml new file mode 100644 index 00000000..5ebc6346 --- /dev/null +++ b/test_data/benefits/test_double_profile_meme_type.yml @@ -0,0 +1,15 @@ +label: "Carte Génération - Apprentis : aide au transport" +conditions_generales: [] +profils: + - type: apprenti + conditions: + - type: age + operator: < + value: 26 + - type: apprenti + conditions: + - type: departements + values: + - "01" +type: float +montant: 200 diff --git a/test_data/bogus_benefits/test_2_same_type_profils_with_same_type_condition/benefit.yml b/test_data/bogus_benefits/test_2_same_type_profils_with_same_type_condition/benefit.yml new file mode 100644 index 00000000..2124093b --- /dev/null +++ b/test_data/bogus_benefits/test_2_same_type_profils_with_same_type_condition/benefit.yml @@ -0,0 +1,15 @@ +label: "Carte Génération - Apprentis : aide au transport" +conditions_generales: [] +profils: + - type: apprenti + conditions: + - type: age + operator: < + value: 26 + - type: apprenti + conditions: + - type: age + operator: < + value: 27 +type: float +montant: 200 diff --git a/tests/reforms/aides_jeunes/test_aides_jeunes_reform.py b/tests/reforms/aides_jeunes/test_aides_jeunes_reform.py index f776a43d..ad59fc83 100644 --- a/tests/reforms/aides_jeunes/test_aides_jeunes_reform.py +++ b/tests/reforms/aides_jeunes/test_aides_jeunes_reform.py @@ -7,6 +7,7 @@ @pytest.mark.parametrize("bogus_benefit_folder", [ 'test_missing_condition_key', 'test_missing_profile_key', + 'test_2_same_type_profils_with_same_type_condition', ]) def test_bogus_benefit_structure(bogus_benefit_folder): with pytest.raises(NotImplementedError):