# Path: wokkel/shim.py
# NS_SHIM = "http://jabber.org/protocol/shim"
# class Headers(domish.Element):
#     def __init__(self, headers):
# def extractHeaders(stanza):
# 
# Path: wokkel/generic.py
# def parseXml(string):
#     """
#     Parse serialized XML into a DOM structure.
# 
#     @param string: The serialized XML to be parsed, UTF-8 encoded.
#     @type string: C{str}.
#     @return: The DOM structure, or C{None} on empty or incomplete input.
#     @rtype: L{domish.Element}
#     """
#     roots = []
#     results = []
#     elementStream = domish.elementStream()
#     elementStream.DocumentStartEvent = roots.append
#     elementStream.ElementEvent = lambda elem: roots[0].addChild(elem)
#     elementStream.DocumentEndEvent = lambda: results.append(roots[0])
#     elementStream.parse(string)
#     return results and results[0] or None


from twisted.python.compat import unicode
from twisted.trial import unittest
from wokkel import shim
from wokkel.generic import parseXml
        self.assertIn('node1', collections)
        self.assertIn('node2', collections)



class ExtractHeadersTest(unittest.TestCase):
    """
    Tests for L{wokkel.shim.extractHeaders}.
    """

    def test_noHeaders(self):
        """
        A stanza without headers results in an empty dictionary.
        """
        stanza = parseXml("""<message/>""")
        headers = shim.extractHeaders(stanza)
        self.assertEquals({}, headers)

    def test_headers(self):
        """
        A stanza with headers results in a dictionary with those headers.
        """
        xml = """<message>
                   <headers xmlns='http://jabber.org/protocol/shim'>
                     <header name='Collection'>node1</header>
                     <header name='Urgency'>high</header>
                   </headers>
                 </message>"""

        stanza = parseXml(xml)

# Path: wokkel/shim.py
# NS_SHIM = "http://jabber.org/protocol/shim"
# class Headers(domish.Element):
#     def __init__(self, headers):
# def extractHeaders(stanza):
# 
# Path: wokkel/generic.py
# def parseXml(string):
#     """
#     Parse serialized XML into a DOM structure.
# 
#     @param string: The serialized XML to be parsed, UTF-8 encoded.
#     @type string: C{str}.
#     @return: The DOM structure, or C{None} on empty or incomplete input.
#     @rtype: L{domish.Element}
#     """
#     roots = []
#     results = []
#     elementStream = domish.elementStream()
#     elementStream.DocumentStartEvent = roots.append
#     elementStream.ElementEvent = lambda elem: roots[0].addChild(elem)
#     elementStream.DocumentEndEvent = lambda: results.append(roots[0])
#     elementStream.parse(string)
#     return results and results[0] or None


# Path: wokkel/test/test_shim.py
from twisted.python.compat import unicode
from twisted.trial import unittest
from wokkel import shim
from wokkel.generic import parseXml

        self.assertIn('node1', collections)
        self.assertIn('node2', collections)



class ExtractHeadersTest(unittest.TestCase):
    """
    Tests for L{wokkel.shim.extractHeaders}.
    """

    def test_noHeaders(self):
        """
        A stanza without headers results in an empty dictionary.
        """
        stanza = parseXml("""<message/>""")
        headers = shim.extractHeaders(stanza)
        self.assertEquals({}, headers)

    def test_headers(self):
        """
        A stanza with headers results in a dictionary with those headers.
        """
        xml = """<message>
                   <headers xmlns='http://jabber.org/protocol/shim'>
                     <header name='Collection'>node1</header>
                     <header name='Urgency'>high</header>
                   </headers>
                 </message>"""

        stanza = parseXml(xml)

        headers = shim.extractHeaders(stanza)