summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-10-07 10:58:13 -0400
committerLance Stout <lancestout@gmail.com>2010-10-07 10:58:13 -0400
commit0fffbb82000a1a6c3c23d62fedcbd8e8141f8994 (patch)
tree114c3767ccc13de3d0388b43cd357b90334f469a /tests
parent21c32c6e1cfd9b18e4c8320e0796e1d7e4b3f74c (diff)
downloadslixmpp-0fffbb82000a1a6c3c23d62fedcbd8e8141f8994.tar.gz
slixmpp-0fffbb82000a1a6c3c23d62fedcbd8e8141f8994.tar.bz2
slixmpp-0fffbb82000a1a6c3c23d62fedcbd8e8141f8994.tar.xz
slixmpp-0fffbb82000a1a6c3c23d62fedcbd8e8141f8994.zip
Unit test reorganization.
Moved SleekTest to sleekxmpp.test. Organized test suites by their focus. - Suites focused on testing stanza objects are named test_stanza_X.py - Suites focused on testing stream behavior are name test_stream_X.py
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py0
-rw-r--r--tests/sleektest.py650
-rw-r--r--tests/test_events.py3
-rw-r--r--tests/test_jid.py4
-rw-r--r--tests/test_stanza_base.py (renamed from tests/test_stanzabase.py)4
-rw-r--r--tests/test_stanza_element.py (renamed from tests/test_elementbase.py)3
-rw-r--r--tests/test_stanza_error.py (renamed from tests/test_errorstanzas.py)3
-rw-r--r--tests/test_stanza_gmail.py (renamed from tests/test_gmail.py)24
-rw-r--r--tests/test_stanza_iq.py (renamed from tests/test_iqstanzas.py)2
-rw-r--r--tests/test_stanza_message.py (renamed from tests/test_messagestanzas.py)2
-rw-r--r--tests/test_stanza_presence.py (renamed from tests/test_presencestanzas.py)3
-rw-r--r--tests/test_stanza_roster.py (renamed from tests/test_roster.py)2
-rw-r--r--tests/test_stanza_xep_0004.py (renamed from tests/test_forms.py)2
-rw-r--r--tests/test_stanza_xep_0030.py (renamed from tests/test_disco.py)2
-rw-r--r--tests/test_stanza_xep_0033.py (renamed from tests/test_addresses.py)2
-rw-r--r--tests/test_stanza_xep_0060.py (renamed from tests/test_pubsubstanzas.py)2
-rw-r--r--tests/test_stanza_xep_0085.py (renamed from tests/test_chatstates.py)2
-rw-r--r--tests/test_stream.py (renamed from tests/test_streamtester.py)4
-rw-r--r--tests/test_stream_handlers.py (renamed from tests/test_handlers.py)4
-rw-r--r--tests/test_tostring.py2
20 files changed, 36 insertions, 684 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/tests/__init__.py
+++ /dev/null
diff --git a/tests/sleektest.py b/tests/sleektest.py
deleted file mode 100644
index 28901877..00000000
--- a/tests/sleektest.py
+++ /dev/null
@@ -1,650 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2010 Nathanael C. Fritz, Lance J.T. Stout
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-
-import unittest
-import socket
-try:
- import queue
-except ImportError:
- import Queue as queue
-
-import sleekxmpp
-from sleekxmpp import ClientXMPP, ComponentXMPP
-from sleekxmpp.stanza import Message, Iq, Presence
-from sleekxmpp.xmlstream.stanzabase import registerStanzaPlugin, ET
-from sleekxmpp.xmlstream.tostring import tostring
-
-
-class TestSocket(object):
-
- """
- A dummy socket that reads and writes to queues instead
- of an actual networking socket.
-
- Methods:
- 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):
- """
- Create a new test socket.
-
- Arguments:
- Same as arguments for socket.socket
- """
- self.socket = socket.socket(*args, **kwargs)
- self.recv_queue = queue.Queue()
- self.send_queue = queue.Queue()
-
- def __getattr__(self, name):
- """
- Return attribute values of internal, dummy socket.
-
- Some attributes and methods are disabled to prevent the
- socket from connecting to the network.
-
- Arguments:
- name -- Name of the attribute requested.
- """
-
- def dummy(*args):
- """Method to do nothing and prevent actual socket connections."""
- return None
-
- overrides = {'connect': dummy,
- 'close': dummy,
- 'shutdown': dummy}
-
- return overrides.get(name, getattr(self.socket, name))
-
- # ------------------------------------------------------------------
- # Testing Interface
-
- def next_sent(self, timeout=None):
- """
- Get the next stanza that has been 'sent'.
-
- Arguments:
- timeout -- Optional timeout for waiting for a new value.
- """
- args = {'block': False}
- if timeout is not None:
- args = {'block': True, 'timeout': timeout}
- try:
- return self.send_queue.get(**args)
- except:
- return None
-
- def recv_data(self, data):
- """
- Add data to the receiving queue.
-
- Arguments:
- data -- String data to 'write' to the socket to be received
- by the XMPP client.
- """
- self.recv_queue.put(data)
-
- # ------------------------------------------------------------------
- # Socket Interface
-
- def recv(self, *args, **kwargs):
- """
- Read a value from the received queue.
-
- Arguments:
- Placeholders. Same as for socket.Socket.recv.
- """
- return self.read(block=True)
-
- def send(self, data):
- """
- Send data by placing it in the send queue.
-
- Arguments:
- data -- String value to write.
- """
- self.send_queue.put(data)
-
- # ------------------------------------------------------------------
- # File Socket
-
- def makefile(self, *args, **kwargs):
- """
- File socket version to use with ElementTree.
-
- Arguments:
- Placeholders, same as socket.Socket.makefile()
- """
- return self
-
- def read(self, block=True, timeout=None, **kwargs):
- """
- Implement the file socket interface.
-
- Arguments:
- block -- Indicate if the read should block until a
- value is ready.
- timeout -- Time in seconds a block should last before
- returning None.
- """
- if timeout is not None:
- block = True
- try:
- return self.recv_queue.get(block, timeout)
- except:
- return None
-
-
-class SleekTest(unittest.TestCase):
-
- """
- A SleekXMPP specific TestCase class that provides
- 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.
- 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.
- """
-
- # ------------------------------------------------------------------
- # Shortcut methods for creating stanza objects
-
- def Message(self, *args, **kwargs):
- """
- Create a Message stanza.
-
- Uses same arguments as StanzaBase.__init__
-
- Arguments:
- xml -- An XML object to use for the Message's values.
- """
- return Message(None, *args, **kwargs)
-
- def Iq(self, *args, **kwargs):
- """
- Create an Iq stanza.
-
- Uses same arguments as StanzaBase.__init__
-
- Arguments:
- xml -- An XML object to use for the Iq's values.
- """
- return Iq(None, *args, **kwargs)
-
- def Presence(self, *args, **kwargs):
- """
- Create a Presence stanza.
-
- Uses same arguments as StanzaBase.__init__
-
- Arguments:
- xml -- An XML object to use for the Iq's values.
- """
- return Presence(None, *args, **kwargs)
-
- # ------------------------------------------------------------------
- # Methods for comparing stanza objects to XML strings
-
- 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.
-
- If use_values is False, test using getStanzaValues() and
- setStanzaValues() will not be used.
-
- Some stanzas provide default values for some interfaces, but
- these defaults can be problematic for testing since they can easily
- be forgotten when supplying the XML string. A list of interfaces that
- use defaults may be provided and the generated stanzas will use the
- default values for those interfaces if needed.
-
- However, correcting the supplied XML is not possible for interfaces
- that add or remove XML elements. Only interfaces that map to XML
- attributes may be set using the defaults parameter. The supplied XML
- must take into account any extra elements that are included by default.
-
- Arguments:
- stanza_class -- The class of the stanza being tested.
- stanza -- The stanza object to test.
- xml_string -- A string version of the correct XML expected.
- defaults -- A list of stanza interfaces that have default
- values. These interfaces will be set to their
- defaults for the given and generated stanzas to
- prevent unexpected test failures.
- use_values -- Indicates if testing using getStanzaValues() and
- setStanzaValues() should be used. Defaults to
- True.
- """
- xml = ET.fromstring(xml_string)
-
- # Ensure that top level namespaces are used, even if they
- # were not provided.
- self.fix_namespaces(stanza.xml, 'jabber:client')
- self.fix_namespaces(xml, 'jabber:client')
-
- stanza2 = stanza_class(xml=xml)
-
- if use_values:
- # Using getStanzaValues() and setStanzaValues() will add
- # XML for any interface that has a default value. We need
- # to set those defaults on the existing stanzas and XML
- # so that they will compare correctly.
- default_stanza = stanza_class()
- if defaults is None:
- defaults = []
- for interface in defaults:
- stanza[interface] = stanza[interface]
- stanza2[interface] = stanza2[interface]
- # Can really only automatically add defaults for top
- # level attribute values. Anything else must be accounted
- # for in the provided XML string.
- if interface not in xml.attrib:
- if interface in default_stanza.xml.attrib:
- value = default_stanza.xml.attrib[interface]
- xml.attrib[interface] = value
-
- values = stanza2.getStanzaValues()
- stanza3 = stanza_class()
- stanza3.setStanzaValues(values)
-
- debug = "Three methods for creating stanzas do not match.\n"
- debug += "Given XML:\n%s\n" % tostring(xml)
- debug += "Given stanza:\n%s\n" % tostring(stanza.xml)
- debug += "Generated stanza:\n%s\n" % tostring(stanza2.xml)
- debug += "Second generated stanza:\n%s\n" % tostring(stanza3.xml)
- result = self.compare(xml, stanza.xml, stanza2.xml, stanza3.xml)
- else:
- debug = "Two methods for creating stanzas do not match.\n"
- debug += "Given XML:\n%s\n" % tostring(xml)
- debug += "Given stanza:\n%s\n" % tostring(stanza.xml)
- debug += "Generated stanza:\n%s\n" % tostring(stanza2.xml)
- result = self.compare(xml, stanza.xml, stanza2.xml)
-
- self.failUnless(result, debug)
-
- def check_message(self, msg, xml_string, use_values=True):
- """
- Create and compare several message stanza objects to a
- correct XML string.
-
- If use_values is False, the test using getStanzaValues() and
- setStanzaValues() will not be used.
-
- Arguments:
- msg -- The Message stanza object to check.
- xml_string -- The XML contents to compare against.
- use_values -- Indicates if the test using getStanzaValues
- and setStanzaValues should be used. Defaults
- to True.
- """
-
- return self.check_stanza(Message, msg, xml_string,
- defaults=['type'],
- use_values=use_values)
-
- def check_iq(self, iq, xml_string, use_values=True):
- """
- Create and compare several iq stanza objects to a
- correct XML string.
-
- If use_values is False, the test using getStanzaValues() and
- setStanzaValues() will not be used.
-
- Arguments:
- iq -- The Iq stanza object to check.
- xml_string -- The XML contents to compare against.
- use_values -- Indicates if the test using getStanzaValues
- and setStanzaValues should be used. Defaults
- to True.
- """
- return self.check_stanza(Iq, iq, xml_string, use_values=use_values)
-
- def check_presence(self, pres, xml_string, use_values=True):
- """
- Create and compare several presence stanza objects to a
- correct XML string.
-
- If use_values is False, the test using getStanzaValues() and
- setStanzaValues() will not be used.
-
- Arguments:
- iq -- The Iq stanza object to check.
- xml_string -- The XML contents to compare against.
- use_values -- Indicates if the test using getStanzaValues
- and setStanzaValues should be used. Defaults
- to True.
- """
- return self.check_stanza(Presence, pres, xml_string,
- defaults=['priority'],
- use_values=use_values)
-
- # ------------------------------------------------------------------
- # Methods for simulating stanza streams.
-
- def stream_start(self, mode='client', skip=True, header=None):
- """
- Initialize an XMPP client or component using a dummy XML stream.
-
- Arguments:
- mode -- Either 'client' or 'component'. Defaults to 'client'.
- skip -- Indicates if the first item in the sent queue (the
- stream header) should be removed. Tests that wish
- to test initializing the stream should set this to
- False. Otherwise, the default of True should be used.
- """
- if mode == 'client':
- self.xmpp = ClientXMPP('tester@localhost', 'test')
- elif mode == 'component':
- self.xmpp = ComponentXMPP('tester.localhost', 'test',
- 'localhost', 8888)
- else:
- raise ValueError("Unknown XMPP connection mode.")
-
- self.xmpp.setSocket(TestSocket())
- self.xmpp.state.set('reconnect', False)
- self.xmpp.state.set('is client', True)
- self.xmpp.state.set('connected', True)
-
- # Must have the stream header ready for xmpp.process() to work.
- if not header:
- header = self.xmpp.stream_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.next_sent(timeout=0.01)
- if mode == 'component':
- self.xmpp.socket.next_sent(timeout=0.01)
-
- def stream_recv(self, data):
- """
- Pass data to the dummy XMPP client as if it came from an XMPP server.
-
- Arguments:
- data -- String stanza XML to be received and processed by the
- XMPP client or component.
- """
- data = str(data)
- self.xmpp.socket.recv_data(data)
-
- def stream_make_header(self, sto='',
- sfrom='',
- sid='',
- stream_ns="http://etherx.jabber.org/streams",
- default_ns="jabber:client",
- version="1.0",
- xml_header=True):
- """
- Create a stream header to be received by the test XMPP agent.
-
- The header must be saved and passed to stream_start.
-
- Arguments:
- sto -- The recipient of the stream header.
- sfrom -- The agent sending the stream header.
- sid -- The stream's id.
- stream_ns -- The namespace of the stream's root element.
- default_ns -- The default stanza namespace.
- version -- The stream version.
- xml_header -- Indicates if the XML version header should be
- appended before the stream header.
- """
- header = '<stream:stream %s>'
- parts = []
- if xml_header:
- header = '<?xml version="1.0"?>' + header
- if sto:
- parts.append('to="%s"' % sto)
- if sfrom:
- parts.append('from="%s"' % sfrom)
- if sid:
- parts.append('id="%s"' % sid)
- parts.append('version="%s"' % version)
- parts.append('xmlns:stream="%s"' % stream_ns)
- parts.append('xmlns="%s"' % default_ns)
- return header % ' '.join(parts)
-
- 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.
-
- Arguments:
- sto -- The recipient of the stream header.
- sfrom -- The agent sending the stream header.
- sid -- The stream's id.
- stream_ns -- The namespace of the stream's root element.
- default_ns -- The default stanza namespace.
- version -- The stream version.
- xml_header -- Indicates if the XML version header should be
- appended before the stream header.
- timeout -- Length of time to wait in seconds for a
- response.
- """
- 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.")
-
- # Apply closing elements so that we can construct
- # XML objects for comparison.
- header2 = header + '</stream:stream>'
- sent_header2 = sent_header + '</stream:stream>'
-
- xml = ET.fromstring(header2)
- sent_xml = ET.fromstring(sent_header2)
-
- self.failUnless(
- self.compare(xml, sent_xml),
- "Stream headers do not match:\nDesired:\n%s\nSent:\n%s" % (
- header, sent_header))
-
- 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 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 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.next_sent(timeout)
- self.check_message(data, sent, use_values)
-
- 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 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 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.next_sent(timeout)
- self.check_iq(data, sent, use_values)
-
- 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 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 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.next_sent(timeout)
- self.check_presence(data, sent, use_values)
-
- def stream_close(self):
- """
- Disconnect the dummy XMPP client.
-
- 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.recv_data(self.xmpp.stream_footer)
-
- # ------------------------------------------------------------------
- # XML Comparison and Cleanup
-
- def fix_namespaces(self, xml, ns):
- """
- Assign a namespace to an element and any children that
- don't have a namespace.
-
- Arguments:
- xml -- The XML object to fix.
- ns -- The namespace to add to the XML object.
- """
- if xml.tag.startswith('{'):
- return
- xml.tag = '{%s}%s' % (ns, xml.tag)
- for child in xml.getchildren():
- self.fix_namespaces(child, ns)
-
- def compare(self, xml, *other):
- """
- Compare XML objects.
-
- Arguments:
- xml -- The XML object to compare against.
- *other -- The list of XML objects to compare.
- """
- if not other:
- return False
-
- # Compare multiple objects
- if len(other) > 1:
- for xml2 in other:
- if not self.compare(xml, xml2):
- return False
- return True
-
- other = other[0]
-
- # Step 1: Check tags
- if xml.tag != other.tag:
- return False
-
- # Step 2: Check attributes
- if xml.attrib != other.attrib:
- return False
-
- # Step 3: Check text
- if xml.text is None:
- xml.text = ""
- if other.text is None:
- other.text = ""
- xml.text = xml.text.strip()
- other.text = other.text.strip()
-
- if xml.text != other.text:
- return False
-
- # Step 4: Recursively check children
- for child in xml:
- child2s = other.findall("%s" % child.tag)
- if child2s is None:
- return False
- for child2 in child2s:
- if self.compare(child, child2):
- break
- else:
- return False
-
- # Everything matches
- return True
diff --git a/tests/test_events.py b/tests/test_events.py
index d9d80c30..ea4cf8a4 100644
--- a/tests/test_events.py
+++ b/tests/test_events.py
@@ -1,6 +1,5 @@
-import sleekxmpp
import time
-from . sleektest import *
+from sleekxmpp.test import *
class TestEvents(SleekTest):
diff --git a/tests/test_jid.py b/tests/test_jid.py
index cddac424..45047313 100644
--- a/tests/test_jid.py
+++ b/tests/test_jid.py
@@ -1,6 +1,7 @@
-from . sleektest import *
+from sleekxmpp.test import *
from sleekxmpp.xmlstream.jid import JID
+
class TestJIDClass(SleekTest):
def testJIDfromfull(self):
j = JID('user@someserver/some/resource')
@@ -23,4 +24,5 @@ class TestJIDClass(SleekTest):
self.assertEqual(j.full, 'user@someserver/some/resource', "Full does not match")
self.assertEqual(str(j), 'user@someserver/some/resource', "String does not match")
+
suite = unittest.TestLoader().loadTestsFromTestCase(TestJIDClass)
diff --git a/tests/test_stanzabase.py b/tests/test_stanza_base.py
index 682068d9..9bd326b6 100644
--- a/tests/test_stanzabase.py
+++ b/tests/test_stanza_base.py
@@ -1,7 +1,7 @@
-from . sleektest import *
-import sleekxmpp
+from sleekxmpp.test import *
from sleekxmpp.xmlstream.stanzabase import ET, StanzaBase
+
class TestStanzaBase(SleekTest):
def testTo(self):
diff --git a/tests/test_elementbase.py b/tests/test_stanza_element.py
index 19794c90..c157e0a8 100644
--- a/tests/test_elementbase.py
+++ b/tests/test_stanza_element.py
@@ -1,6 +1,7 @@
-from . sleektest import *
+from sleekxmpp.test import *
from sleekxmpp.xmlstream.stanzabase import ElementBase
+
class TestElementBase(SleekTest):
def testFixNs(self):
diff --git a/tests/test_errorstanzas.py b/tests/test_stanza_error.py
index a883b7ef..f76ac62d 100644
--- a/tests/test_errorstanzas.py
+++ b/tests/test_stanza_error.py
@@ -1,4 +1,5 @@
-from . sleektest import *
+from sleekxmpp.test import *
+
class TestErrorStanzas(SleekTest):
diff --git a/tests/test_gmail.py b/tests/test_stanza_gmail.py
index 5636e877..5c31a4e2 100644
--- a/tests/test_gmail.py
+++ b/tests/test_stanza_gmail.py
@@ -1,4 +1,4 @@
-from . sleektest import *
+from sleekxmpp.test import *
import sleekxmpp.plugins.gmail_notify as gmail
@@ -8,10 +8,10 @@ class TestGmail(SleekTest):
registerStanzaPlugin(Iq, gmail.GmailQuery)
registerStanzaPlugin(Iq, gmail.MailBox)
registerStanzaPlugin(Iq, gmail.NewMail)
-
+
def testCreateQuery(self):
"""Testing querying Gmail for emails."""
-
+
iq = self.Iq()
iq['type'] = 'get'
iq['gmail']['search'] = 'is:starred'
@@ -29,20 +29,20 @@ class TestGmail(SleekTest):
def testMailBox(self):
"""Testing reading from Gmail mailbox result"""
-
+
# Use the example from Google's documentation at
# http://code.google.com/apis/talk/jep_extensions/gmail.html#notifications
xml = ET.fromstring("""
<iq type="result">
<mailbox xmlns="google:mail:notify"
result-time='1118012394209'
- url='http://mail.google.com/mail'
- total-matched='95'
+ url='http://mail.google.com/mail'
+ total-matched='95'
total-estimate='0'>
- <mail-thread-info tid='1172320964060972012'
+ <mail-thread-info tid='1172320964060972012'
participation='1'
- messages='28'
- date='1118012394209'
+ messages='28'
+ date='1118012394209'
url='http://mail.google.com/mail?view=cv'>
<senders>
<sender name='Me' address='romeo@gmail.com' originator='1' />
@@ -63,7 +63,7 @@ class TestGmail(SleekTest):
self.failUnless(mailbox['url'] == 'http://mail.google.com/mail', "url doesn't match")
self.failUnless(mailbox['matched'] == '95', "total-matched incorrect")
self.failUnless(mailbox['estimate'] == False, "total-estimate incorrect")
- self.failUnless(len(mailbox['threads']) == 1, "could not extract message threads")
+ self.failUnless(len(mailbox['threads']) == 1, "could not extract message threads")
thread = mailbox['threads'][0]
self.failUnless(thread['tid'] == '1172320964060972012', "thread tid doesn't match")
@@ -81,8 +81,8 @@ class TestGmail(SleekTest):
self.failUnless(sender1['address'] == 'romeo@gmail.com', "sender address doesn't match")
self.failUnless(sender1['originator'] == True, "sender originator incorrect")
self.failUnless(sender1['unread'] == False, "sender unread incorrectly True")
-
- sender2 = thread['senders'][2]
+
+ sender2 = thread['senders'][2]
self.failUnless(sender2['unread'] == True, "sender unread incorrectly False")
suite = unittest.TestLoader().loadTestsFromTestCase(TestGmail)
diff --git a/tests/test_iqstanzas.py b/tests/test_stanza_iq.py
index 197bc001..3f6ce8d7 100644
--- a/tests/test_iqstanzas.py
+++ b/tests/test_stanza_iq.py
@@ -1,4 +1,4 @@
-from . sleektest import *
+from sleekxmpp.test import *
from sleekxmpp.xmlstream.stanzabase import ET
diff --git a/tests/test_messagestanzas.py b/tests/test_stanza_message.py
index d57f5ad4..d4f4d8d0 100644
--- a/tests/test_messagestanzas.py
+++ b/tests/test_stanza_message.py
@@ -1,4 +1,4 @@
-from . sleektest import *
+from sleekxmpp.test import *
from sleekxmpp.stanza.message import Message
from sleekxmpp.stanza.htmlim import HTMLIM
diff --git a/tests/test_presencestanzas.py b/tests/test_stanza_presence.py
index 2452df4f..ad357ec3 100644
--- a/tests/test_presencestanzas.py
+++ b/tests/test_stanza_presence.py
@@ -1,5 +1,4 @@
-import sleekxmpp
-from . sleektest import *
+from sleekxmpp.test import *
from sleekxmpp.stanza.presence import Presence
diff --git a/tests/test_roster.py b/tests/test_stanza_roster.py
index f210551d..a0e57987 100644
--- a/tests/test_roster.py
+++ b/tests/test_stanza_roster.py
@@ -1,4 +1,4 @@
-from . sleektest import *
+from sleekxmpp.test import *
from sleekxmpp.stanza.roster import Roster
diff --git a/tests/test_forms.py b/tests/test_stanza_xep_0004.py
index 67b0f6a8..835f0dd6 100644
--- a/tests/test_forms.py
+++ b/tests/test_stanza_xep_0004.py
@@ -1,4 +1,4 @@
-from . sleektest import *
+from sleekxmpp.test import *
import sleekxmpp.plugins.xep_0004 as xep_0004
diff --git a/tests/test_disco.py b/tests/test_stanza_xep_0030.py
index f65fdaf4..bb7ee6a3 100644
--- a/tests/test_disco.py
+++ b/tests/test_stanza_xep_0030.py
@@ -1,4 +1,4 @@
-from . sleektest import *
+from sleekxmpp.test import *
import sleekxmpp.plugins.xep_0030 as xep_0030
diff --git a/tests/test_addresses.py b/tests/test_stanza_xep_0033.py
index 5c510c78..90f6374a 100644
--- a/tests/test_addresses.py
+++ b/tests/test_stanza_xep_0033.py
@@ -1,4 +1,4 @@
-from . sleektest import *
+from sleekxmpp.test import *
import sleekxmpp.plugins.xep_0033 as xep_0033
diff --git a/tests/test_pubsubstanzas.py b/tests/test_stanza_xep_0060.py
index 42a1b52e..32ee37a1 100644
--- a/tests/test_pubsubstanzas.py
+++ b/tests/test_stanza_xep_0060.py
@@ -1,4 +1,4 @@
-from . sleektest import *
+from sleekxmpp.test import *
import sleekxmpp.plugins.xep_0004 as xep_0004
import sleekxmpp.plugins.stanza_pubsub as pubsub
diff --git a/tests/test_chatstates.py b/tests/test_stanza_xep_0085.py
index d5e3979a..5e63530f 100644
--- a/tests/test_chatstates.py
+++ b/tests/test_stanza_xep_0085.py
@@ -1,4 +1,4 @@
-from . sleektest import *
+from sleekxmpp.test import *
import sleekxmpp.plugins.xep_0085 as xep_0085
class TestChatStates(SleekTest):
diff --git a/tests/test_streamtester.py b/tests/test_stream.py
index 9bc9de67..3fbf86e6 100644
--- a/tests/test_streamtester.py
+++ b/tests/test_stream.py
@@ -1,4 +1,4 @@
-from . sleektest import *
+from sleekxmpp.test import *
import sleekxmpp.plugins.xep_0033 as xep_0033
@@ -55,6 +55,6 @@ class TestStreamTester(SleekTest):
def testSendStreamHeader(self):
"""Test that we can check a sent stream header."""
self.stream_start(mode='client', skip=False)
- self.streamSendHeader(sto='localhost')
+ self.stream_send_header(sto='localhost')
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamTester)
diff --git a/tests/test_handlers.py b/tests/test_stream_handlers.py
index 70eb0248..8c05572a 100644
--- a/tests/test_handlers.py
+++ b/tests/test_stream_handlers.py
@@ -1,8 +1,8 @@
-from . sleektest import *
-import sleekxmpp
+from sleekxmpp.test import *
from sleekxmpp.xmlstream.handler import *
from sleekxmpp.xmlstream.matcher import *
+
class TestHandlers(SleekTest):
"""
Test using handlers and waiters.
diff --git a/tests/test_tostring.py b/tests/test_tostring.py
index 2999949a..45f405ce 100644
--- a/tests/test_tostring.py
+++ b/tests/test_tostring.py
@@ -1,4 +1,4 @@
-from . sleektest import *
+from sleekxmpp.test import *
from sleekxmpp.stanza import Message
from sleekxmpp.xmlstream.stanzabase import ET
from sleekxmpp.xmlstream.tostring import tostring, xml_escape