11import  csv 
2+ 
23import  pytest 
34
45from  ..redcap2reproschema  import  process_field_properties 
@@ -13,63 +14,65 @@ def test_process_field_properties_calctext():
1314                "Variable / Field Name" : "test_var" ,
1415                "Required Field?" : "" ,
1516                "Field Annotation" : "@CALCTEXT" ,
16-                 "Branching Logic (Show field only if...)" : "" 
17+                 "Branching Logic (Show field only if...)" : "" , 
1718            },
1819            "expected" : {
1920                "variableName" : "test_var" ,
2021                "isAbout" : "items/test_var" ,
21-                 "isVis" : False 
22-             }
22+                 "isVis" : False , 
23+             }, 
2324        },
2425        # Complex CALCTEXT with conditional logic 
2526        {
2627            "input" : {
2728                "Variable / Field Name" : "parkinsons_diagnosis" ,
2829                "Required Field?" : "" ,
2930                "Field Annotation" : "@CALCTEXT(if(([diagnosis_parkinsons_gsd_category_1(bradykinesia)] && ([diagnosis_parkinsons_gsd_category_1(tremor)] || [diagnosis_parkinsons_gsd_category_1(rigidity)])), 'Yes', 'No'))" ,
30-                 "Branching Logic (Show field only if...)" : "[some_other_condition] = 1" 
31+                 "Branching Logic (Show field only if...)" : "[some_other_condition] = 1" , 
3132            },
3233            "expected" : {
3334                "variableName" : "parkinsons_diagnosis" ,
3435                "isAbout" : "items/parkinsons_diagnosis" ,
35-                 "isVis" : False 
36-             }
36+                 "isVis" : False , 
37+             }, 
3738        },
3839        # CALCTEXT with numerical operations 
3940        {
4041            "input" : {
4142                "Variable / Field Name" : "bmi" ,
4243                "Required Field?" : "" ,
4344                "Field Annotation" : "@CALCTEXT([weight]/([height]*[height]))" ,
44-                 "Branching Logic (Show field only if...)" : "[weight] > 0 and [height] > 0" 
45+                 "Branching Logic (Show field only if...)" : "[weight] > 0 and [height] > 0" , 
4546            },
4647            "expected" : {
4748                "variableName" : "bmi" ,
4849                "isAbout" : "items/bmi" ,
49-                 "isVis" : False 
50-             }
50+                 "isVis" : False , 
51+             }, 
5152        },
5253        # CALCTEXT with multiple nested conditions 
5354        {
5455            "input" : {
5556                "Variable / Field Name" : "complex_score" ,
5657                "Required Field?" : "" ,
5758                "Field Annotation" : "@CALCTEXT(if([score1] > 10 && [score2] < 5, 'High', if([score1] > 5, 'Medium', 'Low')))" ,
58-                 "Branching Logic (Show field only if...)" : "" 
59+                 "Branching Logic (Show field only if...)" : "" , 
5960            },
6061            "expected" : {
6162                "variableName" : "complex_score" ,
6263                "isAbout" : "items/complex_score" ,
63-                 "isVis" : False 
64-             }
65-         }
64+                 "isVis" : False , 
65+             }, 
66+         }, 
6667    ]
67-      
68+ 
6869    for  test_case  in  test_cases :
6970        result  =  process_field_properties (test_case ["input" ])
7071        for  key , expected_value  in  test_case ["expected" ].items ():
71-             assert  result [key ] ==  expected_value , \
72-                 f"Failed for { key }   in test case with annotation: { test_case ['input' ]['Field Annotation' ]}  " 
72+             assert  (
73+                 result [key ] ==  expected_value 
74+             ), f"Failed for { key }   in test case with annotation: { test_case ['input' ]['Field Annotation' ]}  " 
75+ 
7376
7477def  test_process_field_properties_mixed_annotations ():
7578    """Test fields with multiple annotations""" 
@@ -80,34 +83,35 @@ def test_process_field_properties_mixed_annotations():
8083                "Variable / Field Name" : "test_var" ,
8184                "Required Field?" : "" ,
8285                "Field Annotation" : "@CALCTEXT @READONLY" ,
83-                 "Branching Logic (Show field only if...)" : "" 
86+                 "Branching Logic (Show field only if...)" : "" , 
8487            },
85-             "expected" : {"isVis" : False }
88+             "expected" : {"isVis" : False }, 
8689        },
8790        # CALCTEXT with HIDDEN 
8891        {
8992            "input" : {
9093                "Variable / Field Name" : "test_var" ,
9194                "Required Field?" : "" ,
9295                "Field Annotation" : "@HIDDEN @CALCTEXT(if([var1] > 0, 1, 0))" ,
93-                 "Branching Logic (Show field only if...)" : "" 
96+                 "Branching Logic (Show field only if...)" : "" , 
9497            },
95-             "expected" : {"isVis" : False }
98+             "expected" : {"isVis" : False }, 
9699        },
97100        # Complex CALCTEXT with other annotations 
98101        {
99102            "input" : {
100103                "Variable / Field Name" : "test_var" ,
101104                "Required Field?" : "" ,
102105                "Field Annotation" : "@CALCTEXT(if(([var1] && [var2]), 'Yes', 'No')) @READONLY @HIDDEN-SURVEY" ,
103-                 "Branching Logic (Show field only if...)" : "[condition] = 1" 
106+                 "Branching Logic (Show field only if...)" : "[condition] = 1" , 
104107            },
105-             "expected" : {"isVis" : False }
106-         }
108+             "expected" : {"isVis" : False }, 
109+         }, 
107110    ]
108-      
111+ 
109112    for  test_case  in  test_cases :
110113        result  =  process_field_properties (test_case ["input" ])
111114        for  key , expected_value  in  test_case ["expected" ].items ():
112-             assert  result [key ] ==  expected_value , \
113-                 f"Failed for { key }   in test case with annotation: { test_case ['input' ]['Field Annotation' ]}  " 
115+             assert  (
116+                 result [key ] ==  expected_value 
117+             ), f"Failed for { key }   in test case with annotation: { test_case ['input' ]['Field Annotation' ]}  " 
0 commit comments