Skip to content

Commit 0e0f380

Browse files
committed
restore test to the previous version
1 parent 6c10509 commit 0e0f380

File tree

1 file changed

+28
-59
lines changed

1 file changed

+28
-59
lines changed

reproschema/tests/test_rs2redcap_redcap2rs.py

Lines changed: 28 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -230,45 +230,27 @@ def compare_protocols(prot_tree_orig, prot_tree_final):
230230
for nm, el in act_props_final.items():
231231
for key in ["isVis", "valueRequired"]:
232232
error = False
233-
orig_value = getattr(act_props_orig[nm], key)
234-
final_value = getattr(el, key)
235-
236-
if key == "valueRequired":
237-
# Debug print
238-
print(f"\nDebug - Activity: {act_name}, Item: {nm}")
239-
print(
240-
f"Original valueRequired: {orig_value}, type: {type(orig_value)}"
241-
)
242-
print(
243-
f"Final valueRequired: {final_value}, type: {type(final_value)}"
233+
if (getattr(act_props_orig[nm], key) is not None) and (
234+
normalize_condition(getattr(el, key))
235+
!= normalize_condition(
236+
getattr(act_props_orig[nm], key)
244237
)
245-
246-
# Compare only True values
247-
if orig_value is True:
248-
if final_value is not True:
249-
error = True
250-
print(
251-
f"Error case 1: orig=True, final={final_value}"
252-
)
253-
elif final_value is True:
254-
if orig_value is not True:
255-
error = True
256-
print(
257-
f"Error case 2: orig={orig_value}, final=True"
258-
)
259-
260-
elif key == "isVis":
261-
# Original isVis handling
262-
if orig_value is not None:
263-
if normalize_condition(
264-
orig_value
265-
) != normalize_condition(final_value):
266-
error = True
238+
):
239+
error = True
240+
elif (
241+
getattr(el, key)
242+
and getattr(act_props_orig[nm], key) is None
243+
):
244+
if (
245+
key == "isVis"
246+
and normalize_condition(getattr(el, key)) != True
247+
):
248+
error = True
267249
elif (
268-
final_value is not None and final_value is not True
250+
key == "valueRequired"
251+
and normalize_condition(getattr(el, key)) != False
269252
):
270253
error = True
271-
272254
if error:
273255
errors_list.append(
274256
print(
@@ -335,33 +317,20 @@ def compare_protocols(prot_tree_orig, prot_tree_final):
335317
) != normalize_condition(
336318
act_items_orig[nm]["obj"].question.get("en", "")
337319
):
338-
# Handle cases where one might be NaN/None and the other empty string
339-
orig_q = act_items_orig[nm]["obj"].question.get("en", "")
340-
final_q = el["obj"].question.get("en", "")
341-
342-
# Convert None/NaN to empty string for comparison
343-
orig_q = (
344-
"" if pd.isna(orig_q) or orig_q is None else orig_q
345-
)
346-
final_q = (
347-
"" if pd.isna(final_q) or final_q is None else final_q
348-
)
349-
350-
if normalize_condition(orig_q) != normalize_condition(
351-
final_q
320+
if "<br><br>" in normalize_condition(
321+
act_items_orig[nm]["obj"].question.get("en", "")
352322
):
353-
if "<br><br>" in normalize_condition(orig_q):
354-
warnings_list.append(
355-
print_return_msg(
356-
f"Activity {act_name}: items {nm} have different question, FIX normalized function!!!"
357-
)
323+
warnings_list.append(
324+
print_return_msg(
325+
f"Activity {act_name}: items {nm} have different question, FIX normalized function!!!"
358326
)
359-
else:
360-
errors_list.append(
361-
print_return_msg(
362-
f"Activity {act_name}: items {nm} have different question"
363-
)
327+
)
328+
else:
329+
errors_list.append(
330+
print_return_msg(
331+
f"Activity {act_name}: items {nm} have different question"
364332
)
333+
)
365334
elif (
366335
el["obj"].ui.inputType
367336
!= act_items_orig[nm]["obj"].ui.inputType

0 commit comments

Comments
 (0)