From da314aff7969e0d629e6fcb54eee979e22887139 Mon Sep 17 00:00:00 2001 From: Alan Date: Wed, 2 Aug 2017 15:26:50 +0000 Subject: [PATCH] Add convert_xml test --- test/test_cldr2json.py | 68 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/test/test_cldr2json.py b/test/test_cldr2json.py index 6e4d0174c..78a6aa009 100755 --- a/test/test_cldr2json.py +++ b/test/test_cldr2json.py @@ -101,8 +101,72 @@ class TestParseRow(unittest.TestCase): class TestConvertXml(unittest.TestCase): - # cldr2json.convert_xml(xml): - pass + def test_convert_xml(self): + xml_string = """ + + + + + + + + + + + + + + + + + + + + """ + xml_tree = xml.etree.ElementTree.XML(xml_string) + json = { + "locale": "fr", + "name": "French", + "levels": [ + { + "level": "", + "mode": "default", + "rows": [ + [ + ['a', 'à', 'â', '%', 'æ', 'á', 'ä', 'ã', 'å', 'ā', 'ª'], + ] + ] + }, + { + "level": "shift", + "mode": "latched", + "rows": [ + [ + ['A', 'À', 'Â', '%', 'Æ', 'Á', 'Ä', 'Ã', 'Å', 'Ā', 'ª'], + ] + ] + }, + { + "level": "opt", + "mode": "locked", + "rows": [ + [ + ["1", "¹", "½", "⅓", "¼", "⅛"], + ] + ] + }, + { + "level": "opt+shift", + "mode": "locked", + "rows": [ + [ + ["~"], + ] + ] + } + ] + } + self.assertEqual(cldr2json.convert_xml(xml_tree), json) class TestConvertFile(unittest.TestCase):