Skip to content
This repository has been archived by the owner on Oct 17, 2018. It is now read-only.

Commit

Permalink
refs #24: added a test to get list types with valid and invalid numId…
Browse files Browse the repository at this point in the history
…/ilvl combinations
  • Loading branch information
Jason Ward committed Apr 10, 2013
1 parent 222e51b commit 608de27
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion docx2html/tests/test_xml.py
Expand Up @@ -11,6 +11,7 @@
get_font_size,
get_image_id,
get_li_nodes,
get_list_type,
get_namespace,
get_relationship_info,
get_style_dict,
Expand All @@ -26,14 +27,21 @@
class SimpleListTestCase(_TranslationTestCase):
expected_output = '''
<html>
<ol data-list-type="decimal">
<ol data-list-type="lower-alpha">
<li>AAA</li>
<li>BBB</li>
<li>CCC</li>
</ol>
</html>
'''

# Ensure its not failing somewhere and falling back to decimal
numbering_dict = {
'1': {
0: 'lowerLetter',
}
}

def get_xml(self):
li_text = [
('AAA', 0, 1),
Expand Down Expand Up @@ -66,6 +74,40 @@ def test_is_last_li(self):
[False, False, True],
)

def test_get_list_type(self):
meta_data = self.get_meta_data()
numId = '1'
ilvl = 0

# Show that for a valid combination of numId and ilvl that you get the
# correct list type.
list_type = get_list_type(meta_data, numId, ilvl)
self.assertEqual(list_type, 'lowerLetter')

# Show that if the numId and/or the ilvl are invalid (not in the dict)
# that we still get a value (defaults to decimal)

# Invalid numId
numId = '2' # Not valid
ilvl = 0

list_type = get_list_type(meta_data, numId, ilvl)
self.assertEqual(list_type, 'decimal')

# Invalid ilvl
numId = '1'
ilvl = 1 # Not valid

list_type = get_list_type(meta_data, numId, ilvl)
self.assertEqual(list_type, 'decimal')

# Both invalid
numId = '2' # Not valid
ilvl = 1 # Not valid

list_type = get_list_type(meta_data, numId, ilvl)
self.assertEqual(list_type, 'decimal')


class TableInListTestCase(_TranslationTestCase):
expected_output = '''
Expand Down

0 comments on commit 608de27

Please sign in to comment.