Skip to content

Commit 2da4919

Browse files
committed
add test
1 parent 4b877e5 commit 2da4919

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

reproschema/tests/test_redcap2reproschema.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55
import yaml
66
from click.testing import CliRunner
7+
from ..redcap2reproschema import process_field_properties
78

89
from ..cli import main
910

@@ -51,3 +52,36 @@ def test_redcap2reproschema(tmpdir):
5152
assert os.path.isdir(
5253
protocol_name
5354
), f"Expected output directory '{protocol_name}' does not exist"
55+
56+
def test_process_field_properties_visibility():
57+
# Test case 1: No branching logic or annotations
58+
field_data = {
59+
"Variable / Field Name": "test_field"
60+
}
61+
result = process_field_properties(field_data)
62+
assert "isVis" not in result
63+
64+
# Test case 2: With branching logic
65+
field_data = {
66+
"Variable / Field Name": "test_field",
67+
"Branching Logic (Show field only if...)": "[age] > 18"
68+
}
69+
result = process_field_properties(field_data)
70+
assert result["isVis"] == "age > 18"
71+
72+
# Test case 3: With @HIDDEN annotation
73+
field_data = {
74+
"Variable / Field Name": "test_field",
75+
"Field Annotation": "@HIDDEN"
76+
}
77+
result = process_field_properties(field_data)
78+
assert result["isVis"] is False
79+
80+
# Test case 4: With both branching logic and @HIDDEN
81+
field_data = {
82+
"Variable / Field Name": "test_field",
83+
"Branching Logic (Show field only if...)": "[age] > 18",
84+
"Field Annotation": "@HIDDEN"
85+
}
86+
result = process_field_properties(field_data)
87+
assert result["isVis"] is False

0 commit comments

Comments
 (0)