summaryrefslogtreecommitdiff
path: root/tests/test_stanza_xep_0059.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-01-09 10:04:09 -0500
committerLance Stout <lancestout@gmail.com>2011-01-09 10:04:09 -0500
commit23e499998fc36b377e3adb77d3d59f885d94f21d (patch)
tree3dcef998633c65ea320cd2acfdaadb394e4ee773 /tests/test_stanza_xep_0059.py
parentc156a4f723073e1e6394803b5bb1613227947266 (diff)
parentacdf9e2d22dd604578f50d0a9b67c47e001da69f (diff)
downloadslixmpp-23e499998fc36b377e3adb77d3d59f885d94f21d.tar.gz
slixmpp-23e499998fc36b377e3adb77d3d59f885d94f21d.tar.bz2
slixmpp-23e499998fc36b377e3adb77d3d59f885d94f21d.tar.xz
slixmpp-23e499998fc36b377e3adb77d3d59f885d94f21d.zip
Merge branch 'develop' into roster
Diffstat (limited to 'tests/test_stanza_xep_0059.py')
-rw-r--r--tests/test_stanza_xep_0059.py106
1 files changed, 106 insertions, 0 deletions
diff --git a/tests/test_stanza_xep_0059.py b/tests/test_stanza_xep_0059.py
new file mode 100644
index 00000000..913436a6
--- /dev/null
+++ b/tests/test_stanza_xep_0059.py
@@ -0,0 +1,106 @@
+from sleekxmpp.test import *
+from sleekxmpp.plugins.xep_0059 import Set
+
+
+class TestSetStanzas(SleekTest):
+
+ def testSetFirstIndex(self):
+ s = Set()
+ s['first'] = 'id'
+ s.set_first_index('10')
+ self.check(s, """
+ <set xmlns="http://jabber.org/protocol/rsm">
+ <first index="10">id</first>
+ </set>
+ """)
+
+ def testGetFirstIndex(self):
+ xml_string = """
+ <set xmlns="http://jabber.org/protocol/rsm">
+ <first index="10">id</first>
+ </set>
+ """
+ s = Set(ET.fromstring(xml_string))
+ expected = '10'
+ self.failUnless(s['first_index'] == expected)
+
+ def testDelFirstIndex(self):
+ xml_string = """
+ <set xmlns="http://jabber.org/protocol/rsm">
+ <first index="10">id</first>
+ </set>
+ """
+ s = Set(ET.fromstring(xml_string))
+ del s['first_index']
+ self.check(s, """
+ <set xmlns="http://jabber.org/protocol/rsm">
+ <first>id</first>
+ </set>
+ """)
+
+ def testSetBefore(self):
+ s = Set()
+ s['before'] = True
+ self.check(s, """
+ <set xmlns="http://jabber.org/protocol/rsm">
+ <before />
+ </set>
+ """)
+
+ def testGetBefore(self):
+ xml_string = """
+ <set xmlns="http://jabber.org/protocol/rsm">
+ <before />
+ </set>
+ """
+ s = Set(ET.fromstring(xml_string))
+ expected = True
+ self.failUnless(s['before'] == expected)
+
+ def testGetBefore(self):
+ xml_string = """
+ <set xmlns="http://jabber.org/protocol/rsm">
+ <before />
+ </set>
+ """
+ s = Set(ET.fromstring(xml_string))
+ del s['before']
+ self.check(s, """
+ <set xmlns="http://jabber.org/protocol/rsm">
+ </set>
+ """)
+
+ def testSetBeforeVal(self):
+ s = Set()
+ s['before'] = 'id'
+ self.check(s, """
+ <set xmlns="http://jabber.org/protocol/rsm">
+ <before>id</before>
+ </set>
+ """)
+
+ def testGetBeforeVal(self):
+ xml_string = """
+ <set xmlns="http://jabber.org/protocol/rsm">
+ <before>id</before>
+ </set>
+ """
+ s = Set(ET.fromstring(xml_string))
+ expected = 'id'
+ self.failUnless(s['before'] == expected)
+
+ def testGetBeforeVal(self):
+ xml_string = """
+ <set xmlns="http://jabber.org/protocol/rsm">
+ <before>id</before>
+ </set>
+ """
+ s = Set(ET.fromstring(xml_string))
+ del s['before']
+ self.check(s, """
+ <set xmlns="http://jabber.org/protocol/rsm">
+ </set>
+ """)
+
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestSetStanzas)