Repository: MAIF/arta

Issue:
Error with simple conditions when a field is written in pascalCase/CamelCase
Ex:
`simple_condition: input.pascalCaseVariable=="TEST"
`

Error:
arta.exceptions.ConditionExecutionError: Error while executing condition 'input.pascalCaseVariable=="TEST"': "Could not find path 'pascal' in the input data: 'code'"



Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2af70e8..5be35df 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
 
 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
+
+
+### Fixes
+
+* *Simple condition:* an error occurs when the field is of type camelcase or pascalcase  (e.g., `input.streetNumber`, `input.StreetNumber`).
+
+
 ## [0.8.0] - July, 2024
 
 ### Features
diff --git a/docs/pages/a_simple_example.md b/docs/pages/a_simple_example.md
index 3f104ac..cab7f1e 100644
--- a/docs/pages/a_simple_example.md
+++ b/docs/pages/a_simple_example.md
@@ -88,6 +88,8 @@ rules:
           mail_to: cook@super-heroes.test
           mail_content: "Thanks for preparing once a month the following dish:"
           meal: input.favorite_meal
+    
+
 
 actions_source_modules:
   - my_folder.actions
@@ -178,6 +180,7 @@ applicants = [
         "favorite_meal": None,
         "secret_weakness": "Feel alone",
         "weapons": ["Hands", "Batarang"],
+
     },
     {
         "id": 3,
diff --git a/src/arta/condition.py b/src/arta/condition.py
index f02df37..2355738 100644
--- a/src/arta/condition.py
+++ b/src/arta/condition.py
@@ -177,7 +177,7 @@ class SimpleCondition(BaseCondition):
         bool_var: bool = False
         unitary_expr: str = self._condition_id
 
-        data_path_patt: str = r"(?:input\.|output\.)(?:[a-z_\.]*)"
+        data_path_patt: str = r"(?:input\.|output\.)(?:[a-zA-Z_\.]*)"
 
         # Retrieve only the data path
         path_matches: list[str] = re.findall(data_path_patt, unitary_expr)


Test patch:
diff --git a/tests/examples/simple_cond_conf/ignored_rules/rules_simple_cond_ignored_rules.yaml b/tests/examples/simple_cond_conf/ignored_rules/rules_simple_cond_ignored_rules.yaml
index dab6892..83a7859 100644
--- a/tests/examples/simple_cond_conf/ignored_rules/rules_simple_cond_ignored_rules.yaml
+++ b/tests/examples/simple_cond_conf/ignored_rules/rules_simple_cond_ignored_rules.yaml
@@ -23,4 +23,5 @@ rules:
         action_parameters:
           value: false
 
+
 parsing_error_strategy: raise
diff --git a/tests/examples/simple_cond_conf/uppercase/rules_simple_cond_uppercase.yaml b/tests/examples/simple_cond_conf/uppercase/rules_simple_cond_uppercase.yaml
index 58503af..af8f18c 100644
--- a/tests/examples/simple_cond_conf/uppercase/rules_simple_cond_uppercase.yaml
+++ b/tests/examples/simple_cond_conf/uppercase/rules_simple_cond_uppercase.yaml
@@ -13,3 +13,10 @@ rules:
         action_parameters:
           list_str:
             - OK
+    camelCase :
+      RULE_1:
+        simple_condition: input.streetNumber>0 and input.streetName!="" and input.postalCode >0
+        action: concatenate_str
+        action_parameters:
+          list_str:
+            - OK
diff --git a/tests/unit/test_simple_condition.py b/tests/unit/test_simple_condition.py
index 441edaf..68826a7 100644
--- a/tests/unit/test_simple_condition.py
+++ b/tests/unit/test_simple_condition.py
@@ -19,7 +19,11 @@ from arta.exceptions import ConditionExecutionError, RuleExecutionError
             },
             "simple_cond_conf/default",
             None,
-            {"admission": {"admission": True}, "course": {"course_id": "senior"}, "email": True},
+            {
+                "admission": {"admission": True},
+                "course": {"course_id": "senior"},
+                "email": True,
+            },
         ),
         (
             {
@@ -30,7 +34,11 @@ from arta.exceptions import ConditionExecutionError, RuleExecutionError
             },
             "simple_cond_conf/default",
             None,
-            {"admission": {"admission": True}, "course": {"course_id": "english"}, "email": None},
+            {
+                "admission": {"admission": True},
+                "course": {"course_id": "english"},
+                "email": None,
+            },
         ),
         (
             {
@@ -41,26 +49,20 @@ from arta.exceptions import ConditionExecutionError, RuleExecutionError
             },
             "simple_cond_conf/default",
             None,
-            {"admission": {"admission": False}, "course": {"course_id": "senior"}, "email": None},
-        ),
-        (
             {
-                "dummy": 100,
-                "language": "french",
-                "power": "strength",
-                "favorite_meal": "Spinach",
+                "admission": {"admission": False},
+                "course": {"course_id": "senior"},
+                "email": None,
             },
+        ),
+        (
+            {"dummy": 100, "language": "french", "power": "strength", "favorite_meal": "Spinach"},
             "simple_cond_conf/ignore",
             None,
             {"admission": {"admission": True}, "course": {"course_id": "senior"}, "email": True},
         ),
         (
-            {
-                "age": 100,
-                "language": "french",
-                "power": "strength",
-                "favorite_meal": "Spinach",
-            },
+            {"age": 100, "language": "french", "power": "strength", "favorite_meal": "Spinach"},
             "simple_cond_conf/wrong/ignore",
             None,
             {"admission": {"admission": True}, "course": {"course_id": "senior"}, "email": True},
@@ -74,20 +76,16 @@ from arta.exceptions import ConditionExecutionError, RuleExecutionError
             {"whitespace": "OK"},
         ),
         (
-            {
-                "text": "SUPER HERO",
-            },
+            {"text": "SUPER HERO", "streetNumber": 15, "streetName": "rue des Es", "postalCode": 89000},
             "simple_cond_conf/uppercase",
             None,
-            {"uppercase": "OK"},
+            {"uppercase": "OK", "camelCase": "OK"},
         ),
         (
-            {
-                "text": "SUPER HERO",
-            },
+            {"text": "SUPER HERO", "streetNumber": 0, "streetName": "", "postalCode": 0},
             "simple_cond_conf/uppercase",
             set(),
-            {"uppercase": "OK"},
+            {"uppercase": "OK", "camelCase": None},
         ),
         (
             {"age": 100, "power": "strength"},
@@ -102,7 +100,6 @@ def test_simple_condition(input_data, config_dir, ignored_rules, good_results, b
     config_path = os.path.join(base_config_path, config_dir)
     eng = RulesEngine(config_path=config_path)
     res = eng.apply_rules(input_data=input_data, ignored_rules=ignored_rules)
-
     assert res == good_results
 
 
@@ -180,7 +177,6 @@ def test_simple_condition_verbose(input_data, good_results, base_config_path):
     config_path = os.path.join(base_config_path, "simple_cond_conf/default")
     eng = RulesEngine(config_path=config_path)
     res = eng.apply_rules(input_data=input_data, verbose=True)
-
     assert res == good_results
 
 
@@ -265,5 +261,4 @@ def test_math(input_data, config_dir, good_results, base_config_path):
     config_path = os.path.join(base_config_path, config_dir)
     eng = RulesEngine(config_path=config_path)
     res = eng.apply_rules(input_data=input_data)
-
     assert res == good_results