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

Commit

Permalink
Corrected stream header tester.
Browse files Browse the repository at this point in the history
Added test for testing stream headers.
  • Loading branch information
legastero committed Oct 6, 2010
1 parent 799645f commit 88d21d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tests/sleektest.py
Expand Up @@ -378,7 +378,6 @@ def streamStart(self, mode='client', skip=True, header=None):
self.xmpp.socket.recvData(header)

self.xmpp.connect = lambda a=None, b=None, c=None, d=None: True
self.xmpp.start_tls = lambda: True
self.xmpp.process(threaded=True)
if skip:
# Clear startup stanzas
Expand Down Expand Up @@ -420,6 +419,7 @@ def makeStreamHeader(self, sto='',
appended before the stream header.
"""
header = '<stream:stream %s>'
parts = []
if xml_header:
header = '<?xml version="1.0"?>' + header
if sto:
Expand Down Expand Up @@ -467,8 +467,8 @@ def streamSendHeader(self, sto='',

# Apply closing elements so that we can construct
# XML objects for comparison.
header2 += '</stream:stream>'
sent_header2 += '</stream:stream>'
header2 = header + '</stream:stream>'
sent_header2 = sent_header + '</stream:stream>'

xml = ET.fromstring(header2)
sent_xml = ET.fromstring(sent_header2)
Expand Down
11 changes: 8 additions & 3 deletions tests/test_streamtester.py
Expand Up @@ -16,15 +16,15 @@ def testClientEcho(self):

def echo(msg):
msg.reply('Thanks for sending: %(body)s' % msg).send()

self.xmpp.add_event_handler('message', echo)

self.streamRecv("""
<message to="tester@localhost" from="user@localhost">
<body>Hi!</body>
</message>
""")

self.streamSendMessage("""
<message to="user@localhost">
<body>Thanks for sending: Hi!</body>
Expand Down Expand Up @@ -52,4 +52,9 @@ def echo(msg):
</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)

0 comments on commit 88d21d2

Please sign in to comment.