From 75a051556f2cf65f75534102a7fe57a52571494a Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 7 Oct 2010 09:22:27 -0400 Subject: Changed SleekTest to use underscored names. --- tests/sleektest.py | 176 ++++++++++++++++++++++++------------------ tests/test_addresses.py | 18 ++--- tests/test_chatstates.py | 10 +-- tests/test_disco.py | 14 ++-- tests/test_elementbase.py | 36 ++++----- tests/test_errorstanzas.py | 8 +- tests/test_events.py | 4 +- tests/test_forms.py | 8 +- tests/test_gmail.py | 2 +- tests/test_handlers.py | 20 ++--- tests/test_iqstanzas.py | 20 ++--- tests/test_messagestanzas.py | 4 +- tests/test_presencestanzas.py | 10 +-- tests/test_pubsubstanzas.py | 38 ++++----- tests/test_roster.py | 4 +- tests/test_streamtester.py | 16 ++-- 16 files changed, 209 insertions(+), 179 deletions(-) (limited to 'tests') diff --git a/tests/sleektest.py b/tests/sleektest.py index e08a8deb..28901877 100644 --- a/tests/sleektest.py +++ b/tests/sleektest.py @@ -27,12 +27,12 @@ class TestSocket(object): of an actual networking socket. Methods: - nextSent -- Return the next sent stanza. - recvData -- Make a stanza available to read next. - recv -- Read the next stanza from the socket. - send -- Write a stanza to the socket. - makefile -- Dummy call, returns self. - read -- Read the next stanza from the socket. + next_sent -- Return the next sent stanza. + recv_data -- Make a stanza available to read next. + recv -- Read the next stanza from the socket. + send -- Write a stanza to the socket. + makefile -- Dummy call, returns self. + read -- Read the next stanza from the socket. """ def __init__(self, *args, **kwargs): @@ -70,7 +70,7 @@ class TestSocket(object): # ------------------------------------------------------------------ # Testing Interface - def nextSent(self, timeout=None): + def next_sent(self, timeout=None): """ Get the next stanza that has been 'sent'. @@ -85,7 +85,7 @@ class TestSocket(object): except: return None - def recvData(self, data): + def recv_data(self, data): """ Add data to the receiving queue. @@ -153,23 +153,28 @@ class SleekTest(unittest.TestCase): methods for comparing message, iq, and presence stanzas. Methods: - Message -- Create a Message stanza object. - Iq -- Create an Iq stanza object. - Presence -- Create a Presence stanza object. - checkMessage -- Compare a Message stanza against an XML string. - checkIq -- Compare an Iq stanza against an XML string. - checkPresence -- Compare a Presence stanza against an XML string. - streamStart -- Initialize a dummy XMPP client. - streamRecv -- Queue data for XMPP client to receive. - streamSendMessage -- Check that the XMPP client sent the given - Message stanza. - streamSendIq -- Check that the XMPP client sent the given - Iq stanza. - streamSendPresence -- Check taht the XMPP client sent the given - Presence stanza. - streamClose -- Disconnect the XMPP client. - fix_namespaces -- Add top-level namespace to an XML object. - compare -- Compare XML objects against each other. + Message -- Create a Message stanza object. + Iq -- Create an Iq stanza object. + Presence -- Create a Presence stanza object. + check_stanza -- Compare a generic stanza against an XML string. + check_message -- Compare a Message stanza against an XML string. + check_iq -- Compare an Iq stanza against an XML string. + check_presence -- Compare a Presence stanza against an XML string. + stream_start -- Initialize a dummy XMPP client. + stream_recv -- Queue data for XMPP client to receive. + stream_make_header -- Create a stream header. + stream_send_header -- Check that the given header has been sent. + stream_send_message -- Check that the XMPP client sent the given + Message stanza. + stream_send_iq -- Check that the XMPP client sent the given + Iq stanza. + stream_send_presence -- Check thatt the XMPP client sent the given + Presence stanza. + stream_send_stanza -- Check that the XMPP client sent the given + generic stanza. + stream_close -- Disconnect the XMPP client. + fix_namespaces -- Add top-level namespace to an XML object. + compare -- Compare XML objects against each other. """ # ------------------------------------------------------------------ @@ -211,8 +216,8 @@ class SleekTest(unittest.TestCase): # ------------------------------------------------------------------ # Methods for comparing stanza objects to XML strings - def checkStanza(self, stanza_class, stanza, xml_string, - defaults=None, use_values=True): + def check_stanza(self, stanza_class, stanza, xml_string, + defaults=None, use_values=True): """ Create and compare several stanza objects to a correct XML string. @@ -289,7 +294,7 @@ class SleekTest(unittest.TestCase): self.failUnless(result, debug) - def checkMessage(self, msg, xml_string, use_values=True): + def check_message(self, msg, xml_string, use_values=True): """ Create and compare several message stanza objects to a correct XML string. @@ -305,11 +310,11 @@ class SleekTest(unittest.TestCase): to True. """ - return self.checkStanza(Message, msg, xml_string, + return self.check_stanza(Message, msg, xml_string, defaults=['type'], use_values=use_values) - def checkIq(self, iq, xml_string, use_values=True): + def check_iq(self, iq, xml_string, use_values=True): """ Create and compare several iq stanza objects to a correct XML string. @@ -324,9 +329,9 @@ class SleekTest(unittest.TestCase): and setStanzaValues should be used. Defaults to True. """ - return self.checkStanza(Iq, iq, xml_string, use_values=use_values) + return self.check_stanza(Iq, iq, xml_string, use_values=use_values) - def checkPresence(self, pres, xml_string, use_values=True): + def check_presence(self, pres, xml_string, use_values=True): """ Create and compare several presence stanza objects to a correct XML string. @@ -341,14 +346,14 @@ class SleekTest(unittest.TestCase): and setStanzaValues should be used. Defaults to True. """ - return self.checkStanza(Presence, pres, xml_string, + return self.check_stanza(Presence, pres, xml_string, defaults=['priority'], use_values=use_values) # ------------------------------------------------------------------ # Methods for simulating stanza streams. - def streamStart(self, mode='client', skip=True, header=None): + def stream_start(self, mode='client', skip=True, header=None): """ Initialize an XMPP client or component using a dummy XML stream. @@ -375,17 +380,17 @@ class SleekTest(unittest.TestCase): # Must have the stream header ready for xmpp.process() to work. if not header: header = self.xmpp.stream_header - self.xmpp.socket.recvData(header) + self.xmpp.socket.recv_data(header) self.xmpp.connect = lambda a=None, b=None, c=None, d=None: True self.xmpp.process(threaded=True) if skip: # Clear startup stanzas - self.xmpp.socket.nextSent(timeout=0.01) + self.xmpp.socket.next_sent(timeout=0.01) if mode == 'component': - self.xmpp.socket.nextSent(timeout=0.01) + self.xmpp.socket.next_sent(timeout=0.01) - def streamRecv(self, data): + def stream_recv(self, data): """ Pass data to the dummy XMPP client as if it came from an XMPP server. @@ -394,9 +399,9 @@ class SleekTest(unittest.TestCase): XMPP client or component. """ data = str(data) - self.xmpp.socket.recvData(data) + self.xmpp.socket.recv_data(data) - def makeStreamHeader(self, sto='', + def stream_make_header(self, sto='', sfrom='', sid='', stream_ns="http://etherx.jabber.org/streams", @@ -406,7 +411,7 @@ class SleekTest(unittest.TestCase): """ Create a stream header to be received by the test XMPP agent. - The header must be saved and passed to streamStart. + The header must be saved and passed to stream_start. Arguments: sto -- The recipient of the stream header. @@ -433,14 +438,14 @@ class SleekTest(unittest.TestCase): parts.append('xmlns="%s"' % default_ns) return header % ' '.join(parts) - def streamSendHeader(self, sto='', - sfrom='', - sid='', - stream_ns="http://etherx.jabber.org/streams", - default_ns="jabber:client", - version="1.0", - xml_header=False, - timeout=0.1): + def stream_send_header(self, sto='', + sfrom='', + sid='', + stream_ns="http://etherx.jabber.org/streams", + default_ns="jabber:client", + version="1.0", + xml_header=False, + timeout=0.1): """ Check that a given stream header was sent. @@ -456,12 +461,12 @@ class SleekTest(unittest.TestCase): timeout -- Length of time to wait in seconds for a response. """ - header = self.makeStreamHeader(sto, sfrom, sid, - stream_ns=stream_ns, - default_ns=default_ns, - version=version, - xml_header=xml_header) - sent_header = self.xmpp.socket.nextSent(timeout) + header = self.stream_make_header(sto, sfrom, sid, + stream_ns=stream_ns, + default_ns=default_ns, + version=version, + xml_header=xml_header) + sent_header = self.xmpp.socket.next_sent(timeout) if sent_header is None: raise ValueError("Socket did not return data.") @@ -478,75 +483,100 @@ class SleekTest(unittest.TestCase): "Stream headers do not match:\nDesired:\n%s\nSent:\n%s" % ( header, sent_header)) - def streamSendMessage(self, data, use_values=True, timeout=.1): + def stream_send_stanza(self, stanza_class, data, defaults=None, + use_values=True, timeout=.1): + """ + Check that the XMPP client sent the given stanza XML. + + Extracts the next sent stanza and compares it with the given + XML using check_stanza. + + Arguments: + stanza_class -- The class of the sent stanza object. + data -- The XML string of the expected Message stanza, + or an equivalent stanza object. + use_values -- Modifies the type of tests used by check_message. + defaults -- A list of stanza interfaces that have defaults + values which may interfere with comparisons. + timeout -- Time in seconds to wait for a stanza before + failing the check. + """ + if isintance(data, str): + data = stanza_class(xml=ET.fromstring(data)) + sent = self.xmpp.socket.next_sent(timeout) + self.check_stanza(stanza_class, data, sent, + defaults=defaults, + use_values=use_values) + + def stream_send_message(self, data, use_values=True, timeout=.1): """ Check that the XMPP client sent the given stanza XML. Extracts the next sent stanza and compares it with the given - XML using checkMessage. + XML using check_message. Arguments: data -- The XML string of the expected Message stanza, or an equivalent stanza object. - use_values -- Modifies the type of tests used by checkMessage. + use_values -- Modifies the type of tests used by check_message. timeout -- Time in seconds to wait for a stanza before failing the check. """ if isinstance(data, str): data = self.Message(xml=ET.fromstring(data)) - sent = self.xmpp.socket.nextSent(timeout) - self.checkMessage(data, sent, use_values) + sent = self.xmpp.socket.next_sent(timeout) + self.check_message(data, sent, use_values) - def streamSendIq(self, data, use_values=True, timeout=.1): + def stream_send_iq(self, data, use_values=True, timeout=.1): """ Check that the XMPP client sent the given stanza XML. Extracts the next sent stanza and compares it with the given - XML using checkIq. + XML using check_iq. Arguments: data -- The XML string of the expected Iq stanza, or an equivalent stanza object. - use_values -- Modifies the type of tests used by checkIq. + use_values -- Modifies the type of tests used by check_iq. timeout -- Time in seconds to wait for a stanza before failing the check. """ if isinstance(data, str): data = self.Iq(xml=ET.fromstring(data)) - sent = self.xmpp.socket.nextSent(timeout) - self.checkIq(data, sent, use_values) + sent = self.xmpp.socket.next_sent(timeout) + self.check_iq(data, sent, use_values) - def streamSendPresence(self, data, use_values=True, timeout=.1): + def stream_send_presence(self, data, use_values=True, timeout=.1): """ Check that the XMPP client sent the given stanza XML. Extracts the next sent stanza and compares it with the given - XML using checkPresence. + XML using check_presence. Arguments: data -- The XML string of the expected Presence stanza, or an equivalent stanza object. - use_values -- Modifies the type of tests used by checkPresence. + use_values -- Modifies the type of tests used by check_presence. timeout -- Time in seconds to wait for a stanza before failing the check. """ if isinstance(data, str): data = self.Presence(xml=ET.fromstring(data)) - sent = self.xmpp.socket.nextSent(timeout) - self.checkPresence(data, sent, use_values) + sent = self.xmpp.socket.next_sent(timeout) + self.check_presence(data, sent, use_values) - def streamClose(self): + def stream_close(self): """ Disconnect the dummy XMPP client. - Can be safely called even if streamStart has not been called. + Can be safely called even if stream_start has not been called. Must be placed in the tearDown method of a test class to ensure that the XMPP client is disconnected after an error. """ if hasattr(self, 'xmpp') and self.xmpp is not None: self.xmpp.disconnect() - self.xmpp.socket.recvData(self.xmpp.stream_footer) + self.xmpp.socket.recv_data(self.xmpp.stream_footer) # ------------------------------------------------------------------ # XML Comparison and Cleanup diff --git a/tests/test_addresses.py b/tests/test_addresses.py index 450e1362..5c510c78 100644 --- a/tests/test_addresses.py +++ b/tests/test_addresses.py @@ -11,7 +11,7 @@ class TestAddresses(SleekTest): """Testing adding extended stanza address.""" msg = self.Message() msg['addresses'].addAddress(atype='to', jid='to@header1.org') - self.checkMessage(msg, """ + self.check_message(msg, """
@@ -23,7 +23,7 @@ class TestAddresses(SleekTest): msg['addresses'].addAddress(atype='replyto', jid='replyto@header1.org', desc='Reply address') - self.checkMessage(msg, """ + self.check_message(msg, """
@@ -53,14 +53,14 @@ class TestAddresses(SleekTest): 'jid':'cc@header2.org'}, {'type':'bcc', 'jid':'bcc@header2.org'}]) - self.checkMessage(msg, xmlstring) + self.check_message(msg, xmlstring) msg = self.Message() msg['addresses']['replyto'] = [{'jid':'replyto@header1.org', 'desc':'Reply address'}] msg['addresses']['cc'] = [{'jid':'cc@header2.org'}] msg['addresses']['bcc'] = [{'jid':'bcc@header2.org'}] - self.checkMessage(msg, xmlstring) + self.check_message(msg, xmlstring) def testAddURI(self): """Testing adding URI attribute to extended stanza address.""" @@ -69,7 +69,7 @@ class TestAddresses(SleekTest): addr = msg['addresses'].addAddress(atype='to', jid='to@header1.org', node='foo') - self.checkMessage(msg, """ + self.check_message(msg, """
@@ -78,7 +78,7 @@ class TestAddresses(SleekTest): """) addr['uri'] = 'mailto:to@header2.org' - self.checkMessage(msg, """ + self.check_message(msg, """
@@ -99,13 +99,13 @@ class TestAddresses(SleekTest): msg = self.Message() addr = msg['addresses'].addAddress(jid='to@header1.org', atype='to') - self.checkMessage(msg, xmlstring % '') + self.check_message(msg, xmlstring % '') addr['delivered'] = True - self.checkMessage(msg, xmlstring % 'delivered="true"') + self.check_message(msg, xmlstring % 'delivered="true"') addr['delivered'] = False - self.checkMessage(msg, xmlstring % '') + self.check_message(msg, xmlstring % '') suite = unittest.TestLoader().loadTestsFromTestCase(TestAddresses) diff --git a/tests/test_chatstates.py b/tests/test_chatstates.py index 74359df9..d5e3979a 100644 --- a/tests/test_chatstates.py +++ b/tests/test_chatstates.py @@ -21,24 +21,24 @@ class TestChatStates(SleekTest): msg = self.Message() msg['chat_state'].active() - self.checkMessage(msg, xmlstring % 'active', + self.check_message(msg, xmlstring % 'active', use_values=False) msg['chat_state'].composing() - self.checkMessage(msg, xmlstring % 'composing', + self.check_message(msg, xmlstring % 'composing', use_values=False) msg['chat_state'].gone() - self.checkMessage(msg, xmlstring % 'gone', + self.check_message(msg, xmlstring % 'gone', use_values=False) msg['chat_state'].inactive() - self.checkMessage(msg, xmlstring % 'inactive', + self.check_message(msg, xmlstring % 'inactive', use_values=False) msg['chat_state'].paused() - self.checkMessage(msg, xmlstring % 'paused', + self.check_message(msg, xmlstring % 'paused', use_values=False) suite = unittest.TestLoader().loadTestsFromTestCase(TestChatStates) diff --git a/tests/test_disco.py b/tests/test_disco.py index 2cc50ee0..f65fdaf4 100644 --- a/tests/test_disco.py +++ b/tests/test_disco.py @@ -14,7 +14,7 @@ class TestDisco(SleekTest): iq['id'] = "0" iq['disco_info']['node'] = '' - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -26,7 +26,7 @@ class TestDisco(SleekTest): iq['id'] = "0" iq['disco_info']['node'] = 'foo' - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -38,7 +38,7 @@ class TestDisco(SleekTest): iq['id'] = "0" iq['disco_items']['node'] = '' - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -50,7 +50,7 @@ class TestDisco(SleekTest): iq['id'] = "0" iq['disco_items']['node'] = 'foo' - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -63,7 +63,7 @@ class TestDisco(SleekTest): iq['disco_info']['node'] = 'foo' iq['disco_info'].addIdentity('conference', 'text', 'Chatroom') - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -79,7 +79,7 @@ class TestDisco(SleekTest): iq['disco_info'].addFeature('foo') iq['disco_info'].addFeature('bar') - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -97,7 +97,7 @@ class TestDisco(SleekTest): iq['disco_items'].addItem('user@localhost', 'foo') iq['disco_items'].addItem('user@localhost', 'bar', 'Testing') - self.checkIq(iq, """ + self.check_iq(iq, """ diff --git a/tests/test_elementbase.py b/tests/test_elementbase.py index dfd37b53..19794c90 100644 --- a/tests/test_elementbase.py +++ b/tests/test_elementbase.py @@ -26,7 +26,7 @@ class TestElementBase(SleekTest): namespace = "test" stanza = TestStanza() - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ @@ -116,7 +116,7 @@ class TestElementBase(SleekTest): 'baz': ''}]} stanza.setStanzaValues(values) - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ @@ -197,7 +197,7 @@ class TestElementBase(SleekTest): stanza['qux'] = 'overridden' stanza['foobar'] = 'plugin' - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ element! @@ -230,7 +230,7 @@ class TestElementBase(SleekTest): stanza['qux'] = 'c' stanza['foobar']['foobar'] = 'd' - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ a @@ -242,7 +242,7 @@ class TestElementBase(SleekTest): del stanza['qux'] del stanza['foobar'] - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ """) @@ -256,7 +256,7 @@ class TestElementBase(SleekTest): stanza = TestStanza() - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ """) @@ -266,7 +266,7 @@ class TestElementBase(SleekTest): stanza._setAttr('bar', 'a') stanza._setAttr('baz', 'b') - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ """) @@ -276,7 +276,7 @@ class TestElementBase(SleekTest): stanza._setAttr('bar', None) stanza._delAttr('baz') - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ """) @@ -306,7 +306,7 @@ class TestElementBase(SleekTest): "Default _getSubText value incorrect.") stanza['bar'] = 'found' - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ found @@ -339,7 +339,7 @@ class TestElementBase(SleekTest): stanza = TestStanza() stanza['bar'] = 'a' stanza['baz'] = 'b' - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ a @@ -348,7 +348,7 @@ class TestElementBase(SleekTest): """) stanza._setSubText('wrapper/bar', text='', keep=True) - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ @@ -359,7 +359,7 @@ class TestElementBase(SleekTest): stanza['bar'] = 'a' stanza._setSubText('wrapper/bar', text='') - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ b @@ -397,7 +397,7 @@ class TestElementBase(SleekTest): stanza['bar'] = 'a' stanza['baz'] = 'b' - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ @@ -415,7 +415,7 @@ class TestElementBase(SleekTest): del stanza['bar'] del stanza['baz'] - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ @@ -431,7 +431,7 @@ class TestElementBase(SleekTest): stanza._delSub('path/to/only/bar', all=True) - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ @@ -602,7 +602,7 @@ class TestElementBase(SleekTest): "Incorrect empty stanza size.") stanza.append(substanza1) - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ @@ -611,7 +611,7 @@ class TestElementBase(SleekTest): "Incorrect stanza size with 1 substanza.") stanza.append(substanza2) - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ @@ -622,7 +622,7 @@ class TestElementBase(SleekTest): # Test popping substanzas stanza.pop(0) - self.checkStanza(TestStanza, stanza, """ + self.check_stanza(TestStanza, stanza, """ diff --git a/tests/test_errorstanzas.py b/tests/test_errorstanzas.py index d6fafc59..a883b7ef 100644 --- a/tests/test_errorstanzas.py +++ b/tests/test_errorstanzas.py @@ -6,7 +6,7 @@ class TestErrorStanzas(SleekTest): """Test setting initial values in error stanza.""" msg = self.Message() msg.enable('error') - self.checkMessage(msg, """ + self.check_message(msg, """ @@ -19,7 +19,7 @@ class TestErrorStanzas(SleekTest): msg = self.Message() msg['error']['condition'] = 'item-not-found' - self.checkMessage(msg, """ + self.check_message(msg, """ @@ -31,7 +31,7 @@ class TestErrorStanzas(SleekTest): del msg['error']['condition'] - self.checkMessage(msg, """ + self.check_message(msg, """ @@ -45,7 +45,7 @@ class TestErrorStanzas(SleekTest): del msg['error']['condition'] - self.checkMessage(msg, """ + self.check_message(msg, """ Error! diff --git a/tests/test_events.py b/tests/test_events.py index df36969d..d9d80c30 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -6,10 +6,10 @@ from . sleektest import * class TestEvents(SleekTest): def setUp(self): - self.streamStart() + self.stream_start() def tearDown(self): - self.streamClose() + self.stream_close() def testEventHappening(self): """Test handler working""" diff --git a/tests/test_forms.py b/tests/test_forms.py index d5710633..67b0f6a8 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -14,7 +14,7 @@ class TestDataForms(SleekTest): msg = self.Message() msg['form']['instructions'] = "Instructions\nSecond batch" - self.checkMessage(msg, """ + self.check_message(msg, """ Instructions @@ -35,7 +35,7 @@ class TestDataForms(SleekTest): required=True, value='Some text!') - self.checkMessage(msg, """ + self.check_message(msg, """ @@ -62,7 +62,7 @@ class TestDataForms(SleekTest): 'value': 'cool'}, {'label': 'Urgh!', 'value': 'urgh'}]})] - self.checkMessage(msg, """ + self.check_message(msg, """ @@ -99,7 +99,7 @@ class TestDataForms(SleekTest): form.setValues({'foo': 'Foo!', 'bar': ['a', 'b']}) - self.checkMessage(msg, """ + self.check_message(msg, """ diff --git a/tests/test_gmail.py b/tests/test_gmail.py index dd256e27..5636e877 100644 --- a/tests/test_gmail.py +++ b/tests/test_gmail.py @@ -18,7 +18,7 @@ class TestGmail(SleekTest): iq['gmail']['newer-than-time'] = '1140638252542' iq['gmail']['newer-than-tid'] = '11134623426430234' - self.checkIq(iq, """ + self.check_iq(iq, """ """) + self.stream_recv("""""") msg = self.Message() msg['body'] = 'Success!' - self.streamSendMessage(msg) + self.stream_send_message(msg) def testWaiter(self): """Test using stream waiter handler.""" @@ -55,7 +55,7 @@ class TestHandlers(SleekTest): self.xmpp.add_event_handler('message', waiter_handler, threaded=True) # Send message to trigger waiter_handler - self.streamRecv(""" + self.stream_recv(""" Testing @@ -66,10 +66,10 @@ class TestHandlers(SleekTest): iq['id'] = 'test' iq['type'] = 'set' iq['query'] = 'test' - self.streamSendIq(iq) + self.stream_send_iq(iq) # Send the reply Iq - self.streamRecv(""" + self.stream_recv(""" @@ -78,7 +78,7 @@ class TestHandlers(SleekTest): # Check that waiter_handler received the reply msg = self.Message() msg['body'] = 'Successful: test' - self.streamSendMessage(msg) + self.stream_send_message(msg) def testWaiterTimeout(self): """Test that waiter handler is removed after timeout.""" @@ -93,14 +93,14 @@ class TestHandlers(SleekTest): self.xmpp.add_event_handler('message', waiter_handler, threaded=True) # Start test by triggerig waiter_handler - self.streamRecv("""Start Test""") + self.stream_recv("""Start Test""") # Check that Iq was sent to trigger start of timeout period iq = self.Iq() iq['id'] = 'test2' iq['type'] = 'set' iq['query'] = 'test2' - self.streamSendIq(iq) + self.stream_send_iq(iq) # Check that the waiter is no longer registered waiter_exists = self.xmpp.removeHandler('IqWait_test2') diff --git a/tests/test_iqstanzas.py b/tests/test_iqstanzas.py index 2dabc5e9..197bc001 100644 --- a/tests/test_iqstanzas.py +++ b/tests/test_iqstanzas.py @@ -6,12 +6,12 @@ class TestIqStanzas(SleekTest): def tearDown(self): """Shutdown the XML stream after testing.""" - self.streamClose() + self.stream_close() def testSetup(self): """Test initializing default Iq values.""" iq = self.Iq() - self.checkIq(iq, """ + self.check_iq(iq, """ """) @@ -19,7 +19,7 @@ class TestIqStanzas(SleekTest): """Test setting Iq stanza payload.""" iq = self.Iq() iq.setPayload(ET.Element('{test}tester')) - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -28,8 +28,8 @@ class TestIqStanzas(SleekTest): def testUnhandled(self): """Test behavior for Iq.unhandled.""" - self.streamStart() - self.streamRecv(""" + self.stream_start() + self.stream_recv(""" @@ -40,7 +40,7 @@ class TestIqStanzas(SleekTest): iq['error']['condition'] = 'feature-not-implemented' iq['error']['text'] = 'No handlers registered for this request.' - self.streamSendIq(iq, """ + self.stream_send_iq(iq, """ @@ -56,14 +56,14 @@ class TestIqStanzas(SleekTest): iq = self.Iq() iq['query'] = 'query_ns' - self.checkIq(iq, """ + self.check_iq(iq, """ """) iq['query'] = 'query_ns2' - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -72,7 +72,7 @@ class TestIqStanzas(SleekTest): self.failUnless(iq['query'] == 'query_ns2', "Query namespace doesn't match") del iq['query'] - self.checkIq(iq, """ + self.check_iq(iq, """ """) @@ -83,7 +83,7 @@ class TestIqStanzas(SleekTest): iq['type'] = 'get' iq.reply() - self.checkIq(iq, """ + self.check_iq(iq, """ """) diff --git a/tests/test_messagestanzas.py b/tests/test_messagestanzas.py index 2a1567da..d57f5ad4 100644 --- a/tests/test_messagestanzas.py +++ b/tests/test_messagestanzas.py @@ -33,7 +33,7 @@ class TestMessageStanzas(SleekTest): p = ET.Element('{http://www.w3.org/1999/xhtml}p') p.text = "This is the htmlim message" msg['html']['body'] = p - self.checkMessage(msg, """ + self.check_message(msg, """ this is the plaintext message @@ -47,7 +47,7 @@ class TestMessageStanzas(SleekTest): "Test message/nick/nick stanza." msg = self.Message() msg['nick']['nick'] = 'A nickname!' - self.checkMessage(msg, """ + self.check_message(msg, """ A nickname! diff --git a/tests/test_presencestanzas.py b/tests/test_presencestanzas.py index f4a33aa7..2452df4f 100644 --- a/tests/test_presencestanzas.py +++ b/tests/test_presencestanzas.py @@ -9,26 +9,26 @@ class TestPresenceStanzas(SleekTest): """Regression check presence['type'] = 'dnd' show value working""" p = self.Presence() p['type'] = 'dnd' - self.checkPresence(p, "dnd") + self.check_presence(p, "dnd") def testPresenceType(self): """Test manipulating presence['type']""" p = self.Presence() p['type'] = 'available' - self.checkPresence(p, "") + self.check_presence(p, "") self.failUnless(p['type'] == 'available', "Incorrect presence['type'] for type 'available'") for showtype in ['away', 'chat', 'dnd', 'xa']: p['type'] = showtype - self.checkPresence(p, """ + self.check_presence(p, """ %s """ % showtype) self.failUnless(p['type'] == showtype, "Incorrect presence['type'] for type '%s'" % showtype) p['type'] = None - self.checkPresence(p, "") + self.check_presence(p, "") def testPresenceUnsolicitedOffline(self): """ @@ -57,7 +57,7 @@ class TestPresenceStanzas(SleekTest): """Test presence/nick/nick stanza.""" p = self.Presence() p['nick']['nick'] = 'A nickname!' - self.checkPresence(p, """ + self.check_presence(p, """ A nickname! diff --git a/tests/test_pubsubstanzas.py b/tests/test_pubsubstanzas.py index 38fc29e5..42a1b52e 100644 --- a/tests/test_pubsubstanzas.py +++ b/tests/test_pubsubstanzas.py @@ -16,7 +16,7 @@ class TestPubsubStanzas(SleekTest): aff2['affiliation'] = 'publisher' iq['pubsub']['affiliations'].append(aff1) iq['pubsub']['affiliations'].append(aff2) - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -38,7 +38,7 @@ class TestPubsubStanzas(SleekTest): sub2['subscription'] = 'subscribed' iq['pubsub']['subscriptions'].append(sub1) iq['pubsub']['subscriptions'].append(sub2) - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -55,7 +55,7 @@ class TestPubsubStanzas(SleekTest): iq['pubsub']['subscription']['node'] = 'testnode alsdkjfas' iq['pubsub']['subscription']['jid'] = "fritzy@netflint.net/sleekxmpp" iq['pubsub']['subscription']['subscription'] = 'unconfigured' - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -88,7 +88,7 @@ class TestPubsubStanzas(SleekTest): item2['payload'] = payload2 iq['pubsub']['items'].append(item) iq['pubsub']['items'].append(item2) - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -115,7 +115,7 @@ class TestPubsubStanzas(SleekTest): iq['pubsub']['configure']['form'].addField('pubsub#title', ftype='text-single', value='This thing is awesome') - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -136,7 +136,7 @@ class TestPubsubStanzas(SleekTest): iq['psstate']['item']= 'myitem' pl = ET.Element('{http://andyet.net/protocol/pubsubqueue}claimed') iq['psstate']['payload'] = pl - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -152,7 +152,7 @@ class TestPubsubStanzas(SleekTest): iq['pubsub_owner']['default']['form'].addField('pubsub#title', ftype='text-single', value='This thing is awesome') - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -176,7 +176,7 @@ class TestPubsubStanzas(SleekTest): form = xep_0004.Form() form.addField('pubsub#title', ftype='text-single', value='this thing is awesome') iq['pubsub']['subscribe']['options']['options'] = form - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -214,7 +214,7 @@ class TestPubsubStanzas(SleekTest): iq['pubsub']['publish'].append(item) iq['pubsub']['publish'].append(item2) - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -238,7 +238,7 @@ class TestPubsubStanzas(SleekTest): "Testing iq/pubsub_owner/delete stanzas" iq = self.Iq() iq['pubsub_owner']['delete']['node'] = 'thingers' - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -300,7 +300,7 @@ class TestPubsubStanzas(SleekTest): 'label': 'Deliver notification only to available users'}), ]) - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -357,7 +357,7 @@ class TestPubsubStanzas(SleekTest): msg['pubsub_event']['items'].append(item) msg['pubsub_event']['items']['node'] = 'cheese' msg['type'] = 'normal' - self.checkMessage(msg, """ + self.check_message(msg, """ @@ -383,7 +383,7 @@ class TestPubsubStanzas(SleekTest): msg['pubsub_event']['items'].append(item2) msg['pubsub_event']['items']['node'] = 'cheese' msg['type'] = 'normal' - self.checkMessage(msg, """ + self.check_message(msg, """ @@ -415,7 +415,7 @@ class TestPubsubStanzas(SleekTest): msg['pubsub_event']['items'].append(item2) msg['pubsub_event']['items']['node'] = 'cheese' msg['type'] = 'normal' - self.checkMessage(msg, """ + self.check_message(msg, """ @@ -435,7 +435,7 @@ class TestPubsubStanzas(SleekTest): msg['pubsub_event']['collection']['associate']['node'] = 'cheese' msg['pubsub_event']['collection']['node'] = 'cheeseburger' msg['type'] = 'headline' - self.checkMessage(msg, """ + self.check_message(msg, """ @@ -450,7 +450,7 @@ class TestPubsubStanzas(SleekTest): msg['pubsub_event']['collection']['disassociate']['node'] = 'cheese' msg['pubsub_event']['collection']['node'] = 'cheeseburger' msg['type'] = 'headline' - self.checkMessage(msg, """ + self.check_message(msg, """ @@ -467,7 +467,7 @@ class TestPubsubStanzas(SleekTest): ftype='text-single', value='This thing is awesome') msg['type'] = 'headline' - self.checkMessage(msg, """ + self.check_message(msg, """ @@ -485,7 +485,7 @@ class TestPubsubStanzas(SleekTest): msg = self.Message() msg['pubsub_event']['purge']['node'] = 'pickles' msg['type'] = 'headline' - self.checkMessage(msg, """ + self.check_message(msg, """ @@ -501,7 +501,7 @@ class TestPubsubStanzas(SleekTest): msg['pubsub_event']['subscription']['subscription'] = 'subscribed' msg['pubsub_event']['subscription']['expiry'] = 'presence' msg['type'] = 'headline' - self.checkMessage(msg, """ + self.check_message(msg, """ diff --git a/tests/test_roster.py b/tests/test_roster.py index 6f9fa3d6..f210551d 100644 --- a/tests/test_roster.py +++ b/tests/test_roster.py @@ -16,7 +16,7 @@ class TestRosterStanzas(SleekTest): 'name': 'Other User', 'subscription': 'both', 'groups': []}}) - self.checkIq(iq, """ + self.check_iq(iq, """ @@ -74,7 +74,7 @@ class TestRosterStanzas(SleekTest): """ iq = self.Iq(ET.fromstring(xml_string)) del iq['roster']['items'] - self.checkIq(iq, """ + self.check_iq(iq, """ diff --git a/tests/test_streamtester.py b/tests/test_streamtester.py index 8a4f82dd..9bc9de67 100644 --- a/tests/test_streamtester.py +++ b/tests/test_streamtester.py @@ -8,24 +8,24 @@ class TestStreamTester(SleekTest): """ def tearDown(self): - self.streamClose() + self.stream_close() def testClientEcho(self): """Test that we can interact with a ClientXMPP instance.""" - self.streamStart(mode='client') + self.stream_start(mode='client') def echo(msg): msg.reply('Thanks for sending: %(body)s' % msg).send() self.xmpp.add_event_handler('message', echo) - self.streamRecv(""" + self.stream_recv(""" Hi! """) - self.streamSendMessage(""" + self.stream_send_message(""" Thanks for sending: Hi! @@ -33,20 +33,20 @@ class TestStreamTester(SleekTest): def testComponentEcho(self): """Test that we can interact with a ComponentXMPP instance.""" - self.streamStart(mode='component') + self.stream_start(mode='component') def echo(msg): msg.reply('Thanks for sending: %(body)s' % msg).send() self.xmpp.add_event_handler('message', echo) - self.streamRecv(""" + self.stream_recv(""" Hi! """) - self.streamSendMessage(""" + self.stream_send_message(""" Thanks for sending: Hi! @@ -54,7 +54,7 @@ class TestStreamTester(SleekTest): def testSendStreamHeader(self): """Test that we can check a sent stream header.""" - self.streamStart(mode='client', skip=False) + self.stream_start(mode='client', skip=False) self.streamSendHeader(sto='localhost') suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamTester) -- cgit v1.2.3