Skip to content

Commit 4f1bf9d

Browse files
authored
Feature/camelcase fields (#32)
* ✨ * ✨ * delete useless files * delete empty rows * 🎨 * 🎨 * 🎨 * ✏️ * ✨ pascalcase * ✏️ * add changelog * remove camelcase from tests * remove useless added test --------- Co-authored-by: Meriem JEBALI <[email protected]>
1 parent b9d6187 commit 4f1bf9d

File tree

6 files changed

+40
-27
lines changed

6 files changed

+40
-27
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44

55
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).
66

7+
8+
9+
### Fixes
10+
11+
* *Simple condition:* an error occurs when the field is of type camelcase or pascalcase (e.g., `input.streetNumber`, `input.StreetNumber`).
12+
13+
714
## [0.8.0] - July, 2024
815

916
### Features

docs/pages/a_simple_example.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ rules:
8888
8989
mail_content: "Thanks for preparing once a month the following dish:"
9090
meal: input.favorite_meal
91+
92+
9193

9294
actions_source_modules:
9395
- my_folder.actions
@@ -178,6 +180,7 @@ applicants = [
178180
"favorite_meal": None,
179181
"secret_weakness": "Feel alone",
180182
"weapons": ["Hands", "Batarang"],
183+
181184
},
182185
{
183186
"id": 3,

src/arta/condition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def verify(self, input_data: dict[str, Any], parsing_error_strategy: ParsingErro
177177
bool_var: bool = False
178178
unitary_expr: str = self._condition_id
179179

180-
data_path_patt: str = r"(?:input\.|output\.)(?:[a-z_\.]*)"
180+
data_path_patt: str = r"(?:input\.|output\.)(?:[a-zA-Z_\.]*)"
181181

182182
# Retrieve only the data path
183183
path_matches: list[str] = re.findall(data_path_patt, unitary_expr)

tests/examples/simple_cond_conf/ignored_rules/rules_simple_cond_ignored_rules.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ rules:
2323
action_parameters:
2424
value: false
2525

26+
2627
parsing_error_strategy: raise

tests/examples/simple_cond_conf/uppercase/rules_simple_cond_uppercase.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ rules:
1313
action_parameters:
1414
list_str:
1515
- OK
16+
camelCase :
17+
RULE_1:
18+
simple_condition: input.streetNumber>0 and input.streetName!="" and input.postalCode >0
19+
action: concatenate_str
20+
action_parameters:
21+
list_str:
22+
- OK

tests/unit/test_simple_condition.py

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
},
2020
"simple_cond_conf/default",
2121
None,
22-
{"admission": {"admission": True}, "course": {"course_id": "senior"}, "email": True},
22+
{
23+
"admission": {"admission": True},
24+
"course": {"course_id": "senior"},
25+
"email": True,
26+
},
2327
),
2428
(
2529
{
@@ -30,7 +34,11 @@
3034
},
3135
"simple_cond_conf/default",
3236
None,
33-
{"admission": {"admission": True}, "course": {"course_id": "english"}, "email": None},
37+
{
38+
"admission": {"admission": True},
39+
"course": {"course_id": "english"},
40+
"email": None,
41+
},
3442
),
3543
(
3644
{
@@ -41,26 +49,20 @@
4149
},
4250
"simple_cond_conf/default",
4351
None,
44-
{"admission": {"admission": False}, "course": {"course_id": "senior"}, "email": None},
45-
),
46-
(
4752
{
48-
"dummy": 100,
49-
"language": "french",
50-
"power": "strength",
51-
"favorite_meal": "Spinach",
53+
"admission": {"admission": False},
54+
"course": {"course_id": "senior"},
55+
"email": None,
5256
},
57+
),
58+
(
59+
{"dummy": 100, "language": "french", "power": "strength", "favorite_meal": "Spinach"},
5360
"simple_cond_conf/ignore",
5461
None,
5562
{"admission": {"admission": True}, "course": {"course_id": "senior"}, "email": True},
5663
),
5764
(
58-
{
59-
"age": 100,
60-
"language": "french",
61-
"power": "strength",
62-
"favorite_meal": "Spinach",
63-
},
65+
{"age": 100, "language": "french", "power": "strength", "favorite_meal": "Spinach"},
6466
"simple_cond_conf/wrong/ignore",
6567
None,
6668
{"admission": {"admission": True}, "course": {"course_id": "senior"}, "email": True},
@@ -74,20 +76,16 @@
7476
{"whitespace": "OK"},
7577
),
7678
(
77-
{
78-
"text": "SUPER HERO",
79-
},
79+
{"text": "SUPER HERO", "streetNumber": 15, "streetName": "rue des Es", "postalCode": 89000},
8080
"simple_cond_conf/uppercase",
8181
None,
82-
{"uppercase": "OK"},
82+
{"uppercase": "OK", "camelCase": "OK"},
8383
),
8484
(
85-
{
86-
"text": "SUPER HERO",
87-
},
85+
{"text": "SUPER HERO", "streetNumber": 0, "streetName": "", "postalCode": 0},
8886
"simple_cond_conf/uppercase",
8987
set(),
90-
{"uppercase": "OK"},
88+
{"uppercase": "OK", "camelCase": None},
9189
),
9290
(
9391
{"age": 100, "power": "strength"},
@@ -102,7 +100,6 @@ def test_simple_condition(input_data, config_dir, ignored_rules, good_results, b
102100
config_path = os.path.join(base_config_path, config_dir)
103101
eng = RulesEngine(config_path=config_path)
104102
res = eng.apply_rules(input_data=input_data, ignored_rules=ignored_rules)
105-
106103
assert res == good_results
107104

108105

@@ -180,7 +177,6 @@ def test_simple_condition_verbose(input_data, good_results, base_config_path):
180177
config_path = os.path.join(base_config_path, "simple_cond_conf/default")
181178
eng = RulesEngine(config_path=config_path)
182179
res = eng.apply_rules(input_data=input_data, verbose=True)
183-
184180
assert res == good_results
185181

186182

@@ -265,5 +261,4 @@ def test_math(input_data, config_dir, good_results, base_config_path):
265261
config_path = os.path.join(base_config_path, config_dir)
266262
eng = RulesEngine(config_path=config_path)
267263
res = eng.apply_rules(input_data=input_data)
268-
269264
assert res == good_results

0 commit comments

Comments
 (0)