Skip to content

Commit

Permalink
added more tests for read xml
Browse files Browse the repository at this point in the history
  • Loading branch information
frehburg committed Oct 16, 2024
1 parent 300b92d commit ebeae86
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/utils/io/test_data_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,50 @@
'xsi:schemaLocation': 'http://www.cdisc.org/ns/odm/v1.3 '
'schema/odm/ODM1-3-1.xsd'}}
),
('<string>Hello World</string>', {"string": "Hello World"}),
('<object><a>b</a><c>d</c></object>', {"object": {"a": "b", "c": "d"}}),
('<number>123</number>', {"number": 123}),
('<number>-123</number>', {"number": -123}),
('<number>123.4</number>', {"number": 123.4}),
('<null></null>', {"null": None}), # empty tag
('<null />', {"null": None}), # empty tag
('<null xsi:nil="true"/>', {"null": None}), # explicit null
('<color>gold</color>', {"color": "gold"}),
('<boolean>true</boolean>', {"boolean": True}),
('<boolean>false</boolean>', {"boolean": False}),
('<array><item>1</item><item>2</item><item>3</item></array>', {"array": {"item": [1, 2, 3]}}),
('<root>'
'<array>'
'<item>1</item>'
'<item>2</item>'
'<item>3</item>'
'</array>'
'<boolean>true</boolean>'
'<color>gold</color>'
'<number>123</number>'
'<object>'
'<a>b</a>'
'<c>d</c>'
'</object>'
'<string>Hello World</string>'
'</root>',
{
"root":{
"array": {
"item": [1, 2, 3]
},
"boolean": True,
"color": "gold",
"number": 123,
"object": {
"a": "b",
"c": "d"
},
"string": "Hello World"
}
}),
('<ItemData ItemOID="redcap_survey_identifier" Value=""/>', {"ItemData": {"ItemOID": "redcap_survey_identifier", "Value": ""}}),
]
)
def test_read_xml(inp, expected):
Expand Down

0 comments on commit ebeae86

Please sign in to comment.