summaryrefslogtreecommitdiff
path: root/tests/sleektest.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-07-19 23:58:33 -0400
committerLance Stout <lancestout@gmail.com>2010-07-19 23:58:33 -0400
commit14f1c3ba512b17942e1925cc4e610d3558356ea7 (patch)
tree88f759f2cc64263b1f8c6036fb44b962d58344c3 /tests/sleektest.py
parent278a8bb443e1fda262fec1cd3999137b7971d61b (diff)
downloadslixmpp-14f1c3ba512b17942e1925cc4e610d3558356ea7.tar.gz
slixmpp-14f1c3ba512b17942e1925cc4e610d3558356ea7.tar.bz2
slixmpp-14f1c3ba512b17942e1925cc4e610d3558356ea7.tar.xz
slixmpp-14f1c3ba512b17942e1925cc4e610d3558356ea7.zip
Updated SleekTest to implement the checkPresence method.
Also, removed unnecessary TestStream class and shortened timeout during stream connection.
Diffstat (limited to 'tests/sleektest.py')
-rw-r--r--tests/sleektest.py37
1 files changed, 29 insertions, 8 deletions
diff --git a/tests/sleektest.py b/tests/sleektest.py
index d5696d0b..9f4198ec 100644
--- a/tests/sleektest.py
+++ b/tests/sleektest.py
@@ -77,12 +77,6 @@ class TestSocket(object):
except:
return None
-class TestStream(object):
- """Dummy class to pass a stream object to created stanzas"""
-
- def __init__(self):
- self.default_ns = 'jabber:client'
-
class SleekTest(unittest.TestCase):
"""
@@ -186,7 +180,34 @@ class SleekTest(unittest.TestCase):
If use_values is False, the test using getValues() and
setValues() will not be used.
"""
- pass
+ self.fix_namespaces(pres.xml, 'jabber:client')
+ debug = "Given Stanza:\n%s\n" % ET.tostring(pres.xml)
+
+ xml = ET.fromstring(xml_string)
+ self.fix_namespaces(xml, 'jabber:client')
+ debug += "XML String:\n%s\n" % ET.tostring(xml)
+
+ pres2 = self.Presence(xml)
+ debug += "Constructed Stanza:\n%s\n" % ET.tostring(pres2.xml)
+
+ # Ugly, but 'priority' has a default value and need to make
+ # sure it is set
+ pres['priority'] = pres['priority']
+ pres2['priority'] = pres2['priority']
+
+ if use_values:
+ values = pres.getStanzaValues()
+ pres3 = self.Presence()
+ pres3.setStanzaValues(values)
+
+ debug += "Second Constructed Stanza:\n%s\n" % ET.tostring(pres3.xml)
+ debug = "Three methods for creating stanza do not match:\n" + debug
+ self.failUnless(self.compare([xml, pres.xml, pres2.xml, pres3.xml]),
+ debug)
+ else:
+ debug = "Two methods for creating stanza do not match:\n" + debug
+ self.failUnless(self.compare([xml, pres.xml, pres2.xml]), debug)
+
# ------------------------------------------------------------------
# Methods for simulating stanza streams.
@@ -208,7 +229,7 @@ class SleekTest(unittest.TestCase):
self.xmpp.process(threaded=True)
if skip:
# Clear startup stanzas
- self.xmpp.socket.nextSent(timeout=1)
+ self.xmpp.socket.nextSent(timeout=0.1)
def streamRecv(self, data):
data = str(data)