From 1e2665df19a866d5676abec566b9d8f190ecdc80 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 12 Feb 2015 12:23:47 +0100 Subject: 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 --- tests/test_stream_xep_0060.py | 123 ++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 83 deletions(-) (limited to 'tests/test_stream_xep_0060.py') diff --git a/tests/test_stream_xep_0060.py b/tests/test_stream_xep_0060.py index 17cb5b2c..da543f96 100644 --- a/tests/test_stream_xep_0060.py +++ b/tests/test_stream_xep_0060.py @@ -20,10 +20,7 @@ class TestStreamPubsub(SlixTest): 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(""" @@ -42,14 +39,11 @@ class TestStreamPubsub(SlixTest): """) - 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(""" @@ -67,7 +61,7 @@ class TestStreamPubsub(SlixTest): self.xmpp['xep_0060'].create_node( 'pubsub.example.com', 'princely_musings', - config=form, block=False) + config=form) self.send(""" @@ -91,8 +85,7 @@ class TestStreamPubsub(SlixTest): """Test deleting a node""" self.xmpp['xep_0060'].delete_node( 'pubsub.example.com', - 'some_node', - block=False) + 'some_node') self.send(""" @@ -108,8 +101,7 @@ class TestStreamPubsub(SlixTest): """ self.xmpp['xep_0060'].subscribe( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" @@ -126,8 +118,7 @@ class TestStreamPubsub(SlixTest): 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(""" @@ -146,8 +137,7 @@ class TestStreamPubsub(SlixTest): 'pubsub.example.com', 'somenode', ifrom='foo@comp.example.com/bar', - bare=False, - block=False) + bare=False) self.send(""" @@ -168,8 +158,7 @@ class TestStreamPubsub(SlixTest): self.xmpp['xep_0060'].subscribe( 'pubsub.example.com', 'somenode', - bare=False, - block=False) + bare=False) self.send(""" @@ -188,8 +177,7 @@ class TestStreamPubsub(SlixTest): '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(""" @@ -215,8 +203,7 @@ class TestStreamPubsub(SlixTest): self.xmpp['xep_0060'].subscribe( 'pubsub.example.com', 'somenode', - options=opts, - block=False) + options=opts) self.send(""" @@ -242,8 +229,7 @@ class TestStreamPubsub(SlixTest): """ self.xmpp['xep_0060'].unsubscribe( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" @@ -260,8 +246,7 @@ class TestStreamPubsub(SlixTest): 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(""" @@ -280,8 +265,7 @@ class TestStreamPubsub(SlixTest): 'pubsub.example.com', 'somenode', ifrom='foo@comp.example.com/bar', - bare=False, - block=False) + bare=False) self.send(""" @@ -302,8 +286,7 @@ class TestStreamPubsub(SlixTest): self.xmpp['xep_0060'].unsubscribe( 'pubsub.example.com', 'somenode', - bare=False, - block=False) + bare=False) self.send(""" @@ -322,8 +305,7 @@ class TestStreamPubsub(SlixTest): '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(""" @@ -336,8 +318,7 @@ class TestStreamPubsub(SlixTest): 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(""" @@ -350,8 +331,7 @@ class TestStreamPubsub(SlixTest): """Test getting the config for a given node.""" self.xmpp['xep_0060'].get_node_config( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" @@ -372,8 +352,7 @@ class TestStreamPubsub(SlixTest): self.xmpp['xep_0060'].set_node_config( 'pubsub.example.com', 'somenode', - form, - block=False) + form) self.send(""" @@ -395,8 +374,7 @@ class TestStreamPubsub(SlixTest): """Test publishing no items (in order to generate events)""" self.xmpp['xep_0060'].publish( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" @@ -416,8 +394,7 @@ class TestStreamPubsub(SlixTest): 'pubsub.example.com', 'somenode', id='id42', - payload=payload, - block=False) + payload=payload) self.send(""" @@ -451,8 +428,7 @@ class TestStreamPubsub(SlixTest): 'somenode', id='ID42', payload=payload, - options=options, - block=False) + options=options) self.send(""" @@ -483,8 +459,7 @@ class TestStreamPubsub(SlixTest): 'pubsub.example.com', 'somenode', 'ID1', - notify=True, - block=False) + notify=True) self.send(""" @@ -500,8 +475,7 @@ class TestStreamPubsub(SlixTest): self.xmpp['xep_0060'].retract( 'pubsub.example.com', 'somenode', - 'ID1', - block=False) + 'ID1') self.send(""" @@ -516,8 +490,7 @@ class TestStreamPubsub(SlixTest): """Test removing all items from a node.""" self.xmpp['xep_0060'].purge( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" @@ -531,8 +504,7 @@ class TestStreamPubsub(SlixTest): self.xmpp['xep_0060'].get_item( 'pubsub.example.com', 'somenode', - 'id42', - block=False) + 'id42') self.send(""" @@ -548,8 +520,7 @@ class TestStreamPubsub(SlixTest): self.xmpp['xep_0060'].get_items( 'pubsub.example.com', 'somenode', - max_items=3, - block=False) + max_items=3) self.send(""" @@ -562,8 +533,7 @@ class TestStreamPubsub(SlixTest): """Test retrieving all items.""" self.xmpp['xep_0060'].get_items( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" @@ -577,8 +547,7 @@ class TestStreamPubsub(SlixTest): self.xmpp['xep_0060'].get_items( 'pubsub.example.com', 'somenode', - item_ids=['A', 'B', 'C'], - block=False) + item_ids=['A', 'B', 'C']) self.send(""" @@ -594,8 +563,7 @@ class TestStreamPubsub(SlixTest): 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(""" @@ -608,8 +576,7 @@ class TestStreamPubsub(SlixTest): """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(""" @@ -623,8 +590,7 @@ class TestStreamPubsub(SlixTest): self.xmpp['xep_0060'].get_subscription_options( 'pubsub.example.com', 'somenode', - 'tester@localhost', - block=False) + 'tester@localhost') self.send(""" @@ -650,8 +616,7 @@ class TestStreamPubsub(SlixTest): 'pubsub.example.com', 'somenode', 'tester@localhost', - opts, - block=False) + opts) self.send(""" @@ -673,8 +638,7 @@ class TestStreamPubsub(SlixTest): """Test retrieving all subscriptions for a node.""" self.xmpp['xep_0060'].get_node_subscriptions( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" @@ -686,8 +650,7 @@ class TestStreamPubsub(SlixTest): 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(""" @@ -700,8 +663,7 @@ class TestStreamPubsub(SlixTest): """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(""" @@ -713,8 +675,7 @@ class TestStreamPubsub(SlixTest): 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(""" @@ -727,8 +688,7 @@ class TestStreamPubsub(SlixTest): """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(""" @@ -741,8 +701,7 @@ class TestStreamPubsub(SlixTest): """Test getting the affiliations for a node.""" self.xmpp['xep_0060'].get_node_affiliations( 'pubsub.example.com', - 'somenode', - block=False) + 'somenode') self.send(""" @@ -757,8 +716,7 @@ class TestStreamPubsub(SlixTest): 'pubsub.example.com', 'somenode', subscriptions=[('user@example.com', 'subscribed'), - ('foo@example.net', 'none')], - block=False) + ('foo@example.net', 'none')]) self.send(""" @@ -776,8 +734,7 @@ class TestStreamPubsub(SlixTest): 'pubsub.example.com', 'somenode', affiliations=[('user@example.com', 'publisher'), - ('foo@example.net', 'none')], - block=False) + ('foo@example.net', 'none')]) self.send(""" -- cgit v1.2.3