diff options
author | mathieui <mathieui@mathieui.net> | 2015-02-12 12:23:47 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2015-02-12 12:23:47 +0100 |
commit | 1e2665df19a866d5676abec566b9d8f190ecdc80 (patch) | |
tree | 9fe2f0c501d376291f3d9efc3e9550b34afbf6c7 /tests/test_stream_xep_0059.py | |
parent | 4d063e287e1bb2010d115325a3c8c6ca7c542bfc (diff) | |
download | slixmpp-1e2665df19a866d5676abec566b9d8f190ecdc80.tar.gz slixmpp-1e2665df19a866d5676abec566b9d8f190ecdc80.tar.bz2 slixmpp-1e2665df19a866d5676abec566b9d8f190ecdc80.tar.xz slixmpp-1e2665df19a866d5676abec566b9d8f190ecdc80.zip |
Update the test suite.
- monkey-patch our own monkey-patched idle_call to run events immediatly
rather than adding them to the event queue, and add a fake transport
with a fake socket.
- remove the test file related to xep_0059 as it relies on blocking
behavior, and comment out one xep_0030 test uses xep_0059
- remove many instances of threading and sleep()s because they do
nothing except waste time and introduce race conditions.
- keep exactly two sleep() in IoT xeps because they rely on timeouts
Diffstat (limited to 'tests/test_stream_xep_0059.py')
-rw-r--r-- | tests/test_stream_xep_0059.py | 163 |
1 files changed, 0 insertions, 163 deletions
diff --git a/tests/test_stream_xep_0059.py b/tests/test_stream_xep_0059.py deleted file mode 100644 index 6f929e8c..00000000 --- a/tests/test_stream_xep_0059.py +++ /dev/null @@ -1,163 +0,0 @@ -import threading - -import unittest -from slixmpp.test import SlixTest -from slixmpp.xmlstream import register_stanza_plugin -from slixmpp.plugins.xep_0030 import DiscoItems -from slixmpp.plugins.xep_0059 import ResultIterator, Set - - -class TestStreamSet(SlixTest): - - def setUp(self): - register_stanza_plugin(DiscoItems, Set) - - def tearDown(self): - self.stream_close() - - def iter(self, rev=False): - q = self.xmpp.Iq() - q['type'] = 'get' - it = ResultIterator(q, 'disco_items', amount='1', reverse=rev) - for i in it: - for j in i['disco_items']['items']: - self.items.append(j[0]) - - def testResultIterator(self): - self.items = [] - self.stream_start(mode='client') - t = threading.Thread(target=self.iter) - t.start() - self.send(""" - <iq type="get" id="2"> - <query xmlns="http://jabber.org/protocol/disco#items"> - <set xmlns="http://jabber.org/protocol/rsm"> - <max>1</max> - </set> - </query> - </iq> - """) - self.recv(""" - <iq type="result" id="2"> - <query xmlns="http://jabber.org/protocol/disco#items"> - <item jid="item1" /> - <set xmlns="http://jabber.org/protocol/rsm"> - <last>item1</last> - </set> - </query> - </iq> - """) - self.send(""" - <iq type="get" id="3"> - <query xmlns="http://jabber.org/protocol/disco#items"> - <set xmlns="http://jabber.org/protocol/rsm"> - <max>1</max> - <after>item1</after> - </set> - </query> - </iq> - """) - self.recv(""" - <iq type="result" id="3"> - <query xmlns="http://jabber.org/protocol/disco#items"> - <item jid="item2" /> - <set xmlns="http://jabber.org/protocol/rsm"> - <last>item2</last> - </set> - </query> - </iq> - """) - self.send(""" - <iq type="get" id="4"> - <query xmlns="http://jabber.org/protocol/disco#items"> - <set xmlns="http://jabber.org/protocol/rsm"> - <max>1</max> - <after>item2</after> - </set> - </query> - </iq> - """) - self.recv(""" - <iq type="result" id="4"> - <query xmlns="http://jabber.org/protocol/disco#items"> - <item jid="item2" /> - <set xmlns="http://jabber.org/protocol/rsm"> - </set> - </query> - </iq> - """) - t.join() - self.failUnless(self.items == ['item1', 'item2']) - - def testResultIteratorReverse(self): - self.items = [] - self.stream_start(mode='client') - - t = threading.Thread(target=self.iter, args=(True,)) - t.start() - - self.send(""" - <iq type="get" id="2"> - <query xmlns="http://jabber.org/protocol/disco#items"> - <set xmlns="http://jabber.org/protocol/rsm"> - <max>1</max> - <before /> - </set> - </query> - </iq> - """) - self.recv(""" - <iq type="result" id="2"> - <query xmlns="http://jabber.org/protocol/disco#items"> - <item jid="item2" /> - <set xmlns="http://jabber.org/protocol/rsm"> - <first>item2</first> - </set> - </query> - </iq> - """) - self.send(""" - <iq type="get" id="3"> - <query xmlns="http://jabber.org/protocol/disco#items"> - <set xmlns="http://jabber.org/protocol/rsm"> - <max>1</max> - <before>item2</before> - </set> - </query> - </iq> - """) - self.recv(""" - <iq type="result" id="3"> - <query xmlns="http://jabber.org/protocol/disco#items"> - <item jid="item1" /> - <set xmlns="http://jabber.org/protocol/rsm"> - <first>item1</first> - </set> - </query> - </iq> - """) - self.send(""" - <iq type="get" id="4"> - <query xmlns="http://jabber.org/protocol/disco#items"> - <set xmlns="http://jabber.org/protocol/rsm"> - <max>1</max> - <before>item1</before> - </set> - </query> - </iq> - """) - self.recv(""" - <iq type="result" id="4"> - <query xmlns="http://jabber.org/protocol/disco#items"> - <item jid="item1" /> - <set xmlns="http://jabber.org/protocol/rsm"> - </set> - </query> - </iq> - """) - - t.join() - self.failUnless(self.items == ['item2', 'item1']) - - -suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamSet) |