Skip to content

Commit

Permalink
Lève une NotImplementedError si un fichier d'aide dispose de 2 profil…
Browse files Browse the repository at this point in the history
…s identiques avec des conditions de même type
  • Loading branch information
Allan-CodeWorks committed Dec 6, 2023
1 parent 960fea3 commit 84d4193
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
15 changes: 15 additions & 0 deletions test_data/benefits/test_double_profile_meme_type.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tests/reforms/aides_jeunes/test_aides_jeunes_reform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 84d4193

Please sign in to comment.