fix send_stanzas when no stanza given
darcs-hash:20070515155703-86b55-e76575f68f0c13fea7de6c7585ad21d12b4c630b.gz
This commit is contained in:
@@ -214,6 +214,7 @@ class JCLComponent(Component, object):
|
|||||||
def send_stanzas(self, stanzas):
|
def send_stanzas(self, stanzas):
|
||||||
"""Send given stanza list"""
|
"""Send given stanza list"""
|
||||||
self.__logger.debug("Sending responses")
|
self.__logger.debug("Sending responses")
|
||||||
|
if stanzas is not None:
|
||||||
for stanza in stanzas:
|
for stanza in stanzas:
|
||||||
self.stream.send(stanza)
|
self.stream.send(stanza)
|
||||||
|
|
||||||
|
|||||||
@@ -1959,6 +1959,22 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.comp.send_error(_account, exception)
|
self.comp.send_error(_account, exception)
|
||||||
self.assertEqual(len(self.comp.stream.sent), 0)
|
self.assertEqual(len(self.comp.stream.sent), 0)
|
||||||
|
|
||||||
|
def test_send_stanzas(self):
|
||||||
|
self.comp.stream = MockStream()
|
||||||
|
self.comp.stream_class = MockStream
|
||||||
|
msg1 = Message()
|
||||||
|
msg2 = Message()
|
||||||
|
self.comp.send_stanzas([msg1, msg2])
|
||||||
|
self.assertEquals(len(self.comp.stream.sent), 2)
|
||||||
|
self.assertEquals(self.comp.stream.sent[0], msg1)
|
||||||
|
self.assertEquals(self.comp.stream.sent[1], msg2)
|
||||||
|
|
||||||
|
def test_send_stanzas_none(self):
|
||||||
|
self.comp.stream = MockStream()
|
||||||
|
self.comp.stream_class = MockStream
|
||||||
|
self.comp.send_stanzas(None)
|
||||||
|
self.assertEquals(len(self.comp.stream.sent), 0)
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
return unittest.makeSuite(JCLComponent_TestCase, 'test')
|
return unittest.makeSuite(JCLComponent_TestCase, 'test')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user