88from ..cli import main
99from ..redcap2reproschema import process_choices
1010
11+
1112def test_process_choices_numeric_codes ():
1213 # Test standard numeric codes with descriptions
1314 choices_str = "1, Male | 2, Female | 3, Other"
@@ -19,6 +20,7 @@ def test_process_choices_numeric_codes():
1920 ]
2021 assert value_types == ["xsd:integer" ]
2122
23+
2224def test_process_choices_boolean ():
2325 # Test boolean choices (Yes/No)
2426 choices_str = "1, Yes | 0, No"
@@ -29,17 +31,19 @@ def test_process_choices_boolean():
2931 ]
3032 assert value_types == ["xsd:integer" ]
3133
34+
3235def test_process_choices_special_characters ():
3336 # Test choices with special characters
3437 choices_str = "1, Option A | 2, \" Option B\" | 3, Option C with 'quotes'"
3538 choices , value_types = process_choices (choices_str , "special_chars" )
3639 assert choices == [
3740 {"name" : {"en" : "Option A" }, "value" : 1 },
38- {"name" : {"en" : " \" Option B\" " }, "value" : 2 },
41+ {"name" : {"en" : '" Option B"' }, "value" : 2 },
3942 {"name" : {"en" : "Option C with 'quotes'" }, "value" : 3 },
4043 ]
4144 assert value_types == ["xsd:integer" ]
4245
46+
4347def test_process_choices_with_missing_values ():
4448 # Test choices with a missing value (commonly used for "Not applicable" or "Prefer not to say")
4549 choices_str = "1, Yes | 2, No | 99, Not applicable"
@@ -51,6 +55,7 @@ def test_process_choices_with_missing_values():
5155 ]
5256 assert value_types == ["xsd:integer" ]
5357
58+
5459def test_process_choices_with_unicode ():
5560 # Test choices with Unicode characters (e.g., accents, symbols)
5661 choices_str = "1, Café | 2, Niño | 3, Résumé | 4, ☺"
@@ -63,6 +68,7 @@ def test_process_choices_with_unicode():
6368 ]
6469 assert value_types == ["xsd:integer" ]
6570
71+
6672def test_process_choices_alpha_codes ():
6773 # Test alpha codes (e.g., categorical text codes)
6874 choices_str = "A, Apple | B, Banana | C, Cherry"
@@ -74,6 +80,7 @@ def test_process_choices_alpha_codes():
7480 ]
7581 assert sorted (value_types ) == ["xsd:string" ]
7682
83+
7784def test_process_choices_incomplete_values ():
7885 # Test choices with missing descriptions
7986 choices_str = "1, Yes | 2, | 3, No"
@@ -85,6 +92,7 @@ def test_process_choices_incomplete_values():
8592 ]
8693 assert value_types == ["xsd:integer" ]
8794
95+
8896def test_process_choices_numeric_strings ():
8997 # Test numeric strings as values (e.g., not converted to integers)
9098 choices_str = "001, Option 001 | 002, Option 002 | 003, Option 003"
@@ -96,6 +104,7 @@ def test_process_choices_numeric_strings():
96104 ]
97105 assert sorted (value_types ) == ["xsd:string" ]
98106
107+
99108def test_process_choices_spaces_in_values ():
100109 # Test choices with spaces in values and names
101110 choices_str = "A B, Choice AB | C D, Choice CD"
@@ -106,6 +115,7 @@ def test_process_choices_spaces_in_values():
106115 ]
107116 assert sorted (value_types ) == ["xsd:string" ]
108117
118+
109119# Run pytest if script is called directly
110120if __name__ == "__main__" :
111121 pytest .main ()
0 commit comments