Corrected stream header tester.
Added test for testing stream headers.
This commit is contained in:
parent
799645f13f
commit
88d21d210c
2 changed files with 11 additions and 6 deletions
|
@ -378,7 +378,6 @@ class SleekTest(unittest.TestCase):
|
||||||
self.xmpp.socket.recvData(header)
|
self.xmpp.socket.recvData(header)
|
||||||
|
|
||||||
self.xmpp.connect = lambda a=None, b=None, c=None, d=None: True
|
self.xmpp.connect = lambda a=None, b=None, c=None, d=None: True
|
||||||
self.xmpp.start_tls = lambda: True
|
|
||||||
self.xmpp.process(threaded=True)
|
self.xmpp.process(threaded=True)
|
||||||
if skip:
|
if skip:
|
||||||
# Clear startup stanzas
|
# Clear startup stanzas
|
||||||
|
@ -420,6 +419,7 @@ class SleekTest(unittest.TestCase):
|
||||||
appended before the stream header.
|
appended before the stream header.
|
||||||
"""
|
"""
|
||||||
header = '<stream:stream %s>'
|
header = '<stream:stream %s>'
|
||||||
|
parts = []
|
||||||
if xml_header:
|
if xml_header:
|
||||||
header = '<?xml version="1.0"?>' + header
|
header = '<?xml version="1.0"?>' + header
|
||||||
if sto:
|
if sto:
|
||||||
|
@ -467,8 +467,8 @@ class SleekTest(unittest.TestCase):
|
||||||
|
|
||||||
# Apply closing elements so that we can construct
|
# Apply closing elements so that we can construct
|
||||||
# XML objects for comparison.
|
# XML objects for comparison.
|
||||||
header2 += '</stream:stream>'
|
header2 = header + '</stream:stream>'
|
||||||
sent_header2 += '</stream:stream>'
|
sent_header2 = sent_header + '</stream:stream>'
|
||||||
|
|
||||||
xml = ET.fromstring(header2)
|
xml = ET.fromstring(header2)
|
||||||
sent_xml = ET.fromstring(sent_header2)
|
sent_xml = ET.fromstring(sent_header2)
|
||||||
|
|
|
@ -16,15 +16,15 @@ class TestStreamTester(SleekTest):
|
||||||
|
|
||||||
def echo(msg):
|
def echo(msg):
|
||||||
msg.reply('Thanks for sending: %(body)s' % msg).send()
|
msg.reply('Thanks for sending: %(body)s' % msg).send()
|
||||||
|
|
||||||
self.xmpp.add_event_handler('message', echo)
|
self.xmpp.add_event_handler('message', echo)
|
||||||
|
|
||||||
self.streamRecv("""
|
self.streamRecv("""
|
||||||
<message to="tester@localhost" from="user@localhost">
|
<message to="tester@localhost" from="user@localhost">
|
||||||
<body>Hi!</body>
|
<body>Hi!</body>
|
||||||
</message>
|
</message>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
self.streamSendMessage("""
|
self.streamSendMessage("""
|
||||||
<message to="user@localhost">
|
<message to="user@localhost">
|
||||||
<body>Thanks for sending: Hi!</body>
|
<body>Thanks for sending: Hi!</body>
|
||||||
|
@ -52,4 +52,9 @@ class TestStreamTester(SleekTest):
|
||||||
</message>
|
</message>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
def testSendStreamHeader(self):
|
||||||
|
"""Test that we can check a sent stream header."""
|
||||||
|
self.streamStart(mode='client', skip=False)
|
||||||
|
self.streamSendHeader(sto='localhost')
|
||||||
|
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamTester)
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamTester)
|
||||||
|
|
Loading…
Reference in a new issue