summaryrefslogtreecommitdiff
path: root/tests/test_chatstates.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-06-27 17:40:06 -0400
committerLance Stout <lancestout@gmail.com>2010-06-27 17:47:32 -0400
commit7f8179d91e4f8ae3d58448e57f2e350ed6269fd0 (patch)
tree8bf26ca9b2878896641840b9ce5f1eab89e6482f /tests/test_chatstates.py
parent37ada498029c12459e5724ed27db92c828ce2a38 (diff)
downloadslixmpp-7f8179d91e4f8ae3d58448e57f2e350ed6269fd0.tar.gz
slixmpp-7f8179d91e4f8ae3d58448e57f2e350ed6269fd0.tar.bz2
slixmpp-7f8179d91e4f8ae3d58448e57f2e350ed6269fd0.tar.xz
slixmpp-7f8179d91e4f8ae3d58448e57f2e350ed6269fd0.zip
Refactored unit tests for XEP-0030, XEP-0033, and XEP-0085 to use the new SleekTest class.
Diffstat (limited to 'tests/test_chatstates.py')
-rw-r--r--tests/test_chatstates.py59
1 files changed, 28 insertions, 31 deletions
diff --git a/tests/test_chatstates.py b/tests/test_chatstates.py
index 8878e318..1e585be4 100644
--- a/tests/test_chatstates.py
+++ b/tests/test_chatstates.py
@@ -1,47 +1,44 @@
-import unittest
-from xml.etree import cElementTree as ET
-from sleekxmpp.xmlstream.matcher.stanzapath import StanzaPath
-from . import xmlcompare
+from sleektest import *
+import sleekxmpp.plugins.xep_0085 as xep_0085
-import sleekxmpp.plugins.xep_0085 as cs
-
-def stanzaPlugin(stanza, plugin):
- stanza.plugin_attrib_map[plugin.plugin_attrib] = plugin
- stanza.plugin_tag_map["{%s}%s" % (plugin.namespace, plugin.name)] = plugin
-
-class testchatstates(unittest.TestCase):
+class TestChatStates(SleekTest):
def setUp(self):
- self.cs = cs
- stanzaPlugin(self.cs.Message, self.cs.Active)
- stanzaPlugin(self.cs.Message, self.cs.Composing)
- stanzaPlugin(self.cs.Message, self.cs.Gone)
- stanzaPlugin(self.cs.Message, self.cs.Inactive)
- stanzaPlugin(self.cs.Message, self.cs.Paused)
-
- def try2Methods(self, xmlstring, msg):
- msg2 = self.cs.Message(None, self.cs.ET.fromstring(xmlstring))
- self.failUnless(xmlstring == str(msg) == str(msg2),
- "Two methods for creating stanza don't match")
+ self.stanzaPlugin(Message, xep_0085.Active)
+ self.stanzaPlugin(Message, xep_0085.Composing)
+ self.stanzaPlugin(Message, xep_0085.Gone)
+ self.stanzaPlugin(Message, xep_0085.Inactive)
+ self.stanzaPlugin(Message, xep_0085.Paused)
def testCreateChatState(self):
"""Testing creating chat states."""
- xmlstring = """<message><%s xmlns="http://jabber.org/protocol/chatstates" /></message>"""
-
- msg = self.cs.Message()
+
+ xmlstring = """
+ <message>
+ <%s xmlns="http://jabber.org/protocol/chatstates" />
+ </message>
+ """
+
+ msg = self.Message()
msg['chat_state'].active()
- self.try2Methods(xmlstring % 'active', msg)
+ self.checkMessage(msg, xmlstring % 'active',
+ use_values=False)
msg['chat_state'].composing()
- self.try2Methods(xmlstring % 'composing', msg)
+ self.checkMessage(msg, xmlstring % 'composing',
+ use_values=False)
+
msg['chat_state'].gone()
- self.try2Methods(xmlstring % 'gone', msg)
+ self.checkMessage(msg, xmlstring % 'gone',
+ use_values=False)
msg['chat_state'].inactive()
- self.try2Methods(xmlstring % 'inactive', msg)
+ self.checkMessage(msg, xmlstring % 'inactive',
+ use_values=False)
msg['chat_state'].paused()
- self.try2Methods(xmlstring % 'paused', msg)
+ self.checkMessage(msg, xmlstring % 'paused',
+ use_values=False)
-suite = unittest.TestLoader().loadTestsFromTestCase(testchatstates)
+suite = unittest.TestLoader().loadTestsFromTestCase(TestChatStates)