Skip to content

Commit abf484e

Browse files
formatting changes
1 parent 67ef5ea commit abf484e

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

src/rules_validation_api/app.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
import sys
2-
import json
31
import argparse
2+
import json
3+
import sys
44
from pathlib import Path
55

66
from rules_validation_api.validators.rules_validator import RulesValidation
77

8+
GREEN = "\033[92m"
9+
RESET = "\033[0m"
10+
YELLOW = "\033[93m"
11+
RED = "\033[91m"
12+
813

914
def main() -> None:
1015
parser = argparse.ArgumentParser(description="Validate campaign configuration.")
1116
parser.add_argument("--config_path", required=True, help="Path to the campaign config JSON file")
1217
args = parser.parse_args()
1318

14-
with Path(args.config_path).open() as file:
15-
json_data = json.load(file)
16-
RulesValidation(**json_data)
17-
sys.stdout.write("Valid Config\n")
19+
try:
20+
with Path(args.config_path).open() as file:
21+
json_data = json.load(file)
22+
RulesValidation(**json_data)
23+
sys.stdout.write(f"{GREEN}Valid Config{RESET}\n")
24+
except ValueError as e:
25+
sys.stderr.write(f"{YELLOW}Validation Error:{RESET} {RED}{e}{RESET}\n")
1826

1927

2028
if __name__ == "__main__":

tests/test_data/test_config/test_config.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"Name": "Test Config",
66
"Type": "V",
77
"Target": "RSV",
8-
"Manager": "person@test.com",
9-
"Approver": "person@test.com",
10-
"Reviewer": "person@test.com",
8+
"Manager": ["person@test.com"],
9+
"Approver": ["person@test.com"],
10+
"Reviewer": ["person@test.com"],
1111
"IterationFrequency": "X",
1212
"IterationType": "M",
1313
"IterationTime": "07:00:00",
@@ -20,8 +20,8 @@
2020
"DefaultNotEligibleRouting": "INTERNALCONTACTGP1",
2121
"ActionsMapper": {
2222
"INTERNALCONTACTGP1": {"ExternalRoutingCode": "CONTACTGP","ActionDescription":"Contact GP Text1 description", "ActionType":"text1"},
23-
"INTERNALCONTACTGP2": {"ExternalRoutingCode": "CONTACTGP","ActionDescription":"Contact GP Link description", "ActionType":"link", "UrlLink": "link123", "UrlLabel": "link label"},
24-
"INTERNALTESCO": {"ExternalRoutingCode": "TESCO","ActionDescription":"Tesco description", "ActionType":"link", "UrlLink": "tesco link", "UrlLabel": "link label"},
23+
"INTERNALCONTACTGP2": {"ExternalRoutingCode": "CONTACTGP","ActionDescription":"Contact GP Link description", "ActionType":"link", "UrlLink": "https://www.link123.example", "UrlLabel": "link label"},
24+
"INTERNALTESCO": {"ExternalRoutingCode": "TESCO","ActionDescription":"Tesco description", "ActionType":"link", "UrlLink": "/www.tesco_link.example", "UrlLabel": "link label"},
2525
"INTERNALFINDWALKIN": {"ExternalRoutingCode": "FINDWALKIN","ActionDescription":"Find walkin description", "ActionType":"button"},
2626

2727
"XRULEID1": {"ExternalRoutingCode": "FINDWALKIN","ActionDescription":"Find walkin description", "ActionType":"button"},

0 commit comments

Comments
 (0)