Skip to content

Commit 46a4fbb

Browse files
committed
[test/versionConv] Add strng value tests
1 parent 35161bc commit 46a4fbb

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

test/test_version_converter.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,37 @@ def test_convert_odml_file_value(self):
481481
</value>
482482
</property>
483483
484+
<property>
485+
<value>Single, string, value, with, many, commata.<type>string</type></value>
486+
<name>testSingleString</name>
487+
</property>
488+
489+
<property>
490+
<value>A<type>string</type></value>
491+
<value>B<type>string</type></value>
492+
<value>C<type>string</type></value>
493+
<name>testStringList</name>
494+
</property>
495+
496+
<property>
497+
<value> Single string value with wrapping whitespace <type>string</type></value>
498+
<name>testStringWhiteSpace</name>
499+
</property>
500+
501+
<property>
502+
<value> Multiple Strings <type>string</type></value>
503+
<value> with wrapping <type>string</type></value>
504+
<value> Whitespace <type>string</type></value>
505+
<name>testStringListWhiteSpace</name>
506+
</property>
507+
508+
<property>
509+
<value> 1 <type>int</type></value>
510+
<value> 2 <type>int</type></value>
511+
<value> 3 <type>int</type></value>
512+
<name>testIntListWhiteSpace</name>
513+
</property>
514+
484515
</section>
485516
</odML>
486517
"""
@@ -490,7 +521,7 @@ def test_convert_odml_file_value(self):
490521
conv_doc = vc._convert(vc._parse_xml())
491522
root = conv_doc.getroot()
492523
sec = root.find("section")
493-
self.assertEqual(len(sec), 9)
524+
self.assertEqual(len(sec), 14)
494525

495526
# Test single value export
496527
prop = sec.findall("property")[0]
@@ -541,6 +572,35 @@ def test_convert_odml_file_value(self):
541572
self.assertEqual(prop.find("name").text, "Unsupported binary value dtype replace")
542573
self.assertEqual(prop.find("type").text, "text")
543574

575+
# Test single string value with commata
576+
prop = sec.findall("property")[8]
577+
self.assertEqual(prop.find("name").text, "testSingleString")
578+
self.assertEqual(prop.find("value").text,
579+
"Single, string, value, with, many, commata.")
580+
581+
# Test string list import
582+
prop = sec.findall("property")[9]
583+
self.assertEqual(prop.find("name").text, "testStringList")
584+
self.assertEqual(prop.find("value").text, "[A,B,C]")
585+
586+
# Test single string values wrapping whitespace removal
587+
prop = sec.findall("property")[10]
588+
self.assertEqual(prop.find("name").text, "testStringWhiteSpace")
589+
self.assertEqual(prop.find("value").text,
590+
"Single string value with wrapping whitespace")
591+
592+
# Test multiple string values with wrapping whitespace removal
593+
prop = sec.findall("property")[11]
594+
self.assertEqual(prop.find("name").text, "testStringListWhiteSpace")
595+
self.assertEqual(prop.find("value").text,
596+
"[Multiple Strings,with wrapping,Whitespace]")
597+
598+
# Test multiple int values with wrapping whitespaces
599+
prop = sec.findall("property")[12]
600+
self.assertEqual(prop.find("name").text, "testIntListWhiteSpace")
601+
self.assertEqual(prop.find("type").text, "int")
602+
self.assertEqual(prop.find("value").text, "[1,2,3]")
603+
544604
def test_parse_dict_document(self):
545605
# Test appending tags; not appending empty sections
546606
doc_dict = {'Document': {'author': 'HPL', 'sections': []}}

0 commit comments

Comments
 (0)