diff options
Diffstat (limited to 'tests')
46 files changed, 407 insertions, 907 deletions
diff --git a/tests/live_multiple_streams.py b/tests/live_multiple_streams.py index 69ee74c4..b026dd55 100644 --- a/tests/live_multiple_streams.py +++ b/tests/live_multiple_streams.py @@ -1,16 +1,16 @@ import logging -from sleekxmpp.test import * +from slixmpp.test import * -class TestMultipleStreams(SleekTest): +class TestMultipleStreams(SlixTest): """ Test that we can test a live stanza stream. """ def setUp(self): - self.client1 = SleekTest() - self.client2 = SleekTest() + self.client1 = SlixTest() + self.client2 = SlixTest() def tearDown(self): self.client1.stream_close() diff --git a/tests/live_test.py b/tests/live_test.py index b71930af..327657a7 100644 --- a/tests/live_test.py +++ b/tests/live_test.py @@ -1,9 +1,9 @@ import logging -from sleekxmpp.test import * +from slixmpp.test import * -class TestLiveStream(SleekTest): +class TestLiveStream(SlixTest): """ Test that we can test a live stanza stream. """ diff --git a/tests/test_events.py b/tests/test_events.py index a41ed017..65494d80 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -1,9 +1,9 @@ import time import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestEvents(SleekTest): +class TestEvents(SlixTest): def setUp(self): self.stream_start() @@ -22,9 +22,6 @@ class TestEvents(SleekTest): self.xmpp.event("test_event") self.xmpp.event("test_event") - # Give the event queue time to process. - time.sleep(0.1) - msg = "Event was not triggered the correct number of times: %s" self.failUnless(happened == [True, True], msg) @@ -43,9 +40,6 @@ class TestEvents(SleekTest): # Should not trigger because it was deleted self.xmpp.event("test_event", {}) - # Give the event queue time to process. - time.sleep(0.1) - msg = "Event was not triggered the correct number of times: %s" self.failUnless(happened == [True], msg % happened) @@ -66,9 +60,6 @@ class TestEvents(SleekTest): self.xmpp.add_event_handler("test_event", handletestevent) self.xmpp.event("test_event", {}) - # Give the event queue time to process. - time.sleep(0.1) - msg = "Event was not triggered the correct number of times: %s" self.failUnless(happened == [True, True], msg % happened) @@ -86,9 +77,6 @@ class TestEvents(SleekTest): # Should not trigger because it was deleted self.xmpp.event("test_event", {}) - # Give the event queue time to process. - time.sleep(0.1) - msg = "Event was not triggered the correct number of times: %s" self.failUnless(happened == [True], msg % happened) diff --git a/tests/test_jid.py b/tests/test_jid.py index ed2aeea9..1233eb37 100644 --- a/tests/test_jid.py +++ b/tests/test_jid.py @@ -1,12 +1,12 @@ # -*- encoding: utf8 -*- from __future__ import unicode_literals import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp import JID, InvalidJID -from sleekxmpp.jid import nodeprep +from slixmpp.test import SlixTest +from slixmpp import JID, InvalidJID +from slixmpp.jid import nodeprep -class TestJIDClass(SleekTest): +class TestJIDClass(SlixTest): """Verify that the JID class can parse and manipulate JIDs.""" @@ -138,143 +138,149 @@ class TestJIDClass(SleekTest): def testJIDInequality(self): jid1 = JID('user@domain/resource') jid2 = JID('otheruser@domain/resource') - self.assertFalse(jid1 == jid2, "Same JIDs are not considered equal") - self.assertTrue(jid1 != jid2, "Same JIDs are considered not equal") + self.assertFalse(jid1 == jid2, "Different JIDs are considered equal") + self.assertTrue(jid1 != jid2, "Different JIDs are considered equal") def testZeroLengthDomain(self): - self.assertRaises(InvalidJID, JID, domain='') + jid1 = JID('') + jid2 = JID() + self.assertTrue(jid1 == jid2, "Empty JIDs are not considered equal") + self.assertTrue(jid1.domain == '', "Empty JID’s domain part not empty") + self.assertTrue(jid1.full == '', "Empty JID’s full part not empty") + + self.assertRaises(InvalidJID, JID, 'user@') + self.assertRaises(InvalidJID, JID, '/resource') self.assertRaises(InvalidJID, JID, 'user@/resource') def testZeroLengthLocalPart(self): - self.assertRaises(InvalidJID, JID, local='', domain='test.com') + self.assertRaises(InvalidJID, JID, '@test.com') + self.assertRaises(InvalidJID, JID, '@test.com/resource') + + def testZeroLengthNodeDomain(self): self.assertRaises(InvalidJID, JID, '@/test.com') def testZeroLengthResource(self): - self.assertRaises(InvalidJID, JID, domain='test.com', resource='') self.assertRaises(InvalidJID, JID, 'test.com/') + self.assertRaises(InvalidJID, JID, 'user@test.com/') def test1023LengthDomain(self): domain = ('a.' * 509) + 'a.com' - jid1 = JID(domain=domain) - jid2 = JID('user@%s/resource' % domain) + jid = JID('user@%s/resource' % domain) def test1023LengthLocalPart(self): local = 'a' * 1023 - jid1 = JID(local=local, domain='test.com') - jid2 = JID('%s@test.com' % local) + jid = JID('%s@test.com' % local) def test1023LengthResource(self): resource = 'r' * 1023 - jid1 = JID(domain='test.com', resource=resource) - jid2 = JID('test.com/%s' % resource) + jid = JID('test.com/%s' % resource) def test1024LengthDomain(self): domain = ('a.' * 509) + 'aa.com' - self.assertRaises(InvalidJID, JID, domain=domain) self.assertRaises(InvalidJID, JID, 'user@%s/resource' % domain) + self.assertRaises(InvalidJID, JID, 'user@%s' % domain) + self.assertRaises(InvalidJID, JID, '%s/resource' % domain) + self.assertRaises(InvalidJID, JID, domain) def test1024LengthLocalPart(self): local = 'a' * 1024 - self.assertRaises(InvalidJID, JID, local=local, domain='test.com') - self.assertRaises(InvalidJID, JID, '%s@/test.com' % local) + self.assertRaises(InvalidJID, JID, '%s@test.com' % local) + self.assertRaises(InvalidJID, JID, '%s@test.com/resource' % local) def test1024LengthResource(self): resource = 'r' * 1024 - self.assertRaises(InvalidJID, JID, domain='test.com', resource=resource) self.assertRaises(InvalidJID, JID, 'test.com/%s' % resource) + self.assertRaises(InvalidJID, JID, 'user@test.com/%s' % resource) def testTooLongDomainLabel(self): domain = ('a' * 64) + '.com' - self.assertRaises(InvalidJID, JID, domain=domain) self.assertRaises(InvalidJID, JID, 'user@%s/resource' % domain) def testDomainEmptyLabel(self): domain = 'aaa..bbb.com' - self.assertRaises(InvalidJID, JID, domain=domain) self.assertRaises(InvalidJID, JID, 'user@%s/resource' % domain) def testDomainIPv4(self): domain = '127.0.0.1' - jid1 = JID(domain=domain) - jid2 = JID('user@%s/resource' % domain) + + jid1 = JID('%s' % domain) + jid2 = JID('user@%s' % domain) + jid3 = JID('%s/resource' % domain) + jid4 = JID('user@%s/resource' % domain) def testDomainIPv6(self): domain = '[::1]' - jid1 = JID(domain=domain) - jid2 = JID('user@%s/resource' % domain) + + jid1 = JID('%s' % domain) + jid2 = JID('user@%s' % domain) + jid3 = JID('%s/resource' % domain) + jid4 = JID('user@%s/resource' % domain) def testDomainInvalidIPv6NoBrackets(self): domain = '::1' - jid1 = JID(domain=domain) - jid2 = JID('user@%s/resource' % domain) - self.assertEqual(jid1.domain, '[::1]') - self.assertEqual(jid2.domain, '[::1]') + self.assertRaises(InvalidJID, JID, '%s' % domain) + self.assertRaises(InvalidJID, JID, 'user@%s' % domain) + self.assertRaises(InvalidJID, JID, '%s/resource' % domain) + self.assertRaises(InvalidJID, JID, 'user@%s/resource' % domain) def testDomainInvalidIPv6MissingBracket(self): domain = '[::1' - jid1 = JID(domain=domain) - jid2 = JID('user@%s/resource' % domain) - self.assertEqual(jid1.domain, '[::1]') - self.assertEqual(jid2.domain, '[::1]') + self.assertRaises(InvalidJID, JID, '%s' % domain) + self.assertRaises(InvalidJID, JID, 'user@%s' % domain) + self.assertRaises(InvalidJID, JID, '%s/resource' % domain) + self.assertRaises(InvalidJID, JID, 'user@%s/resource' % domain) + + def testDomainInvalidIPv6WrongBracket(self): + domain = '[::]1]' + + self.assertRaises(InvalidJID, JID, '%s' % domain) + self.assertRaises(InvalidJID, JID, 'user@%s' % domain) + self.assertRaises(InvalidJID, JID, '%s/resource' % domain) + self.assertRaises(InvalidJID, JID, 'user@%s/resource' % domain) def testDomainWithPort(self): domain = 'example.com:5555' - self.assertRaises(InvalidJID, JID, domain=domain) + + self.assertRaises(InvalidJID, JID, '%s' % domain) + self.assertRaises(InvalidJID, JID, 'user@%s' % domain) + self.assertRaises(InvalidJID, JID, '%s/resource' % domain) self.assertRaises(InvalidJID, JID, 'user@%s/resource' % domain) def testDomainWithTrailingDot(self): domain = 'example.com.' - jid1 = JID(domain=domain) - jid2 = JID('user@%s/resource' % domain) + jid = JID('user@%s/resource' % domain) - self.assertEqual(jid1.domain, 'example.com') - self.assertEqual(jid2.domain, 'example.com') + self.assertEqual(jid.domain, 'example.com') def testDomainWithDashes(self): domain = 'example.com-' - self.assertRaises(InvalidJID, JID, domain=domain) self.assertRaises(InvalidJID, JID, 'user@%s/resource' % domain) domain = '-example.com' - self.assertRaises(InvalidJID, JID, domain=domain) self.assertRaises(InvalidJID, JID, 'user@%s/resource' % domain) def testACEDomain(self): domain = 'xn--bcher-kva.ch' - jid1 = JID(domain=domain) - jid2 = JID('user@%s/resource' % domain) - - self.assertEqual(jid1.domain.encode('utf-8'), b'b\xc3\xbccher.ch') - self.assertEqual(jid2.domain.encode('utf-8'), b'b\xc3\xbccher.ch') - - def testJIDEscapeExistingSequences(self): - jid = JID(local='blah\\foo\\20bar', domain='example.com') - self.assertEqual(jid.local, 'blah\\foo\\5c20bar') + jid = JID('user@%s/resource' % domain) - def testJIDEscape(self): - jid = JID(local='here\'s_a_wild_&_/cr%zy/_address_for:<wv>("IMPS")', - domain='example.com') - self.assertEqual(jid.local, r'here\27s_a_wild_\26_\2fcr%zy\2f_address_for\3a\3cwv\3e(\22IMPS\22)') + self.assertEqual(jid.domain.encode('utf-8'), b'b\xc3\xbccher.ch') def testJIDUnescape(self): - jid = JID(local='here\'s_a_wild_&_/cr%zy/_address_for:<wv>("IMPS")', - domain='example.com') + jid = JID('here\\27s_a_wild_\\26_\\2fcr%zy\\2f_\\40ddress\\20for\\3a\\3cwv\\3e(\\22IMPS\\22)\\5c@example.com') ujid = jid.unescape() - self.assertEqual(ujid.local, 'here\'s_a_wild_&_/cr%zy/_address_for:<wv>("IMPS")') + self.assertEqual(ujid.local, 'here\'s_a_wild_&_/cr%zy/_@ddress for:<wv>("imps")\\') - jid = JID(local='blah\\foo\\20bar', domain='example.com') + jid = JID('blah\\5cfoo\\5c20bar@example.com') ujid = jid.unescape() self.assertEqual(ujid.local, 'blah\\foo\\20bar') def testStartOrEndWithEscapedSpaces(self): local = ' foo' - self.assertRaises(InvalidJID, JID, local=local, domain='example.com') self.assertRaises(InvalidJID, JID, '%s@example.com' % local) local = 'bar ' - self.assertRaises(InvalidJID, JID, local=local, domain='example.com') self.assertRaises(InvalidJID, JID, '%s@example.com' % local) # Need more input for these cases. A JID starting with \20 *is* valid diff --git a/tests/test_overall.py b/tests/test_overall.py index 05fdc6d8..3f32913c 100644 --- a/tests/test_overall.py +++ b/tests/test_overall.py @@ -14,16 +14,13 @@ class TestOverall(unittest.TestCase): def testModules(self): """Testing all modules by compiling them""" - src = '.%ssleekxmpp' % os.sep - if sys.version_info < (3, 0): - rx = re.compile('/[.]svn') - else: - rx = re.compile('/[.]svn|.*26.*') + src = '.%sslixmpp' % os.sep + rx = re.compile('/[.]svn|.*26.*') self.failUnless(compileall.compile_dir(src, rx=rx, quiet=True)) def testTabNanny(self): """Testing that indentation is consistent""" - self.failIf(tabnanny.check('..%ssleekxmpp' % os.sep)) + self.failIf(tabnanny.check('..%sslixmpp' % os.sep)) suite = unittest.TestLoader().loadTestsFromTestCase(TestOverall) diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 6220d7a5..ee6d44c0 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -1,7 +1,7 @@ import unittest import logging -from sleekxmpp.plugins.base import PluginManager, BasePlugin, register_plugin +from slixmpp.plugins.base import PluginManager, BasePlugin, register_plugin class A(BasePlugin): @@ -77,7 +77,7 @@ class TestPlugins(unittest.TestCase): p.disable('a') self.assertEqual(len(p), 0, "Wrong number of enabled plugins.") - self.assertEqual(events, ['init', 'end'], + self.assertEqual(events, ['init', 'end'], "Plugin lifecycle methods not called.") def test_enable_dependencies(self): diff --git a/tests/test_stanza_base.py b/tests/test_stanza_base.py index deb7ab96..dac3f046 100644 --- a/tests/test_stanza_base.py +++ b/tests/test_stanza_base.py @@ -1,9 +1,9 @@ import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp.xmlstream.stanzabase import ET, StanzaBase +from slixmpp.test import SlixTest +from slixmpp.xmlstream.stanzabase import ET, StanzaBase -class TestStanzaBase(SleekTest): +class TestStanzaBase(SlixTest): def testTo(self): """Test the 'to' interface of StanzaBase.""" @@ -61,7 +61,7 @@ class TestStanzaBase(SleekTest): stanza['from'] = "sender@example.com" stanza['payload'] = ET.Element("{foo}foo") - stanza.reply() + stanza = stanza.reply() self.failUnless(str(stanza['to'] == "sender@example.com"), "Stanza reply did not change 'to' attribute.") diff --git a/tests/test_stanza_element.py b/tests/test_stanza_element.py index e678b56e..0c49f201 100644 --- a/tests/test_stanza_element.py +++ b/tests/test_stanza_element.py @@ -1,10 +1,10 @@ import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp.xmlstream.stanzabase import ElementBase, register_stanza_plugin, ET -from sleekxmpp.thirdparty import OrderedDict +from slixmpp.test import SlixTest +from slixmpp.xmlstream.stanzabase import ElementBase, register_stanza_plugin, ET +from collections import OrderedDict -class TestElementBase(SleekTest): +class TestElementBase(SlixTest): def testFixNs(self): """Test fixing namespaces in an XPath expression.""" @@ -38,7 +38,7 @@ class TestElementBase(SleekTest): """) def testGetStanzaValues(self): - """Test getStanzaValues using plugins and substanzas.""" + """Test get_stanza_values using plugins and substanzas.""" class TestStanzaPlugin(ElementBase): name = "foo2" @@ -65,7 +65,7 @@ class TestElementBase(SleekTest): substanza['bar'] = 'c' stanza.append(substanza) - values = stanza.getStanzaValues() + values = stanza.get_stanza_values() expected = {'lang': '', 'bar': 'a', 'baz': '', @@ -85,7 +85,7 @@ class TestElementBase(SleekTest): def testSetStanzaValues(self): - """Test using setStanzaValues with substanzas and plugins.""" + """Test using set_stanza_values with substanzas and plugins.""" class TestStanzaPlugin(ElementBase): name = "pluginfoo" @@ -157,10 +157,10 @@ class TestElementBase(SleekTest): stanza = TestStanza() substanza = TestStanza() stanza.append(substanza) - stanza.setStanzaValues({'bar': 'a', - 'baz': 'b', - 'qux': 42, - 'foobar': {'fizz': 'c'}}) + stanza.set_stanza_values({'bar': 'a', + 'baz': 'b', + 'qux': 42, + 'foobar': {'fizz': 'c'}}) # Test non-plugin interfaces expected = {'substanzas': [substanza], diff --git a/tests/test_stanza_error.py b/tests/test_stanza_error.py index d95a33ce..c6a92eb6 100644 --- a/tests/test_stanza_error.py +++ b/tests/test_stanza_error.py @@ -1,8 +1,8 @@ import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestErrorStanzas(SleekTest): +class TestErrorStanzas(SlixTest): def setUp(self): # Ensure that the XEP-0086 plugin has been loaded. diff --git a/tests/test_stanza_gmail.py b/tests/test_stanza_gmail.py index a15fea20..a17efca2 100644 --- a/tests/test_stanza_gmail.py +++ b/tests/test_stanza_gmail.py @@ -1,11 +1,11 @@ import unittest -from sleekxmpp import Iq -from sleekxmpp.test import SleekTest -import sleekxmpp.plugins.gmail_notify as gmail -from sleekxmpp.xmlstream import register_stanza_plugin, ET +from slixmpp import Iq +from slixmpp.test import SlixTest +import slixmpp.plugins.gmail_notify as gmail +from slixmpp.xmlstream import register_stanza_plugin, ET -class TestGmail(SleekTest): +class TestGmail(SlixTest): def setUp(self): register_stanza_plugin(Iq, gmail.GmailQuery) diff --git a/tests/test_stanza_iq.py b/tests/test_stanza_iq.py index 0f5e30b0..0b248da6 100644 --- a/tests/test_stanza_iq.py +++ b/tests/test_stanza_iq.py @@ -1,9 +1,9 @@ import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp.xmlstream.stanzabase import ET +from slixmpp.test import SlixTest +from slixmpp.xmlstream.stanzabase import ET -class TestIqStanzas(SleekTest): +class TestIqStanzas(SlixTest): def tearDown(self): """Shutdown the XML stream after testing.""" @@ -19,7 +19,7 @@ class TestIqStanzas(SleekTest): def testPayload(self): """Test setting Iq stanza payload.""" iq = self.Iq() - iq.setPayload(ET.Element('{test}tester')) + iq.set_payload(ET.Element('{test}tester')) self.check(iq, """ <iq id="0"> <tester xmlns="test" /> @@ -82,7 +82,7 @@ class TestIqStanzas(SleekTest): iq = self.Iq() iq['to'] = 'user@localhost' iq['type'] = 'get' - iq.reply() + iq = iq.reply() self.check(iq, """ <iq id="0" type="result" /> diff --git a/tests/test_stanza_message.py b/tests/test_stanza_message.py index 9968a630..68c78dab 100644 --- a/tests/test_stanza_message.py +++ b/tests/test_stanza_message.py @@ -1,11 +1,11 @@ import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp.stanza.message import Message -from sleekxmpp.stanza.htmlim import HTMLIM -from sleekxmpp.xmlstream import register_stanza_plugin +from slixmpp.test import SlixTest +from slixmpp.stanza.message import Message +from slixmpp.stanza.htmlim import HTMLIM +from slixmpp.xmlstream import register_stanza_plugin -class TestMessageStanzas(SleekTest): +class TestMessageStanzas(SlixTest): def setUp(self): register_stanza_plugin(Message, HTMLIM) @@ -17,7 +17,7 @@ class TestMessageStanzas(SleekTest): msg['from'] = 'room@someservice.someserver.tld/somenick' msg['type'] = 'groupchat' msg['body'] = "this is a message" - msg.reply() + msg = msg.reply() self.failUnless(str(msg['to']) == 'room@someservice.someserver.tld') def testAttribProperty(self): @@ -29,12 +29,12 @@ class TestMessageStanzas(SleekTest): def testHTMLPlugin(self): "Test message/html/body stanza" msg = self.Message() - msg['to'] = "fritzy@netflint.net/sleekxmpp" + msg['to'] = "fritzy@netflint.net/slixmpp" msg['body'] = "this is the plaintext message" msg['type'] = 'chat' msg['html']['body'] = '<p>This is the htmlim message</p>' self.check(msg, """ - <message to="fritzy@netflint.net/sleekxmpp" type="chat"> + <message to="fritzy@netflint.net/slixmpp" type="chat"> <body>this is the plaintext message</body> <html xmlns="http://jabber.org/protocol/xhtml-im"> <body xmlns="http://www.w3.org/1999/xhtml"> diff --git a/tests/test_stanza_presence.py b/tests/test_stanza_presence.py index 184dce96..73aaba97 100644 --- a/tests/test_stanza_presence.py +++ b/tests/test_stanza_presence.py @@ -1,8 +1,8 @@ import unittest -import sleekxmpp -from sleekxmpp.test import SleekTest +import slixmpp +from slixmpp.test import SlixTest -class TestPresenceStanzas(SleekTest): +class TestPresenceStanzas(SlixTest): def testPresenceShowRegression(self): """Regression check presence['type'] = 'dnd' show value working""" @@ -38,7 +38,7 @@ class TestPresenceStanzas(SleekTest): p['type'] = 'unavailable' p['from'] = 'bill@chadmore.com/gmail15af' - c = sleekxmpp.ClientXMPP('crap@wherever', 'password') + c = slixmpp.ClientXMPP('crap@wherever', 'password') happened = [] def handlechangedpresence(event): diff --git a/tests/test_stanza_roster.py b/tests/test_stanza_roster.py index d121568b..4496fc18 100644 --- a/tests/test_stanza_roster.py +++ b/tests/test_stanza_roster.py @@ -1,14 +1,14 @@ import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp.xmlstream import ET +from slixmpp.test import SlixTest +from slixmpp.xmlstream import ET -class TestRosterStanzas(SleekTest): +class TestRosterStanzas(SlixTest): def testAddItems(self): """Test adding items to a roster stanza.""" iq = self.Iq() - iq['roster'].setItems({ + iq['roster'].set_items({ 'user@example.com': { 'name': 'User', 'subscription': 'both', diff --git a/tests/test_stanza_xep_0004.py b/tests/test_stanza_xep_0004.py index b87afb24..7b01b575 100644 --- a/tests/test_stanza_xep_0004.py +++ b/tests/test_stanza_xep_0004.py @@ -1,13 +1,13 @@ import unittest -from sleekxmpp import Message -from sleekxmpp.test import SleekTest -from sleekxmpp.thirdparty import OrderedDict +from slixmpp import Message +from slixmpp.test import SlixTest +from collections import OrderedDict -import sleekxmpp.plugins.xep_0004 as xep_0004 -from sleekxmpp.xmlstream import register_stanza_plugin +import slixmpp.plugins.xep_0004 as xep_0004 +from slixmpp.xmlstream import register_stanza_plugin -class TestDataForms(SleekTest): +class TestDataForms(SlixTest): def setUp(self): register_stanza_plugin(Message, xep_0004.Form) diff --git a/tests/test_stanza_xep_0009.py b/tests/test_stanza_xep_0009.py index fa1ed19b..f1a61b80 100644 --- a/tests/test_stanza_xep_0009.py +++ b/tests/test_stanza_xep_0009.py @@ -1,9 +1,9 @@ # -*- encoding:utf-8 -*- """ - SleekXMPP: The Sleek XMPP Library + Slixmpp: The Slick XMPP Library Copyright (C) 2011 Nathanael C. Fritz, Dann Martens (TOMOTON). - This file is part of SleekXMPP. + This file is part of Slixmpp. See the file LICENSE for copying permission. """ @@ -13,22 +13,18 @@ from __future__ import unicode_literals import base64 import sys -from sleekxmpp.plugins.xep_0009.stanza.RPC import RPCQuery, MethodCall, \ +from slixmpp.plugins.xep_0009.stanza.RPC import RPCQuery, MethodCall, \ MethodResponse -from sleekxmpp.plugins.xep_0009.binding import py2xml, xml2py, rpcbase64, \ +from slixmpp.plugins.xep_0009.binding import py2xml, xml2py, rpcbase64, \ rpctime -from sleekxmpp.stanza.iq import Iq -from sleekxmpp.test.sleektest import SleekTest -from sleekxmpp.xmlstream.stanzabase import register_stanza_plugin -from sleekxmpp.xmlstream.tostring import tostring +from slixmpp.stanza.iq import Iq +from slixmpp.test.slixtest import SlixTest +from slixmpp.xmlstream.stanzabase import register_stanza_plugin +from slixmpp.xmlstream.tostring import tostring import unittest -if sys.version_info > (3, 0): - unicode = str - - -class TestJabberRPC(SleekTest): +class TestJabberRPC(SlixTest): def setUp(self): register_stanza_plugin(Iq, RPCQuery) diff --git a/tests/test_stanza_xep_0030.py b/tests/test_stanza_xep_0030.py index 986c1880..d8e99ffb 100644 --- a/tests/test_stanza_xep_0030.py +++ b/tests/test_stanza_xep_0030.py @@ -1,11 +1,11 @@ import unittest -from sleekxmpp import Iq -from sleekxmpp.test import SleekTest -import sleekxmpp.plugins.xep_0030 as xep_0030 -from sleekxmpp.xmlstream import register_stanza_plugin +from slixmpp import Iq +from slixmpp.test import SlixTest +import slixmpp.plugins.xep_0030 as xep_0030 +from slixmpp.xmlstream import register_stanza_plugin -class TestDisco(SleekTest): +class TestDisco(SlixTest): """ Test creating and manipulating the disco#info and diff --git a/tests/test_stanza_xep_0033.py b/tests/test_stanza_xep_0033.py index bf10cf6c..0e560a7e 100644 --- a/tests/test_stanza_xep_0033.py +++ b/tests/test_stanza_xep_0033.py @@ -1,11 +1,11 @@ import unittest -from sleekxmpp import Message -from sleekxmpp.test import SleekTest -import sleekxmpp.plugins.xep_0033 as xep_0033 -from sleekxmpp.xmlstream import register_stanza_plugin +from slixmpp import Message +from slixmpp.test import SlixTest +import slixmpp.plugins.xep_0033 as xep_0033 +from slixmpp.xmlstream import register_stanza_plugin -class TestAddresses(SleekTest): +class TestAddresses(SlixTest): def setUp(self): register_stanza_plugin(Message, xep_0033.Addresses) diff --git a/tests/test_stanza_xep_0047.py b/tests/test_stanza_xep_0047.py index 9fd3c4d6..12283136 100644 --- a/tests/test_stanza_xep_0047.py +++ b/tests/test_stanza_xep_0047.py @@ -1,12 +1,12 @@ import unittest -from sleekxmpp.exceptions import XMPPError -from sleekxmpp import Iq -from sleekxmpp.test import SleekTest -from sleekxmpp.plugins.xep_0047 import Data -from sleekxmpp.xmlstream import register_stanza_plugin, ET +from slixmpp.exceptions import XMPPError +from slixmpp import Iq +from slixmpp.test import SlixTest +from slixmpp.plugins.xep_0047 import Data +from slixmpp.xmlstream import register_stanza_plugin, ET -class TestIBB(SleekTest): +class TestIBB(SlixTest): def setUp(self): register_stanza_plugin(Iq, Data) @@ -82,11 +82,11 @@ class TestIBB(SleekTest): iq = Iq() iq['type'] = 'set' iq['ibb_data']['seq'] = 0 - iq['ibb_data']['data'] = 'sleekxmpp' + iq['ibb_data']['data'] = 'slixmpp' self.check(iq, """ <iq type="set"> - <data xmlns="http://jabber.org/protocol/ibb" seq="0">c2xlZWt4bXBw</data> + <data xmlns="http://jabber.org/protocol/ibb" seq="0">c2xpeG1wcA==</data> </iq> """) diff --git a/tests/test_stanza_xep_0050.py b/tests/test_stanza_xep_0050.py index 9d49b3ee..7272d783 100644 --- a/tests/test_stanza_xep_0050.py +++ b/tests/test_stanza_xep_0050.py @@ -1,11 +1,11 @@ -from sleekxmpp import Iq +from slixmpp import Iq import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp.plugins.xep_0050 import Command -from sleekxmpp.xmlstream import register_stanza_plugin +from slixmpp.test import SlixTest +from slixmpp.plugins.xep_0050 import Command +from slixmpp.xmlstream import register_stanza_plugin -class TestAdHocCommandStanzas(SleekTest): +class TestAdHocCommandStanzas(SlixTest): def setUp(self): register_stanza_plugin(Iq, Command) diff --git a/tests/test_stanza_xep_0059.py b/tests/test_stanza_xep_0059.py index 860ec869..246481ce 100644 --- a/tests/test_stanza_xep_0059.py +++ b/tests/test_stanza_xep_0059.py @@ -1,10 +1,10 @@ import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp.plugins.xep_0059 import Set -from sleekxmpp.xmlstream import ET +from slixmpp.test import SlixTest +from slixmpp.plugins.xep_0059 import Set +from slixmpp.xmlstream import ET -class TestSetStanzas(SleekTest): +class TestSetStanzas(SlixTest): def testSetFirstIndex(self): s = Set() diff --git a/tests/test_stanza_xep_0060.py b/tests/test_stanza_xep_0060.py index 332b53ea..567757cb 100644 --- a/tests/test_stanza_xep_0060.py +++ b/tests/test_stanza_xep_0060.py @@ -1,11 +1,11 @@ import unittest -from sleekxmpp.test import SleekTest -import sleekxmpp.plugins.xep_0004 as xep_0004 -import sleekxmpp.plugins.xep_0060.stanza as pubsub -from sleekxmpp.xmlstream.stanzabase import ET +from slixmpp.test import SlixTest +import slixmpp.plugins.xep_0004 as xep_0004 +import slixmpp.plugins.xep_0060.stanza as pubsub +from slixmpp.xmlstream.stanzabase import ET -class TestPubsubStanzas(SleekTest): +class TestPubsubStanzas(SlixTest): def testAffiliations(self): "Testing iq/pubsub/affiliations/affiliation stanzas" @@ -55,12 +55,12 @@ class TestPubsubStanzas(SleekTest): iq = self.Iq() iq['pubsub']['subscription']['suboptions']['required'] = True iq['pubsub']['subscription']['node'] = 'testnode alsdkjfas' - iq['pubsub']['subscription']['jid'] = "fritzy@netflint.net/sleekxmpp" + iq['pubsub']['subscription']['jid'] = "fritzy@netflint.net/slixmpp" iq['pubsub']['subscription']['subscription'] = 'unconfigured' self.check(iq, """ <iq id="0"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> - <subscription node="testnode alsdkjfas" jid="fritzy@netflint.net/sleekxmpp" subscription="unconfigured"> + <subscription node="testnode alsdkjfas" jid="fritzy@netflint.net/slixmpp" subscription="unconfigured"> <subscribe-options> <required /> </subscribe-options> @@ -157,17 +157,17 @@ class TestPubsubStanzas(SleekTest): iq = self.Iq() iq['pubsub']['subscribe']['options'] iq['pubsub']['subscribe']['node'] = 'cheese' - iq['pubsub']['subscribe']['jid'] = 'fritzy@netflint.net/sleekxmpp' + iq['pubsub']['subscribe']['jid'] = 'fritzy@netflint.net/slixmpp' iq['pubsub']['subscribe']['options']['node'] = 'cheese' - iq['pubsub']['subscribe']['options']['jid'] = 'fritzy@netflint.net/sleekxmpp' + iq['pubsub']['subscribe']['options']['jid'] = 'fritzy@netflint.net/slixmpp' form = xep_0004.Form() form.addField('pubsub#title', ftype='text-single', value='this thing is awesome') iq['pubsub']['subscribe']['options']['options'] = form self.check(iq, """ <iq id="0"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> - <subscribe node="cheese" jid="fritzy@netflint.net/sleekxmpp"> - <options node="cheese" jid="fritzy@netflint.net/sleekxmpp"> + <subscribe node="cheese" jid="fritzy@netflint.net/slixmpp"> + <options node="cheese" jid="fritzy@netflint.net/slixmpp"> <x xmlns="jabber:x:data" type="submit"> <field var="pubsub#title"> <value>this thing is awesome</value> diff --git a/tests/test_stanza_xep_0085.py b/tests/test_stanza_xep_0085.py index 303e6c5b..d62d2e46 100644 --- a/tests/test_stanza_xep_0085.py +++ b/tests/test_stanza_xep_0085.py @@ -1,11 +1,11 @@ import unittest -from sleekxmpp import Message -from sleekxmpp.test import SleekTest -import sleekxmpp.plugins.xep_0085 as xep_0085 -from sleekxmpp.xmlstream import register_stanza_plugin +from slixmpp import Message +from slixmpp.test import SlixTest +import slixmpp.plugins.xep_0085 as xep_0085 +from slixmpp.xmlstream import register_stanza_plugin -class TestChatStates(SleekTest): +class TestChatStates(SlixTest): def setUp(self): register_stanza_plugin(Message, xep_0085.stanza.Active) diff --git a/tests/test_stanza_xep_0122.py b/tests/test_stanza_xep_0122.py index fca49bbb..0c032c05 100644 --- a/tests/test_stanza_xep_0122.py +++ b/tests/test_stanza_xep_0122.py @@ -1,13 +1,13 @@ import unittest -from sleekxmpp import Message -from sleekxmpp.test import SleekTest -import sleekxmpp.plugins.xep_0004 as xep_0004 -import sleekxmpp.plugins.xep_0122 as xep_0122 -from sleekxmpp.xmlstream import register_stanza_plugin +from slixmpp import Message +from slixmpp.test import SlixTest +import slixmpp.plugins.xep_0004 as xep_0004 +import slixmpp.plugins.xep_0122 as xep_0122 +from slixmpp.xmlstream import register_stanza_plugin -class TestDataForms(SleekTest): +class TestDataForms(SlixTest): def setUp(self): register_stanza_plugin(Message, xep_0004.Form) @@ -19,12 +19,12 @@ class TestDataForms(SleekTest): """Testing basic validation setting and getting.""" msg = self.Message() form = msg['form'] - field = form.addField(var='f1', - ftype='text-single', - label='Text', - desc='A text field', - required=True, - value='Some text!') + field = form.add_field(var='f1', + ftype='text-single', + label='Text', + desc='A text field', + required=True, + value='Some text!') validation = field['validate'] validation['datatype'] = 'xs:string' @@ -54,12 +54,12 @@ class TestDataForms(SleekTest): """Testing open validation setting and getting.""" msg = self.Message() form = msg['form'] - field = form.addField(var='f1', - ftype='text-single', - label='Text', - desc='A text field', - required=True, - value='Some text!') + field = form.add_field(var='f1', + ftype='text-single', + label='Text', + desc='A text field', + required=True, + value='Some text!') validation = field['validate'] validation.set_open(True) @@ -88,12 +88,12 @@ class TestDataForms(SleekTest): """Testing regex validation setting and getting.""" msg = self.Message() form = msg['form'] - field = form.addField(var='f1', - ftype='text-single', - label='Text', - desc='A text field', - required=True, - value='Some text!') + field = form.add_field(var='f1', + ftype='text-single', + label='Text', + desc='A text field', + required=True, + value='Some text!') regex_value = '[0-9]+' @@ -126,12 +126,12 @@ class TestDataForms(SleekTest): """Testing range validation setting and getting.""" msg = self.Message() form = msg['form'] - field = form.addField(var='f1', - ftype='text-single', - label='Text', - desc='A text field', - required=True, - value='Some text!') + field = form.add_field(var='f1', + ftype='text-single', + label='Text', + desc='A text field', + required=True, + value='Some text!') validation = field['validate'] validation.set_range(True, minimum=0, maximum=10) @@ -160,11 +160,11 @@ class TestDataForms(SleekTest): """ msg = self.Message() form = msg['form'] - field = form.addReported(var='f1', ftype='text-single', label='Text') + field = form.add_reported(var='f1', ftype='text-single', label='Text') validation = field['validate'] validation.set_basic(True) - form.addItem({'f1': 'Some text!'}) + form.add_item({'f1': 'Some text!'}) self.check(msg, """ <message> diff --git a/tests/test_stanza_xep_0184.py b/tests/test_stanza_xep_0184.py index 0c340487..9d2f0c07 100644 --- a/tests/test_stanza_xep_0184.py +++ b/tests/test_stanza_xep_0184.py @@ -1,11 +1,11 @@ import unittest -from sleekxmpp import Message -from sleekxmpp.test import SleekTest -import sleekxmpp.plugins.xep_0184 as xep_0184 -from sleekxmpp.xmlstream import register_stanza_plugin +from slixmpp import Message +from slixmpp.test import SlixTest +import slixmpp.plugins.xep_0184 as xep_0184 +from slixmpp.xmlstream import register_stanza_plugin -class TestReciept(SleekTest): +class TestReciept(SlixTest): def setUp(self): register_stanza_plugin(Message, xep_0184.Request) diff --git a/tests/test_stanza_xep_0323.py b/tests/test_stanza_xep_0323.py index 7b1dfe42..991481d7 100644 --- a/tests/test_stanza_xep_0323.py +++ b/tests/test_stanza_xep_0323.py @@ -1,12 +1,11 @@ # -*- coding: utf-8 -*- -from sleekxmpp.test import * -import sleekxmpp.plugins.xep_0323 as xep_0323 +from slixmpp.test import * +import slixmpp.plugins.xep_0323 as xep_0323 namespace='sn' -class TestSensorDataStanzas(SleekTest): - +class TestSensorDataStanzas(SlixTest): def setUp(self): pass diff --git a/tests/test_stanza_xep_0325.py b/tests/test_stanza_xep_0325.py index dc2e8efe..3e388ac3 100644 --- a/tests/test_stanza_xep_0325.py +++ b/tests/test_stanza_xep_0325.py @@ -1,21 +1,20 @@ # -*- coding: utf-8 -*- """ - SleekXMPP: The Sleek XMPP Library + Slixmpp: The Slick XMPP Library Implementation of xeps for Internet of Things http://wiki.xmpp.org/web/Tech_pages/IoT_systems Copyright (C) 2013 Sustainable Innovation, Joachim.lindborg@sust.se, bjorn.westrom@consoden.se - This file is part of SleekXMPP. + This file is part of Slixmpp. See the file LICENSE for copying permission. """ -from sleekxmpp.test import * -import sleekxmpp.plugins.xep_0325 as xep_0325 +from slixmpp.test import * +import slixmpp.plugins.xep_0325 as xep_0325 namespace='sn' -class TestControlStanzas(SleekTest): - +class TestControlStanzas(SlixTest): def setUp(self): pass diff --git a/tests/test_stream.py b/tests/test_stream.py index f68f8426..0476039c 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -1,9 +1,9 @@ import time import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestStreamTester(SleekTest): +class TestStreamTester(SlixTest): """ Test that we can simulate and test a stanza stream. """ @@ -16,7 +16,7 @@ class TestStreamTester(SleekTest): self.stream_start(mode='client') def echo(msg): - msg.reply('Thanks for sending: %(body)s' % msg).send() + msg.reply('Thanks for sending: %s' % msg['body']).send() self.xmpp.add_event_handler('message', echo) @@ -58,23 +58,4 @@ class TestStreamTester(SleekTest): self.stream_start(mode='client', skip=False) self.send_header(sto='localhost') - def testStreamDisconnect(self): - """Test that the test socket can simulate disconnections.""" - self.stream_start() - events = set() - - def stream_error(event): - events.add('socket_error') - - self.xmpp.add_event_handler('socket_error', stream_error) - - self.stream_disconnect() - self.xmpp.send_raw(' ') - - time.sleep(.1) - - self.failUnless('socket_error' in events, - "Stream error event not raised: %s" % events) - - suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamTester) diff --git a/tests/test_stream_exceptions.py b/tests/test_stream_exceptions.py index d18d059a..f21f197e 100644 --- a/tests/test_stream_exceptions.py +++ b/tests/test_stream_exceptions.py @@ -1,11 +1,11 @@ -from sleekxmpp.xmlstream.matcher import MatchXPath -from sleekxmpp.xmlstream.handler import Callback -from sleekxmpp.exceptions import XMPPError +from slixmpp.xmlstream.matcher import MatchXPath +from slixmpp.xmlstream.handler import Callback +from slixmpp.exceptions import XMPPError import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestStreamExceptions(SleekTest): +class TestStreamExceptions(SlixTest): """ Test handling roster updates. """ @@ -13,40 +13,11 @@ class TestStreamExceptions(SleekTest): def tearDown(self): self.stream_close() - def testExceptionReply(self): - """Test that raising an exception replies with the original stanza.""" - - def message(msg): - msg.reply() - msg['body'] = 'Body changed' - raise XMPPError(clear=False) - - self.stream_start() - self.xmpp.add_event_handler('message', message) - - self.recv(""" - <message> - <body>This is going to cause an error.</body> - </message> - """) - - self.send(""" - <message type="error"> - <body>This is going to cause an error.</body> - <error type="cancel" code="500"> - <undefined-condition - xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /> - </error> - </message> - """) - def testExceptionContinueWorking(self): - """Test that Sleek continues to respond after an XMPPError is raised.""" + """Test that Slixmpp continues to respond after an XMPPError is raised.""" def message(msg): - msg.reply() - msg['body'] = 'Body changed' - raise XMPPError(clear=False) + raise XMPPError(clear=True) self.stream_start() self.xmpp.add_event_handler('message', message) @@ -59,7 +30,6 @@ class TestStreamExceptions(SleekTest): self.send(""" <message type="error"> - <body>This is going to cause an error.</body> <error type="cancel" code="500"> <undefined-condition xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /> @@ -75,7 +45,6 @@ class TestStreamExceptions(SleekTest): self.send(""" <message type="error"> - <body>This is going to cause an error.</body> <error type="cancel" code="500"> <undefined-condition xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /> @@ -151,38 +120,8 @@ class TestStreamExceptions(SleekTest): </iq> """, use_values=False) - def testThreadedXMPPErrorException(self): - """Test raising an XMPPError exception in a threaded handler.""" - - def message(msg): - raise XMPPError(condition='feature-not-implemented', - text="We don't do things that way here.", - etype='cancel') - - self.stream_start() - self.xmpp.add_event_handler('message', message, - threaded=True) - - self.recv(""" - <message> - <body>This is going to cause an error.</body> - </message> - """) - - self.send(""" - <message type="error"> - <error type="cancel" code="501"> - <feature-not-implemented - xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /> - <text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"> - We don't do things that way here. - </text> - </error> - </message> - """) - def testUnknownException(self): - """Test raising an generic exception in a threaded handler.""" + """Test raising an generic exception in a handler.""" raised_errors = [] @@ -208,7 +147,7 @@ class TestStreamExceptions(SleekTest): <undefined-condition xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /> <text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"> - SleekXMPP got into trouble. + Slixmpp got into trouble. </text> </error> </message> @@ -217,7 +156,7 @@ class TestStreamExceptions(SleekTest): self.assertEqual(raised_errors, [True], "Exception was not raised: %s" % raised_errors) def testUnknownException(self): - """Test Sleek continues to respond after an unknown exception.""" + """Test Slixmpp continues to respond after an unknown exception.""" raised_errors = [] @@ -243,7 +182,7 @@ class TestStreamExceptions(SleekTest): <undefined-condition xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /> <text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"> - SleekXMPP got into trouble. + Slixmpp got into trouble. </text> </error> </message> @@ -261,7 +200,7 @@ class TestStreamExceptions(SleekTest): <undefined-condition xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /> <text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"> - SleekXMPP got into trouble. + Slixmpp got into trouble. </text> </error> </message> diff --git a/tests/test_stream_filters.py b/tests/test_stream_filters.py index ee17ffdc..c5fde338 100644 --- a/tests/test_stream_filters.py +++ b/tests/test_stream_filters.py @@ -1,11 +1,11 @@ import time -from sleekxmpp import Message +from slixmpp import Message import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestFilters(SleekTest): +class TestFilters(SlixTest): """ Test using incoming and outgoing filters. @@ -47,8 +47,6 @@ class TestFilters(SleekTest): </message> """) - time.sleep(0.5) - self.assertEqual(data, ['', 'testing filter'], 'Incoming filter did not apply %s' % data) diff --git a/tests/test_stream_handlers.py b/tests/test_stream_handlers.py index 0208cd16..24b5c1a6 100644 --- a/tests/test_stream_handlers.py +++ b/tests/test_stream_handlers.py @@ -2,12 +2,12 @@ import time import threading import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp.exceptions import IqTimeout -from sleekxmpp import Callback, MatchXPath +from slixmpp.test import SlixTest +from slixmpp.exceptions import IqTimeout +from slixmpp import Callback, MatchXPath -class TestHandlers(SleekTest): +class TestHandlers(SlixTest): """ Test using handlers and waiters. """ @@ -48,15 +48,15 @@ class TestHandlers(SleekTest): iq['id'] = 'test' iq['type'] = 'set' iq['query'] = 'test' - reply = iq.send(block=True) - if reply: + def callback_waiter(result): self.xmpp.send_raw(""" <message> <body>Successful: %s</body> </message> - """ % reply['query']) + """ % result['query']) + iq.send(callback=callback_waiter) - self.xmpp.add_event_handler('message', waiter_handler, threaded=True) + self.xmpp.add_event_handler('message', waiter_handler) # Send message to trigger waiter_handler self.recv(""" @@ -93,11 +93,11 @@ class TestHandlers(SleekTest): iq['type'] = 'set' iq['query'] = 'test2' try: - reply = iq.send(block=True, timeout=0) + reply = iq.send(timeout=0) except IqTimeout: pass - self.xmpp.add_event_handler('message', waiter_handler, threaded=True) + self.xmpp.add_event_handler('message', waiter_handler) # Start test by triggerig waiter_handler self.recv("""<message><body>Start Test</body></message>""") @@ -109,9 +109,6 @@ class TestHandlers(SleekTest): iq['query'] = 'test2' self.send(iq) - # Give the event queue time to process. - time.sleep(0.1) - # Check that the waiter is no longer registered waiter_exists = self.xmpp.remove_handler('IqWait_test2') @@ -148,41 +145,9 @@ class TestHandlers(SleekTest): </iq> """) - # Give event queue time to process - time.sleep(0.1) - self.failUnless(events == ['foo'], "Iq callback was not executed: %s" % events) - def testIqTimeoutCallback(self): - """Test that iq.send(tcallback=handle_foo, timeout_callback=handle_timeout) works.""" - events = [] - - def handle_foo(iq): - events.append('foo') - - def handle_timeout(iq): - events.append('timeout') - - iq = self.Iq() - iq['type'] = 'get' - iq['id'] = 'test-foo' - iq['to'] = 'user@localhost' - iq['query'] = 'foo' - iq.send(callback=handle_foo, timeout_callback=handle_timeout, timeout=0.05) - - self.send(""" - <iq type="get" id="test-foo" to="user@localhost"> - <query xmlns="foo" /> - </iq> - """) - - # Give event queue time to process - time.sleep(1) - - self.failUnless(events == ['timeout'], - "Iq timeout was not executed: %s" % events) - def testMultipleHandlersForStanza(self): """ Test that multiple handlers for a single stanza work @@ -235,26 +200,23 @@ class TestHandlers(SleekTest): events = [] - def run_test(): - # Check that Iq was sent by waiter_handler - iq = self.Iq() - iq['id'] = 'test' - iq['to'] = 'tester@sleekxmpp.com/test' - iq['type'] = 'set' - iq['query'] = 'test' - result = iq.send() + def callback(result): events.append(result['from'].full) - t = threading.Thread(name="sender_test", target=run_test) - t.start() + iq = self.Iq() + iq['id'] = 'test' + iq['to'] = 'tester@slixmpp.com/test' + iq['type'] = 'set' + iq['query'] = 'test' + iq.send(callback=callback) self.recv(""" - <iq id="test" from="evil@sleekxmpp.com/bad" type="result"> + <iq id="test" from="evil@slixmpp.com/bad" type="result"> <query xmlns="test" /> </iq> """) self.recv(""" - <iq id="test" from="evil2@sleekxmpp.com" type="result"> + <iq id="test" from="evil2@slixmpp.com" type="result"> <query xmlns="test" /> </iq> """) @@ -266,18 +228,12 @@ class TestHandlers(SleekTest): # Now for a good one self.recv(""" - <iq id="test" from="tester@sleekxmpp.com/test" type="result"> + <iq id="test" from="tester@slixmpp.com/test" type="result"> <query xmlns="test" /> </iq> """) - t.join() - - time.sleep(0.1) - - self.assertEqual(events, ['tester@sleekxmpp.com/test'], "Did not timeout on bad sender") - - + self.assertEqual(events, ['tester@slixmpp.com/test'], "Did not timeout on bad sender") suite = unittest.TestLoader().loadTestsFromTestCase(TestHandlers) diff --git a/tests/test_stream_presence.py b/tests/test_stream_presence.py index 365a09ed..ea2337a2 100644 --- a/tests/test_stream_presence.py +++ b/tests/test_stream_presence.py @@ -1,9 +1,9 @@ import time import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestStreamPresence(SleekTest): +class TestStreamPresence(SlixTest): """ Test handling roster updates. """ @@ -38,9 +38,6 @@ class TestStreamPresence(SleekTest): to="tester@localhost"/> """) - # Give event queue time to process. - time.sleep(0.1) - self.assertEqual(events, set(('unavailable',)), "Got offline incorrectly triggered: %s." % events) @@ -83,9 +80,6 @@ class TestStreamPresence(SleekTest): type="unavailable" /> """) - # Give event queue time to process. - time.sleep(0.1) - self.assertEqual(events, ['got_offline'], "Got offline incorrectly triggered: %s" % events) @@ -108,9 +102,6 @@ class TestStreamPresence(SleekTest): to="tester@localhost" /> """) - # Give event queue time to process. - time.sleep(0.1) - expected = set(('presence_available', 'got_online')) self.assertEqual(events, expected, "Incorrect events triggered: %s" % events) @@ -242,8 +233,6 @@ class TestStreamPresence(SleekTest): <presence type="unsubscribed" /> """) - time.sleep(.5) - self.assertEqual(events, ptypes, "Not all events raised: %s" % events) @@ -364,8 +353,6 @@ class TestStreamPresence(SleekTest): </presence> """) - time.sleep(0.3) - self.assertEqual(events, ['available', 'away', 'dnd', 'chat', 'xa', 'unavailable', 'available', 'available', 'dnd'], diff --git a/tests/test_stream_roster.py b/tests/test_stream_roster.py index 221954ab..6a171ce7 100644 --- a/tests/test_stream_roster.py +++ b/tests/test_stream_roster.py @@ -2,13 +2,13 @@ from __future__ import unicode_literals import unittest -from sleekxmpp.exceptions import IqTimeout -from sleekxmpp.test import SleekTest +from slixmpp.exceptions import IqTimeout +from slixmpp.test import SlixTest import time import threading -class TestStreamRoster(SleekTest): +class TestStreamRoster(SlixTest): """ Test handling roster updates. """ @@ -24,9 +24,7 @@ class TestStreamRoster(SleekTest): self.xmpp.add_event_handler('roster_update', roster_updates.append) - # Since get_roster blocks, we need to run it in a thread. - t = threading.Thread(name='get_roster', target=self.xmpp.get_roster) - t.start() + self.xmpp.get_roster() self.send(""" <iq type="get" id="1"> @@ -47,12 +45,6 @@ class TestStreamRoster(SleekTest): </iq> """) - # Wait for get_roster to return. - t.join() - - # Give the event queue time to process. - time.sleep(.1) - self.check_roster('tester@localhost', 'user@localhost', name='User', subscription='from', @@ -96,8 +88,6 @@ class TestStreamRoster(SleekTest): subscription='both', groups=['Friends', 'Examples']) - # Give the event queue time to process. - time.sleep(.1) self.failUnless('roster_update' in events, "Roster updated event not triggered: %s" % events) @@ -170,16 +160,6 @@ class TestStreamRoster(SleekTest): </iq> """) - def testRosterTimeout(self): - """Test handling a timed out roster request.""" - self.stream_start() - - def do_test(): - self.xmpp.get_roster(timeout=0) - time.sleep(.1) - - self.assertRaises(IqTimeout, do_test) - def testRosterCallback(self): """Test handling a roster request callback.""" self.stream_start() @@ -188,12 +168,7 @@ class TestStreamRoster(SleekTest): def roster_callback(iq): events.append('roster_callback') - # Since get_roster blocks, we need to run it in a thread. - t = threading.Thread(name='get_roster', - target=self.xmpp.get_roster, - kwargs={str('block'): False, - str('callback'): roster_callback}) - t.start() + self.xmpp.get_roster(callback=roster_callback) self.send(""" <iq type="get" id="1"> @@ -213,12 +188,6 @@ class TestStreamRoster(SleekTest): </iq> """) - # Wait for get_roster to return. - t.join() - - # Give the event queue time to process. - time.sleep(.1) - self.failUnless(events == ['roster_callback'], "Roster timeout event not triggered: %s." % events) @@ -235,9 +204,6 @@ class TestStreamRoster(SleekTest): </iq> """) - # Give the event queue time to process. - time.sleep(.1) - self.check_roster('tester@localhost', 'andré@foo', subscription='both', groups=['Unicode']) @@ -253,9 +219,6 @@ class TestStreamRoster(SleekTest): </presence> """) - # Give the event queue time to process. - time.sleep(.1) - result = self.xmpp.client_roster['andré@foo'].resources expected = {'bar': {'status':'Testing', 'show':'away', @@ -298,8 +261,8 @@ class TestStreamRoster(SleekTest): self.stream_start() self.assertTrue('rosterver' not in self.xmpp.features) - t = threading.Thread(name='get_roster', target=self.xmpp.get_roster) - t.start() + self.xmpp.get_roster() + self.send(""" <iq type="get" id="1"> <query xmlns="jabber:iq:roster" /> @@ -309,16 +272,14 @@ class TestStreamRoster(SleekTest): <iq to="tester@localhost" type="result" id="1" /> """) - t.join() - def testBootstrapRosterVer(self): """Test bootstrapping with roster versioning.""" self.stream_start() self.xmpp.features.add('rosterver') self.xmpp.client_roster.version = '' - t = threading.Thread(name='get_roster', target=self.xmpp.get_roster) - t.start() + self.xmpp.get_roster() + self.send(""" <iq type="get" id="1"> <query xmlns="jabber:iq:roster" ver="" /> @@ -328,8 +289,6 @@ class TestStreamRoster(SleekTest): <iq to="tester@localhost" type="result" id="1" /> """) - t.join() - def testExistingRosterVer(self): """Test using a stored roster version.""" @@ -337,8 +296,8 @@ class TestStreamRoster(SleekTest): self.xmpp.features.add('rosterver') self.xmpp.client_roster.version = '42' - t = threading.Thread(name='get_roster', target=self.xmpp.get_roster) - t.start() + self.xmpp.get_roster() + self.send(""" <iq type="get" id="1"> <query xmlns="jabber:iq:roster" ver="42" /> @@ -348,7 +307,5 @@ class TestStreamRoster(SleekTest): <iq to="tester@localhost" type="result" id="1" /> """) - t.join() - suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamRoster) diff --git a/tests/test_stream_xep_0030.py b/tests/test_stream_xep_0030.py index 37d29d33..de0bd414 100644 --- a/tests/test_stream_xep_0030.py +++ b/tests/test_stream_xep_0030.py @@ -2,10 +2,10 @@ import time import threading import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestStreamDisco(SleekTest): +class TestStreamDisco(SlixTest): """ Test using the XEP-0030 plugin. @@ -75,7 +75,7 @@ class TestStreamDisco(SleekTest): self.xmpp['xep_0030'].static.add_node(node='testing') self.recv(""" - <iq to="tester@localhost" type="get" id="test"> + <iq to="tester@localhost/resource" type="get" id="test"> <query xmlns="http://jabber.org/protocol/disco#info" node="testing" /> </iq> @@ -101,7 +101,7 @@ class TestStreamDisco(SleekTest): self.xmpp['xep_0030'].static.add_node(node='testing') self.recv(""" - <iq to="tester@localhost" type="get" id="test"> + <iq to="tester@localhost/resource" type="get" id="test"> <query xmlns="http://jabber.org/protocol/disco#items" node="testing" /> </iq> @@ -288,10 +288,7 @@ class TestStreamDisco(SleekTest): self.xmpp.add_event_handler('disco_info', handle_disco_info) - t = threading.Thread(name="get_info", - target=self.xmpp['xep_0030'].get_info, - args=('user@localhost', 'foo')) - t.start() + self.xmpp['xep_0030'].get_info('user@localhost', 'foo') self.send(""" <iq type="get" to="user@localhost" id="1"> @@ -310,11 +307,6 @@ class TestStreamDisco(SleekTest): </iq> """) - # Wait for disco#info request to be received. - t.join() - - time.sleep(0.1) - self.assertEqual(events, set(('disco_info',)), "Disco info event was not triggered: %s" % events) @@ -491,10 +483,7 @@ class TestStreamDisco(SleekTest): self.xmpp.add_event_handler('disco_items', handle_disco_items) - t = threading.Thread(name="get_items", - target=self.xmpp['xep_0030'].get_items, - args=('user@localhost', 'foo')) - t.start() + self.xmpp['xep_0030'].get_items('user@localhost', 'foo') self.send(""" <iq type="get" to="user@localhost" id="1"> @@ -513,11 +502,6 @@ class TestStreamDisco(SleekTest): </iq> """) - # Wait for disco#items request to be received. - t.join() - - time.sleep(0.1) - items = set([('user@localhost', 'bar', 'Test'), ('user@localhost', 'baz', 'Test 2')]) self.assertEqual(events, set(('disco_items',)), @@ -525,6 +509,7 @@ class TestStreamDisco(SleekTest): self.assertEqual(results, items, "Unexpected items: %s" % results) + ''' def testGetItemsIterator(self): """Test interaction between XEP-0030 and XEP-0059 plugins.""" @@ -571,6 +556,7 @@ class TestStreamDisco(SleekTest): self.assertEqual(raised_exceptions, [True], "StopIteration was not raised: %s" % raised_exceptions) + ''' suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamDisco) diff --git a/tests/test_stream_xep_0047.py b/tests/test_stream_xep_0047.py index 0515bca5..ecba2445 100644 --- a/tests/test_stream_xep_0047.py +++ b/tests/test_stream_xep_0047.py @@ -1,11 +1,12 @@ +import asyncio import threading import time import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestInBandByteStreams(SleekTest): +class TestInBandByteStreams(SlixTest): def setUp(self): self.stream_start(plugins=['xep_0047', 'xep_0030']) @@ -24,11 +25,8 @@ class TestInBandByteStreams(SleekTest): self.xmpp.add_event_handler('ibb_stream_start', on_stream_start) - t = threading.Thread(name='open_stream', - target=self.xmpp['xep_0047'].open_stream, - args=('tester@localhost/receiver',), - kwargs={'sid': 'testing'}) - t.start() + self.xmpp['xep_0047'].open_stream('tester@localhost/receiver', + sid='testing') self.send(""" <iq type="set" to="tester@localhost/receiver" id="1"> @@ -45,10 +43,6 @@ class TestInBandByteStreams(SleekTest): from="tester@localhost/receiver" /> """) - t.join() - - time.sleep(0.2) - self.assertEqual(events, ['ibb_stream_start']) def testAysncOpenStream(self): @@ -64,13 +58,9 @@ class TestInBandByteStreams(SleekTest): self.xmpp.add_event_handler('ibb_stream_start', on_stream_start) - t = threading.Thread(name='open_stream', - target=self.xmpp['xep_0047'].open_stream, - args=('tester@localhost/receiver',), - kwargs={'sid': 'testing', - 'block': False, - 'callback': stream_callback}) - t.start() + self.xmpp['xep_0047'].open_stream('tester@localhost/receiver', + sid='testing', + callback=stream_callback) self.send(""" <iq type="set" to="tester@localhost/receiver" id="1"> @@ -87,12 +77,9 @@ class TestInBandByteStreams(SleekTest): from="tester@localhost/receiver" /> """) - t.join() - - time.sleep(0.2) - self.assertEqual(events, set(['ibb_stream_start', 'callback'])) + @asyncio.coroutine def testSendData(self): """Test sending data over an in-band bytestream.""" @@ -108,11 +95,8 @@ class TestInBandByteStreams(SleekTest): self.xmpp.add_event_handler('ibb_stream_start', on_stream_start) self.xmpp.add_event_handler('ibb_stream_data', on_stream_data) - t = threading.Thread(name='open_stream', - target=self.xmpp['xep_0047'].open_stream, - args=('tester@localhost/receiver',), - kwargs={'sid': 'testing'}) - t.start() + self.xmpp['xep_0047'].open_stream('tester@localhost/receiver', + sid='testing') self.send(""" <iq type="set" to="tester@localhost/receiver" id="1"> @@ -129,15 +113,11 @@ class TestInBandByteStreams(SleekTest): from="tester@localhost/receiver" /> """) - t.join() - - time.sleep(0.2) - stream = streams[0] # Test sending data out - stream.send("Testing") + yield from stream.send("Testing") self.send(""" <iq type="set" id="2" diff --git a/tests/test_stream_xep_0050.py b/tests/test_stream_xep_0050.py index e38c4add..6ebf88a9 100644 --- a/tests/test_stream_xep_0050.py +++ b/tests/test_stream_xep_0050.py @@ -2,11 +2,11 @@ import time import logging import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp.xmlstream import ElementBase, register_stanza_plugin +from slixmpp.test import SlixTest +from slixmpp.xmlstream import ElementBase, register_stanza_plugin -class TestAdHocCommands(SleekTest): +class TestAdHocCommands(SlixTest): def setUp(self): self.stream_start(mode='client', @@ -626,9 +626,6 @@ class TestAdHocCommands(SleekTest): </iq> """) - # Give the event queue time to process - time.sleep(0.3) - self.failUnless(results == ['foo', 'bar', 'baz'], 'Incomplete command workflow: %s' % results) @@ -692,9 +689,6 @@ class TestAdHocCommands(SleekTest): </iq> """) - # Give the event queue time to process - time.sleep(0.3) - self.failUnless(results == ['foo', 'bar'], 'Incomplete command workflow: %s' % results) @@ -733,9 +727,6 @@ class TestAdHocCommands(SleekTest): </iq> """) - # Give the event queue time to process - time.sleep(0.3) - self.failUnless(results == ['foo'], 'Incomplete command workflow: %s' % results) @@ -771,14 +762,8 @@ class TestAdHocCommands(SleekTest): </iq> """) - # Give the event queue time to process - time.sleep(0.3) - self.failUnless(results == ['foo'], 'Incomplete command workflow: %s' % results) - - - suite = unittest.TestLoader().loadTestsFromTestCase(TestAdHocCommands) diff --git a/tests/test_stream_xep_0059.py b/tests/test_stream_xep_0059.py deleted file mode 100644 index 5f3ea079..00000000 --- a/tests/test_stream_xep_0059.py +++ /dev/null @@ -1,163 +0,0 @@ -import threading - -import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp.xmlstream import register_stanza_plugin -from sleekxmpp.plugins.xep_0030 import DiscoItems -from sleekxmpp.plugins.xep_0059 import ResultIterator, Set - - -class TestStreamSet(SleekTest): - - 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) diff --git a/tests/test_stream_xep_0060.py b/tests/test_stream_xep_0060.py index 581d5d00..da543f96 100644 --- a/tests/test_stream_xep_0060.py +++ b/tests/test_stream_xep_0060.py @@ -1,12 +1,12 @@ import threading import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp.stanza.atom import AtomEntry -from sleekxmpp.xmlstream import register_stanza_plugin +from slixmpp.test import SlixTest +from slixmpp.stanza.atom import AtomEntry +from slixmpp.xmlstream import register_stanza_plugin -class TestStreamPubsub(SleekTest): +class TestStreamPubsub(SlixTest): """ Test using the XEP-0030 plugin. @@ -20,10 +20,7 @@ class TestStreamPubsub(SleekTest): def testCreateInstantNode(self): """Test creating an instant node""" - t = threading.Thread(name='create_node', - target=self.xmpp['xep_0060'].create_node, - args=('pubsub.example.com', None)) - t.start() + self.xmpp['xep_0060'].create_node('pubsub.example.com', None) self.send(""" <iq type="set" id="1" to="pubsub.example.com"> @@ -42,14 +39,11 @@ class TestStreamPubsub(SleekTest): </iq> """) - t.join() - def testCreateNodeNoConfig(self): """Test creating a node without a config""" self.xmpp['xep_0060'].create_node( 'pubsub.example.com', - 'princely_musings', - block=False) + 'princely_musings') self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -67,7 +61,7 @@ class TestStreamPubsub(SleekTest): self.xmpp['xep_0060'].create_node( 'pubsub.example.com', 'princely_musings', - config=form, block=False) + config=form) self.send(""" <iq type="set" id="1" to="pubsub.example.com"> @@ -91,8 +85,7 @@ class TestStreamPubsub(SleekTest): """Test deleting a node""" self.xmpp['xep_0060'].delete_node( 'pubsub.example.com', - 'some_node', - block=False) + 'some_node') self.send(""" <iq type="set" to="pubsub.example.com" id="1"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> @@ -108,8 +101,7 @@ class TestStreamPubsub(SleekTest): """ self.xmpp['xep_0060'].subscribe( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -126,8 +118,7 @@ class TestStreamPubsub(SleekTest): self.xmpp['xep_0060'].subscribe( 'pubsub.example.com', 'somenode', - ifrom='foo@comp.example.com/bar', - block=False) + ifrom='foo@comp.example.com/bar') self.send(""" <iq type="set" id="1" to="pubsub.example.com" from="foo@comp.example.com/bar"> @@ -146,8 +137,7 @@ class TestStreamPubsub(SleekTest): 'pubsub.example.com', 'somenode', ifrom='foo@comp.example.com/bar', - bare=False, - block=False) + bare=False) self.send(""" <iq type="set" id="1" to="pubsub.example.com" from="foo@comp.example.com/bar"> @@ -168,8 +158,7 @@ class TestStreamPubsub(SleekTest): self.xmpp['xep_0060'].subscribe( 'pubsub.example.com', 'somenode', - bare=False, - block=False) + bare=False) self.send(""" <iq type="set" id="1" to="pubsub.example.com"> @@ -188,8 +177,7 @@ class TestStreamPubsub(SleekTest): 'pubsub.example.com', 'somenode', subscribee='user@example.com/foo', - ifrom='foo@comp.example.com/bar', - block=False) + ifrom='foo@comp.example.com/bar') self.send(""" <iq type="set" id="1" to="pubsub.example.com" from="foo@comp.example.com/bar"> @@ -215,8 +203,7 @@ class TestStreamPubsub(SleekTest): self.xmpp['xep_0060'].subscribe( 'pubsub.example.com', 'somenode', - options=opts, - block=False) + options=opts) self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -242,8 +229,7 @@ class TestStreamPubsub(SleekTest): """ self.xmpp['xep_0060'].unsubscribe( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -260,8 +246,7 @@ class TestStreamPubsub(SleekTest): self.xmpp['xep_0060'].unsubscribe( 'pubsub.example.com', 'somenode', - ifrom='foo@comp.example.com/bar', - block=False) + ifrom='foo@comp.example.com/bar') self.send(""" <iq type="set" id="1" to="pubsub.example.com" from="foo@comp.example.com/bar"> @@ -280,8 +265,7 @@ class TestStreamPubsub(SleekTest): 'pubsub.example.com', 'somenode', ifrom='foo@comp.example.com/bar', - bare=False, - block=False) + bare=False) self.send(""" <iq type="set" id="1" to="pubsub.example.com" from="foo@comp.example.com/bar"> @@ -302,8 +286,7 @@ class TestStreamPubsub(SleekTest): self.xmpp['xep_0060'].unsubscribe( 'pubsub.example.com', 'somenode', - bare=False, - block=False) + bare=False) self.send(""" <iq type="set" id="1" to="pubsub.example.com"> @@ -322,8 +305,7 @@ class TestStreamPubsub(SleekTest): 'pubsub.example.com', 'somenode', subscribee='user@example.com/foo', - ifrom='foo@comp.example.com/bar', - block=False) + ifrom='foo@comp.example.com/bar') self.send(""" <iq type="set" id="1" to="pubsub.example.com" from="foo@comp.example.com/bar"> @@ -336,8 +318,7 @@ class TestStreamPubsub(SleekTest): def testGetDefaultNodeConfig(self): """Test retrieving the default node config for a pubsub service.""" self.xmpp['xep_0060'].get_node_config( - 'pubsub.example.com', - block=False) + 'pubsub.example.com') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> @@ -350,8 +331,7 @@ class TestStreamPubsub(SleekTest): """Test getting the config for a given node.""" self.xmpp['xep_0060'].get_node_config( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> @@ -372,8 +352,7 @@ class TestStreamPubsub(SleekTest): self.xmpp['xep_0060'].set_node_config( 'pubsub.example.com', 'somenode', - form, - block=False) + form) self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> @@ -395,8 +374,7 @@ class TestStreamPubsub(SleekTest): """Test publishing no items (in order to generate events)""" self.xmpp['xep_0060'].publish( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -416,8 +394,7 @@ class TestStreamPubsub(SleekTest): 'pubsub.example.com', 'somenode', id='id42', - payload=payload, - block=False) + payload=payload) self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -451,8 +428,7 @@ class TestStreamPubsub(SleekTest): 'somenode', id='ID42', payload=payload, - options=options, - block=False) + options=options) self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -483,8 +459,7 @@ class TestStreamPubsub(SleekTest): 'pubsub.example.com', 'somenode', 'ID1', - notify=True, - block=False) + notify=True) self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -500,8 +475,7 @@ class TestStreamPubsub(SleekTest): self.xmpp['xep_0060'].retract( 'pubsub.example.com', 'somenode', - 'ID1', - block=False) + 'ID1') self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -516,8 +490,7 @@ class TestStreamPubsub(SleekTest): """Test removing all items from a node.""" self.xmpp['xep_0060'].purge( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> @@ -531,8 +504,7 @@ class TestStreamPubsub(SleekTest): self.xmpp['xep_0060'].get_item( 'pubsub.example.com', 'somenode', - 'id42', - block=False) + 'id42') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -548,8 +520,7 @@ class TestStreamPubsub(SleekTest): self.xmpp['xep_0060'].get_items( 'pubsub.example.com', 'somenode', - max_items=3, - block=False) + max_items=3) self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -562,8 +533,7 @@ class TestStreamPubsub(SleekTest): """Test retrieving all items.""" self.xmpp['xep_0060'].get_items( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -577,8 +547,7 @@ class TestStreamPubsub(SleekTest): self.xmpp['xep_0060'].get_items( 'pubsub.example.com', 'somenode', - item_ids=['A', 'B', 'C'], - block=False) + item_ids=['A', 'B', 'C']) self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -594,8 +563,7 @@ class TestStreamPubsub(SleekTest): def testGetSubscriptionGlobalDefaultOptions(self): """Test getting the subscription options for a node/JID.""" self.xmpp['xep_0060'].get_subscription_options( - 'pubsub.example.com', - block=False) + 'pubsub.example.com') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -608,8 +576,7 @@ class TestStreamPubsub(SleekTest): """Test getting the subscription options for a node/JID.""" self.xmpp['xep_0060'].get_subscription_options( 'pubsub.example.com', - node='somenode', - block=False) + node='somenode') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -623,8 +590,7 @@ class TestStreamPubsub(SleekTest): self.xmpp['xep_0060'].get_subscription_options( 'pubsub.example.com', 'somenode', - 'tester@localhost', - block=False) + 'tester@localhost') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -650,8 +616,7 @@ class TestStreamPubsub(SleekTest): 'pubsub.example.com', 'somenode', 'tester@localhost', - opts, - block=False) + opts) self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -673,8 +638,7 @@ class TestStreamPubsub(SleekTest): """Test retrieving all subscriptions for a node.""" self.xmpp['xep_0060'].get_node_subscriptions( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> @@ -686,8 +650,7 @@ class TestStreamPubsub(SleekTest): def testGetSubscriptions(self): """Test retrieving a users's subscriptions.""" self.xmpp['xep_0060'].get_subscriptions( - 'pubsub.example.com', - block=False) + 'pubsub.example.com') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -700,8 +663,7 @@ class TestStreamPubsub(SleekTest): """Test retrieving a users's subscriptions for a given node.""" self.xmpp['xep_0060'].get_subscriptions( 'pubsub.example.com', - node='somenode', - block=False) + node='somenode') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -713,8 +675,7 @@ class TestStreamPubsub(SleekTest): def testGetAffiliations(self): """Test retrieving a users's affiliations.""" self.xmpp['xep_0060'].get_affiliations( - 'pubsub.example.com', - block=False) + 'pubsub.example.com') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -727,8 +688,7 @@ class TestStreamPubsub(SleekTest): """Test retrieving a users's affiliations for a given node.""" self.xmpp['xep_0060'].get_affiliations( 'pubsub.example.com', - node='somenode', - block=False) + node='somenode') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub"> @@ -741,8 +701,7 @@ class TestStreamPubsub(SleekTest): """Test getting the affiliations for a node.""" self.xmpp['xep_0060'].get_node_affiliations( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" <iq type="get" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> @@ -757,8 +716,7 @@ class TestStreamPubsub(SleekTest): 'pubsub.example.com', 'somenode', subscriptions=[('user@example.com', 'subscribed'), - ('foo@example.net', 'none')], - block=False) + ('foo@example.net', 'none')]) self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> @@ -776,8 +734,7 @@ class TestStreamPubsub(SleekTest): 'pubsub.example.com', 'somenode', affiliations=[('user@example.com', 'publisher'), - ('foo@example.net', 'none')], - block=False) + ('foo@example.net', 'none')]) self.send(""" <iq type="set" id="1" to="pubsub.example.com"> <pubsub xmlns="http://jabber.org/protocol/pubsub#owner"> diff --git a/tests/test_stream_xep_0066.py b/tests/test_stream_xep_0066.py index 175026d2..159333c7 100644 --- a/tests/test_stream_xep_0066.py +++ b/tests/test_stream_xep_0066.py @@ -1,10 +1,10 @@ import threading import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestOOB(SleekTest): +class TestOOB(SlixTest): def tearDown(self): self.stream_close() @@ -13,21 +13,16 @@ class TestOOB(SleekTest): """Test sending an OOB transfer request.""" self.stream_start(plugins=['xep_0066', 'xep_0030']) - url = 'http://github.com/fritzy/SleekXMPP/blob/master/README' + url = 'http://github.com/fritzy/Slixmpp/blob/master/README' - t = threading.Thread( - name='send_oob', - target=self.xmpp['xep_0066'].send_oob, - args=('user@example.com', url), - kwargs={'desc': 'SleekXMPP README'}) - - t.start() + self.xmpp['xep_0066'].send_oob('user@example.com', url, + desc='Slixmpp README') self.send(""" <iq to="user@example.com" type="set" id="1"> <query xmlns="jabber:iq:oob"> - <url>http://github.com/fritzy/SleekXMPP/blob/master/README</url> - <desc>SleekXMPP README</desc> + <url>http://github.com/fritzy/Slixmpp/blob/master/README</url> + <desc>Slixmpp README</desc> </query> </iq> """) @@ -38,7 +33,5 @@ class TestOOB(SleekTest): from="user@example.com" /> """) - t.join() - suite = unittest.TestLoader().loadTestsFromTestCase(TestOOB) diff --git a/tests/test_stream_xep_0085.py b/tests/test_stream_xep_0085.py index 54e7e15f..9e3a2dd5 100644 --- a/tests/test_stream_xep_0085.py +++ b/tests/test_stream_xep_0085.py @@ -1,10 +1,10 @@ import time import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestStreamChatStates(SleekTest): +class TestStreamChatStates(SlixTest): def tearDown(self): self.stream_close() @@ -49,8 +49,6 @@ class TestStreamChatStates(SleekTest): </message> """) - # Give event queue time to process - time.sleep(0.3) expected = ['active', 'inactive', 'paused', 'composing', 'gone'] self.failUnless(results == expected, "Chat state event not handled: %s" % results) diff --git a/tests/test_stream_xep_0092.py b/tests/test_stream_xep_0092.py index c0748697..1f1eac00 100644 --- a/tests/test_stream_xep_0092.py +++ b/tests/test_stream_xep_0092.py @@ -1,10 +1,10 @@ import threading import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestStreamSet(SleekTest): +class TestStreamSet(SlixTest): def tearDown(self): self.stream_close() @@ -12,7 +12,7 @@ class TestStreamSet(SleekTest): def testHandleSoftwareVersionRequest(self): self.stream_start(mode='client', plugins=['xep_0030', 'xep_0092']) - self.xmpp['xep_0092'].name = 'SleekXMPP' + self.xmpp['xep_0092'].name = 'Slixmpp' self.xmpp['xep_0092'].version = 'dev' self.xmpp['xep_0092'].os = 'Linux' @@ -25,7 +25,7 @@ class TestStreamSet(SleekTest): self.send(""" <iq type="result" id="1"> <query xmlns="jabber:iq:version"> - <name>SleekXMPP</name> + <name>Slixmpp</name> <version>dev</version> <os>Linux</os> </query> @@ -35,16 +35,14 @@ class TestStreamSet(SleekTest): def testMakeSoftwareVersionRequest(self): results = [] - def query(): - r = self.xmpp['xep_0092'].get_version('foo@bar') - results.append((r['software_version']['name'], - r['software_version']['version'], - r['software_version']['os'])) + def callback(result): + results.append((result['software_version']['name'], + result['software_version']['version'], + result['software_version']['os'])) self.stream_start(mode='client', plugins=['xep_0030', 'xep_0092']) - t = threading.Thread(target=query) - t.start() + self.xmpp['xep_0092'].get_version('foo@bar', callback=callback) self.send(""" <iq type="get" id="1" to="foo@bar"> @@ -62,8 +60,6 @@ class TestStreamSet(SleekTest): </iq> """) - t.join() - expected = [('Foo', '1.0', 'Linux')] self.assertEqual(results, expected, "Did not receive expected results: %s" % results) diff --git a/tests/test_stream_xep_0128.py b/tests/test_stream_xep_0128.py index 10222d9b..1c1da88f 100644 --- a/tests/test_stream_xep_0128.py +++ b/tests/test_stream_xep_0128.py @@ -1,8 +1,8 @@ import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestStreamExtendedDisco(SleekTest): +class TestStreamExtendedDisco(SlixTest): """ Test using the XEP-0128 plugin. diff --git a/tests/test_stream_xep_0249.py b/tests/test_stream_xep_0249.py index 8edea270..f12978a8 100644 --- a/tests/test_stream_xep_0249.py +++ b/tests/test_stream_xep_0249.py @@ -1,10 +1,10 @@ import time import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestStreamDirectInvite(SleekTest): +class TestStreamDirectInvite(SlixTest): """ Test using the XEP-0249 plugin. @@ -35,8 +35,6 @@ class TestStreamDirectInvite(SleekTest): </message> """) - time.sleep(.5) - self.failUnless(events == [True], "Event not raised: %s" % events) @@ -47,13 +45,13 @@ class TestStreamDirectInvite(SleekTest): self.xmpp['xep_0249'].send_invitation('user@example.com', 'sleek@conference.jabber.org', - reason='Need to test Sleek') + reason='Need to test Slixmpp') self.send(""" <message to="user@example.com"> <x xmlns="jabber:x:conference" jid="sleek@conference.jabber.org" - reason="Need to test Sleek" /> + reason="Need to test Slixmpp" /> </message> """) diff --git a/tests/test_stream_xep_0323.py b/tests/test_stream_xep_0323.py index 94f1d638..42230e1f 100644 --- a/tests/test_stream_xep_0323.py +++ b/tests/test_stream_xep_0323.py @@ -5,12 +5,12 @@ import datetime import time import threading -from sleekxmpp.test import * -from sleekxmpp.xmlstream import ElementBase -from sleekxmpp.plugins.xep_0323.device import Device +from slixmpp.test import * +from slixmpp.xmlstream import ElementBase +from slixmpp.plugins.xep_0323.device import Device -class TestStreamSensorData(SleekTest): +class TestStreamSensorData(SlixTest): """ Test using the XEP-0323 plugin. @@ -455,8 +455,6 @@ class TestStreamSensorData(SleekTest): </iq> """) - time.sleep(.1) - self.failUnless(results == ["rejected"], "Rejected callback was not properly executed") @@ -494,8 +492,6 @@ class TestStreamSensorData(SleekTest): </iq> """) - time.sleep(.1) - self.failUnless(results == ["accepted"], "Accepted callback was not properly executed") @@ -517,13 +513,10 @@ class TestStreamSensorData(SleekTest): for f in fields: callback_data["field_" + f['name']] = f - t1= threading.Thread(name="request_data", - target=self.xmpp['xep_0323'].request_data, - kwargs={"from_jid": "tester@localhost", - "to_jid": "you@google.com", - "nodeIds": ['Device33'], - "callback": my_callback}) - t1.start() + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", + to_jid="you@google.com", + nodeIds=['Device33'], + callback=my_callback) #self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); self.send(""" @@ -567,9 +560,6 @@ class TestStreamSensorData(SleekTest): </message> """) - t1.join() - time.sleep(.5) - self.failUnlessEqual(results, ["accepted","fields","done"]) # self.assertIn("nodeId", callback_data); self.assertTrue("nodeId" in callback_data) @@ -592,7 +582,7 @@ class TestStreamSensorData(SleekTest): self.recv(""" <iq type='get' from='master@clayster.com/amr' - to='tester@localhost' + to='tester@localhost/resource' id='disco1'> <query xmlns='http://jabber.org/protocol/disco#info'/> </iq> @@ -617,7 +607,7 @@ class TestStreamSensorData(SleekTest): self.recv(""" <iq type='get' from='master@clayster.com/amr' - to='tester@localhost' + to='tester@localhost/resource' id='disco1'> <query xmlns='http://jabber.org/protocol/disco#info'/> </iq> @@ -625,7 +615,7 @@ class TestStreamSensorData(SleekTest): self.send(""" <iq type='result' - from='tester@localhost' + from='tester@localhost/resource' to='master@clayster.com/amr' id='disco1'> <query xmlns='http://jabber.org/protocol/disco#info'> @@ -651,14 +641,10 @@ class TestStreamSensorData(SleekTest): callback_data["timestamp"] = timestamp callback_data["error_msg"] = error_msg - t1= threading.Thread(name="request_data", - target=self.xmpp['xep_0323'].request_data, - kwargs={"from_jid": "tester@localhost", - "to_jid": "you@google.com", - "nodeIds": ['Device33'], - "callback": my_callback}) - t1.start() - + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", + to_jid="you@google.com", + nodeIds=['Device33'], + callback=my_callback) self.send(""" <iq type='get' from='tester@localhost' @@ -688,10 +674,7 @@ class TestStreamSensorData(SleekTest): </message> """) - t1.join() - time.sleep(.5) - - self.failUnlessEqual(results, ["accepted","failure"]) + self.failUnlessEqual(results, ["accepted","failure"]); # self.assertIn("nodeId", callback_data); self.assertTrue("nodeId" in callback_data) self.failUnlessEqual(callback_data["nodeId"], "Device33") @@ -737,7 +720,7 @@ class TestStreamSensorData(SleekTest): </iq> """) - time.sleep(2) + time.sleep(1) self.send(""" <message from='device@clayster.com' @@ -1033,13 +1016,10 @@ class TestStreamSensorData(SleekTest): for f in fields: callback_data["field_" + f['name']] = f - t1= threading.Thread(name="request_data", - target=self.xmpp['xep_0323'].request_data, - kwargs={"from_jid": "tester@localhost", - "to_jid": "you@google.com", - "nodeIds": ['Device33'], - "callback": my_callback}) - t1.start() + self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", + to_jid="you@google.com", + nodeIds=['Device33'], + callback=my_callback) #self.xmpp['xep_0323'].request_data(from_jid="tester@localhost", to_jid="you@google.com", nodeIds=['Device33'], callback=my_callback); self.send(""" @@ -1090,10 +1070,7 @@ class TestStreamSensorData(SleekTest): </message> """) - t1.join() - time.sleep(.5) - - self.failUnlessEqual(results, ["queued","started","fields","done"]) + self.failUnlessEqual(results, ["queued","started","fields","done"]); # self.assertIn("nodeId", callback_data); self.assertTrue("nodeId" in callback_data) self.failUnlessEqual(callback_data["nodeId"], "Device33") @@ -1161,8 +1138,6 @@ class TestStreamSensorData(SleekTest): </iq> """) - time.sleep(.5) - self.failUnlessEqual(results, ["accepted","cancelled"]) def testDelayedRequestCancel(self): @@ -1239,8 +1214,6 @@ class TestStreamSensorData(SleekTest): </iq> """) - time.sleep(2) - # Ensure we don't get anything after cancellation self.send(None) diff --git a/tests/test_stream_xep_0325.py b/tests/test_stream_xep_0325.py index 2ebdd121..600bfa64 100644 --- a/tests/test_stream_xep_0325.py +++ b/tests/test_stream_xep_0325.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ - SleekXMPP: The Sleek XMPP Library + Slixmpp: The Slick XMPP Library Implementation of xeps for Internet of Things http://wiki.xmpp.org/web/Tech_pages/IoT_systems Copyright (C) 2013 Sustainable Innovation, Joachim.lindborg@sust.se, bjorn.westrom@consoden.se - This file is part of SleekXMPP. + This file is part of Slixmpp. See the file LICENSE for copying permission. """ @@ -14,12 +14,12 @@ import datetime import time import threading -from sleekxmpp.test import * -from sleekxmpp.xmlstream import ElementBase -from sleekxmpp.plugins.xep_0325.device import Device +from slixmpp.test import * +from slixmpp.xmlstream import ElementBase +from slixmpp.plugins.xep_0325.device import Device -class TestStreamControl(SleekTest): +class TestStreamControl(SlixTest): """ Test using the XEP-0325 plugin. @@ -189,7 +189,7 @@ class TestStreamControl(SleekTest): </message> """) - time.sleep(.5) + time.sleep(0.5) self.assertEqual(myDevice._get_field_value("Temperature"), "17") @@ -213,10 +213,8 @@ class TestStreamControl(SleekTest): </message> """) - time.sleep(.5) - - self.assertEqual(myDevice._get_field_value("Temperature"), "15") - self.assertFalse(myDevice.has_control_field("Voltage", "int")) + self.assertEqual(myDevice._get_field_value("Temperature"), "15"); + self.assertFalse(myDevice.has_control_field("Voltage", "int")); def testRequestSetOkAPI(self): @@ -259,9 +257,7 @@ class TestStreamControl(SleekTest): </iq> """) - time.sleep(.5) - - self.assertEqual(results, ["OK"]) + self.assertEqual(results, ["OK"]); def testRequestSetErrorAPI(self): @@ -305,8 +301,6 @@ class TestStreamControl(SleekTest): </iq> """) - time.sleep(.5) - self.assertEqual(results, ["OtherError"]) def testServiceDiscoveryClient(self): @@ -317,7 +311,7 @@ class TestStreamControl(SleekTest): self.recv(""" <iq type='get' from='master@clayster.com/amr' - to='tester@localhost' + to='tester@localhost/resource' id='disco1'> <query xmlns='http://jabber.org/protocol/disco#info'/> </iq> @@ -342,7 +336,7 @@ class TestStreamControl(SleekTest): self.recv(""" <iq type='get' from='master@clayster.com/amr' - to='tester@localhost' + to='tester@localhost/resource' id='disco1'> <query xmlns='http://jabber.org/protocol/disco#info'/> </iq> @@ -350,7 +344,7 @@ class TestStreamControl(SleekTest): self.send(""" <iq type='result' - from='tester@localhost' + from='tester@localhost/resource' to='master@clayster.com/amr' id='disco1'> <query xmlns='http://jabber.org/protocol/disco#info'> diff --git a/tests/test_tostring.py b/tests/test_tostring.py index e6148533..72718beb 100644 --- a/tests/test_tostring.py +++ b/tests/test_tostring.py @@ -1,13 +1,13 @@ import unittest -from sleekxmpp.test import SleekTest -from sleekxmpp.xmlstream.stanzabase import ET -from sleekxmpp.xmlstream.tostring import tostring, escape +from slixmpp.test import SlixTest +from slixmpp.xmlstream.stanzabase import ET +from slixmpp.xmlstream.tostring import tostring, escape -class TestToString(SleekTest): +class TestToString(SlixTest): """ - Test the implementation of sleekxmpp.xmlstream.tostring + Test the implementation of slixmpp.xmlstream.tostring """ def tearDown(self): |