# Path: xmltool/utils.py
# def to_int(value):
# def truncate(s, limit=30):
# def prefixes_to_str(lis):
# def unflatten_params(params):
# def numdict_to_list(dct):
# 
# Path: tests/test_dtd_parser.py
# EXERCISE_XML = b'''<?xml version='1.0' encoding='UTF-8'?>
# <!DOCTYPE Exercise SYSTEM "test.dtd">
# <Exercise>
#   <question>What is your favorite color?</question>
#   <test>
#     <mqm>
#       <choice>blue</choice>
#       <choice>red</choice>
#       <choice>black</choice>
#     </mqm>
#   </test>
# </Exercise>
# '''
# 
# EXERCISE_DTD = u'''
# <!ELEMENT Exercise (question, test)>
# <!ELEMENT question (#PCDATA)>
# <!ELEMENT test (qcm|mqm)>
# <!ELEMENT qcm (choice+)>
# <!ELEMENT mqm (choice+)>
# <!ELEMENT choice (#PCDATA)>
# '''
# 
# INVALID_EXERCISE_XML = b'''<?xml version='1.0' encoding='UTF-8'?>
# <!DOCTYPE Exercise SYSTEM "test.dtd">
# <Exercise>
#   <question>What is your favorite color?</question>
#   <test>
#     <mqm>
#     </mqm>
#   </test>
# </Exercise>
# '''


from unittest import TestCase
from lxml import etree
from xmltool import utils
from .test_dtd_parser import EXERCISE_XML, EXERCISE_DTD, INVALID_EXERCISE_XML
import webob
    def test_numdict_to_list(self):
        dic = {
            'test': {'0': {'test1': {'value': 'v1'}},
                     '1': {'test1': {'value': 'v2'}}
                    }
        }
        utils.numdict_to_list(dic)
        expected = {
            'test': [{'test1': {'value': 'v1'}},
                     {'test1': {'value': 'v2'}}]}
        self.assertEqual(dic, expected)

        dic = {
            'test': {'1': {'test1': {'value': 'v1'}},
                     '3': {'test1': {'value': 'v2'}}
                    }
        }
        utils.numdict_to_list(dic)
        expected = {
            'test': [
                None,
                {'test1': {'value': 'v1'}},
                None,
                {'test1': {'value': 'v2'}}
            ]}
        self.assertEqual(dic, expected)

        dic = {
            'test': {}
        }

# Path: xmltool/utils.py
# def to_int(value):
# def truncate(s, limit=30):
# def prefixes_to_str(lis):
# def unflatten_params(params):
# def numdict_to_list(dct):
# 
# Path: tests/test_dtd_parser.py
# EXERCISE_XML = b'''<?xml version='1.0' encoding='UTF-8'?>
# <!DOCTYPE Exercise SYSTEM "test.dtd">
# <Exercise>
#   <question>What is your favorite color?</question>
#   <test>
#     <mqm>
#       <choice>blue</choice>
#       <choice>red</choice>
#       <choice>black</choice>
#     </mqm>
#   </test>
# </Exercise>
# '''
# 
# EXERCISE_DTD = u'''
# <!ELEMENT Exercise (question, test)>
# <!ELEMENT question (#PCDATA)>
# <!ELEMENT test (qcm|mqm)>
# <!ELEMENT qcm (choice+)>
# <!ELEMENT mqm (choice+)>
# <!ELEMENT choice (#PCDATA)>
# '''
# 
# INVALID_EXERCISE_XML = b'''<?xml version='1.0' encoding='UTF-8'?>
# <!DOCTYPE Exercise SYSTEM "test.dtd">
# <Exercise>
#   <question>What is your favorite color?</question>
#   <test>
#     <mqm>
#     </mqm>
#   </test>
# </Exercise>
# '''


# Path: tests/test_utils.py
from unittest import TestCase
from lxml import etree
from xmltool import utils
from .test_dtd_parser import EXERCISE_XML, EXERCISE_DTD, INVALID_EXERCISE_XML
import webob

    def test_numdict_to_list(self):
        dic = {
            'test': {'0': {'test1': {'value': 'v1'}},
                     '1': {'test1': {'value': 'v2'}}
                    }
        }
        utils.numdict_to_list(dic)
        expected = {
            'test': [{'test1': {'value': 'v1'}},
                     {'test1': {'value': 'v2'}}]}
        self.assertEqual(dic, expected)

        dic = {
            'test': {'1': {'test1': {'value': 'v1'}},
                     '3': {'test1': {'value': 'v2'}}
                    }
        }
        utils.numdict_to_list(dic)
        expected = {
            'test': [
                None,
                {'test1': {'value': 'v1'}},
                None,
                {'test1': {'value': 'v2'}}
            ]}
        self.assertEqual(dic, expected)

        dic = {
            'test': {}
        }

        utils.numdict_to_list(dic)