Simplify pubsub tests.
We don't really care about empty responses, so let's use block=False.
This commit is contained in:
parent
3f9ca0366b
commit
d2dc4824ee
@ -47,11 +47,10 @@ class TestStreamPubsub(SleekTest):
|
|||||||
|
|
||||||
def testCreateNodeNoConfig(self):
|
def testCreateNodeNoConfig(self):
|
||||||
"""Test creating a node without a config"""
|
"""Test creating a node without a config"""
|
||||||
t = threading.Thread(name='create_node',
|
self.xmpp['xep_0060'].create_node(
|
||||||
target=self.xmpp['xep_0060'].create_node,
|
'pubsub.example.com',
|
||||||
args=('pubsub.example.com', 'princely_musings'))
|
'princely_musings',
|
||||||
t.start()
|
block=False)
|
||||||
|
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="set" id="1" to="pubsub.example.com">
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
@ -60,24 +59,16 @@ class TestStreamPubsub(SleekTest):
|
|||||||
</iq>
|
</iq>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
self.recv("""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
def testCreateNodeConfig(self):
|
def testCreateNodeConfig(self):
|
||||||
"""Test creating a node with a config"""
|
"""Test creating a node with a config"""
|
||||||
form = self.xmpp['xep_0004'].stanza.Form()
|
form = self.xmpp['xep_0004'].stanza.Form()
|
||||||
form['type'] = 'submit'
|
form['type'] = 'submit'
|
||||||
form.add_field(var='pubsub#access_model', value='whitelist')
|
form.add_field(var='pubsub#access_model', value='whitelist')
|
||||||
|
|
||||||
t = threading.Thread(name='create_node',
|
self.xmpp['xep_0060'].create_node(
|
||||||
target=self.xmpp['xep_0060'].create_node,
|
'pubsub.example.com',
|
||||||
args=('pubsub.example.com', 'princely_musings'),
|
'princely_musings',
|
||||||
kwargs={'config': form})
|
config=form, block=False)
|
||||||
t.start()
|
|
||||||
|
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="set" id="1" to="pubsub.example.com">
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
@ -97,20 +88,12 @@ class TestStreamPubsub(SleekTest):
|
|||||||
</iq>
|
</iq>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
self.recv("""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
def testDeleteNode(self):
|
def testDeleteNode(self):
|
||||||
"""Test deleting a node"""
|
"""Test deleting a node"""
|
||||||
t = threading.Thread(name='delete_node',
|
self.xmpp['xep_0060'].delete_node(
|
||||||
target=self.xmpp['xep_0060'].delete_node,
|
'pubsub.example.com',
|
||||||
args=('pubsub.example.com', 'some_node'))
|
'some_node',
|
||||||
t.start()
|
block=False)
|
||||||
|
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="set" to="pubsub.example.com" id="1">
|
<iq type="set" to="pubsub.example.com" id="1">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
||||||
@ -119,193 +102,210 @@ class TestStreamPubsub(SleekTest):
|
|||||||
</iq>
|
</iq>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
self.recv("""
|
def testSubscribeCase1(self):
|
||||||
<iq type="result" id="1"
|
"""
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
Test subscribing to a node: Case 1:
|
||||||
|
No subscribee, default 'from' JID, bare JID
|
||||||
|
"""
|
||||||
|
self.xmpp['xep_0060'].subscribe(
|
||||||
|
'pubsub.example.com',
|
||||||
|
'somenode',
|
||||||
|
block=False)
|
||||||
|
self.send("""
|
||||||
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
|
<subscribe node="somenode" jid="tester@localhost" />
|
||||||
|
</pubsub>
|
||||||
|
</iq>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
t.join()
|
def testSubscribeCase2(self):
|
||||||
|
"""
|
||||||
|
Test subscribing to a node: Case 2:
|
||||||
|
No subscribee, given 'from' JID, bare JID
|
||||||
|
"""
|
||||||
|
self.xmpp['xep_0060'].subscribe(
|
||||||
|
'pubsub.example.com',
|
||||||
|
'somenode',
|
||||||
|
ifrom='foo@comp.example.com/bar',
|
||||||
|
block=False)
|
||||||
|
self.send("""
|
||||||
|
<iq type="set" id="1"
|
||||||
|
to="pubsub.example.com" from="foo@comp.example.com/bar">
|
||||||
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
|
<subscribe node="somenode" jid="foo@comp.example.com" />
|
||||||
|
</pubsub>
|
||||||
|
</iq>
|
||||||
|
""")
|
||||||
|
|
||||||
def testSubscribe(self):
|
def testSubscribeCase3(self):
|
||||||
"""Test subscribing to a node"""
|
"""
|
||||||
|
Test subscribing to a node: Case 3:
|
||||||
|
No subscribee, given 'from' JID, full JID
|
||||||
|
"""
|
||||||
|
self.xmpp['xep_0060'].subscribe(
|
||||||
|
'pubsub.example.com',
|
||||||
|
'somenode',
|
||||||
|
ifrom='foo@comp.example.com/bar',
|
||||||
|
bare=False,
|
||||||
|
block=False)
|
||||||
|
self.send("""
|
||||||
|
<iq type="set" id="1"
|
||||||
|
to="pubsub.example.com" from="foo@comp.example.com/bar">
|
||||||
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
|
<subscribe node="somenode" jid="foo@comp.example.com/bar" />
|
||||||
|
</pubsub>
|
||||||
|
</iq>
|
||||||
|
""")
|
||||||
|
|
||||||
def run_test(jid, bare, ifrom, send, recv):
|
def testSubscribeCase4(self):
|
||||||
t = threading.Thread(name='subscribe',
|
"""
|
||||||
target=self.xmpp['xep_0060'].subscribe,
|
Test subscribing to a node: Case 4:
|
||||||
args=('pubsub.example.com', 'some_node'),
|
No subscribee, no 'from' JID, full JID
|
||||||
kwargs={'subscribee': jid,
|
"""
|
||||||
'bare': bare,
|
self.stream_close()
|
||||||
'ifrom': ifrom})
|
self.stream_start(jid='tester@localhost/full')
|
||||||
t.start()
|
|
||||||
self.send(send)
|
|
||||||
self.recv(recv)
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
# Case 1: No subscribee, default 'from' JID, bare JID
|
self.xmpp['xep_0060'].subscribe(
|
||||||
run_test(None, True, None,
|
'pubsub.example.com',
|
||||||
"""
|
'somenode',
|
||||||
<iq type="set" id="1" to="pubsub.example.com">
|
bare=False,
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
block=False)
|
||||||
<subscribe node="some_node" jid="tester@localhost" />
|
self.send("""
|
||||||
</pubsub>
|
<iq type="set" id="1"
|
||||||
</iq>
|
to="pubsub.example.com">
|
||||||
""",
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
"""
|
<subscribe node="somenode" jid="tester@localhost/full" />
|
||||||
<iq type="result" id="1"
|
</pubsub>
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
</iq>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
# Case 2: No subscribee, given 'from' JID, bare JID
|
def testSubscribeCase5(self):
|
||||||
run_test(None, True, 'foo@comp.example.com/bar',
|
"""
|
||||||
"""
|
Test subscribing to a node: Case 5:
|
||||||
<iq type="set" id="2"
|
Subscribee given
|
||||||
to="pubsub.example.com" from="foo@comp.example.com/bar">
|
"""
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
self.xmpp['xep_0060'].subscribe(
|
||||||
<subscribe node="some_node" jid="foo@comp.example.com" />
|
'pubsub.example.com',
|
||||||
</pubsub>
|
'somenode',
|
||||||
</iq>
|
subscribee='user@example.com/foo',
|
||||||
""",
|
ifrom='foo@comp.example.com/bar',
|
||||||
"""
|
block=False)
|
||||||
<iq type="result" id="2"
|
self.send("""
|
||||||
to="foo@comp.example.com/bar" from="pubsub.example.com" />
|
<iq type="set" id="1"
|
||||||
""")
|
to="pubsub.example.com" from="foo@comp.example.com/bar">
|
||||||
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
# Case 3: No subscribee, given 'from' JID, full JID
|
<subscribe node="somenode" jid="user@example.com/foo" />
|
||||||
run_test(None, False, 'foo@comp.example.com/bar',
|
</pubsub>
|
||||||
"""
|
</iq>
|
||||||
<iq type="set" id="3"
|
""")
|
||||||
to="pubsub.example.com" from="foo@comp.example.com/bar">
|
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
|
||||||
<subscribe node="some_node" jid="foo@comp.example.com/bar" />
|
|
||||||
</pubsub>
|
|
||||||
</iq>
|
|
||||||
""",
|
|
||||||
"""
|
|
||||||
<iq type="result" id="3"
|
|
||||||
to="foo@comp.example.com/bar" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
# Case 4: Subscribee
|
|
||||||
run_test('user@example.com/foo', True, 'foo@comp.example.com/bar',
|
|
||||||
"""
|
|
||||||
<iq type="set" id="4"
|
|
||||||
to="pubsub.example.com" from="foo@comp.example.com/bar">
|
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
|
||||||
<subscribe node="some_node" jid="user@example.com/foo" />
|
|
||||||
</pubsub>
|
|
||||||
</iq>
|
|
||||||
""",
|
|
||||||
"""
|
|
||||||
<iq type="result" id="4"
|
|
||||||
to="foo@comp.example.com/bar" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
def testSubscribeWithOptions(self):
|
def testSubscribeWithOptions(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def testUnubscribe(self):
|
def testUnsubscribeCase1(self):
|
||||||
"""Test unsubscribing from a node"""
|
"""
|
||||||
|
Test unsubscribing from a node: Case 1:
|
||||||
def run_test(jid, bare, ifrom, send, recv):
|
No subscribee, default 'from' JID, bare JID
|
||||||
t = threading.Thread(name='unsubscribe',
|
"""
|
||||||
target=self.xmpp['xep_0060'].unsubscribe,
|
self.xmpp['xep_0060'].unsubscribe(
|
||||||
args=('pubsub.example.com', 'some_node'),
|
'pubsub.example.com',
|
||||||
kwargs={'subscribee': jid,
|
'somenode',
|
||||||
'bare': bare,
|
block=False)
|
||||||
'ifrom': ifrom})
|
|
||||||
t.start()
|
|
||||||
self.send(send)
|
|
||||||
self.recv(recv)
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
# Case 1: No subscribee, default 'from' JID, bare JID
|
|
||||||
run_test(None, True, None,
|
|
||||||
"""
|
|
||||||
<iq type="set" id="1" to="pubsub.example.com">
|
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
|
||||||
<unsubscribe node="some_node" jid="tester@localhost" />
|
|
||||||
</pubsub>
|
|
||||||
</iq>
|
|
||||||
""",
|
|
||||||
"""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
# Case 2: No subscribee, given 'from' JID, bare JID
|
|
||||||
run_test(None, True, 'foo@comp.example.com/bar',
|
|
||||||
"""
|
|
||||||
<iq type="set" id="2"
|
|
||||||
to="pubsub.example.com" from="foo@comp.example.com/bar">
|
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
|
||||||
<unsubscribe node="some_node" jid="foo@comp.example.com" />
|
|
||||||
</pubsub>
|
|
||||||
</iq>
|
|
||||||
""",
|
|
||||||
"""
|
|
||||||
<iq type="result" id="2"
|
|
||||||
to="foo@comp.example.com/bar" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
# Case 3: No subscribee, given 'from' JID, full JID
|
|
||||||
run_test(None, False, 'foo@comp.example.com/bar',
|
|
||||||
"""
|
|
||||||
<iq type="set" id="3"
|
|
||||||
to="pubsub.example.com" from="foo@comp.example.com/bar">
|
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
|
||||||
<unsubscribe node="some_node" jid="foo@comp.example.com/bar" />
|
|
||||||
</pubsub>
|
|
||||||
</iq>
|
|
||||||
""",
|
|
||||||
"""
|
|
||||||
<iq type="result" id="3"
|
|
||||||
to="foo@comp.example.com/bar" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
# Case 4: Subscribee
|
|
||||||
run_test('user@example.com/foo', True, 'foo@comp.example.com/bar',
|
|
||||||
"""
|
|
||||||
<iq type="set" id="4"
|
|
||||||
to="pubsub.example.com" from="foo@comp.example.com/bar">
|
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
|
||||||
<unsubscribe node="some_node" jid="user@example.com/foo" />
|
|
||||||
</pubsub>
|
|
||||||
</iq>
|
|
||||||
""",
|
|
||||||
"""
|
|
||||||
<iq type="result" id="4"
|
|
||||||
to="foo@comp.example.com/bar" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
def testGetDefaultConfig(self):
|
|
||||||
"""Test retrieving the default node configuration."""
|
|
||||||
t = threading.Thread(name='default_config',
|
|
||||||
target=self.xmpp['xep_0060'].get_node_config,
|
|
||||||
args=('pubsub.example.com',))
|
|
||||||
t.start()
|
|
||||||
|
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="get" id="1" to="pubsub.example.com">
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
<default />
|
<unsubscribe node="somenode" jid="tester@localhost" />
|
||||||
</pubsub>
|
</pubsub>
|
||||||
</iq>
|
</iq>
|
||||||
""", use_values=False)
|
|
||||||
|
|
||||||
self.recv("""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
t.join()
|
def testUnsubscribeCase2(self):
|
||||||
|
"""
|
||||||
|
Test unsubscribing from a node: Case 2:
|
||||||
|
No subscribee, given 'from' JID, bare JID
|
||||||
|
"""
|
||||||
|
self.xmpp['xep_0060'].unsubscribe(
|
||||||
|
'pubsub.example.com',
|
||||||
|
'somenode',
|
||||||
|
ifrom='foo@comp.example.com/bar',
|
||||||
|
block=False)
|
||||||
|
self.send("""
|
||||||
|
<iq type="set" id="1"
|
||||||
|
to="pubsub.example.com" from="foo@comp.example.com/bar">
|
||||||
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
|
<unsubscribe node="somenode" jid="foo@comp.example.com" />
|
||||||
|
</pubsub>
|
||||||
|
</iq>
|
||||||
|
""")
|
||||||
|
|
||||||
|
def testUnsubscribeCase3(self):
|
||||||
|
"""
|
||||||
|
Test unsubscribing from a node: Case 3:
|
||||||
|
No subscribee, given 'from' JID, full JID
|
||||||
|
"""
|
||||||
|
self.xmpp['xep_0060'].unsubscribe(
|
||||||
|
'pubsub.example.com',
|
||||||
|
'somenode',
|
||||||
|
ifrom='foo@comp.example.com/bar',
|
||||||
|
bare=False,
|
||||||
|
block=False)
|
||||||
|
self.send("""
|
||||||
|
<iq type="set" id="1"
|
||||||
|
to="pubsub.example.com" from="foo@comp.example.com/bar">
|
||||||
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
|
<unsubscribe node="somenode" jid="foo@comp.example.com/bar" />
|
||||||
|
</pubsub>
|
||||||
|
</iq>
|
||||||
|
""")
|
||||||
|
|
||||||
|
def testUnsubscribeCase4(self):
|
||||||
|
"""
|
||||||
|
Test unsubscribing from a node: Case 4:
|
||||||
|
No subscribee, no 'from' JID, full JID
|
||||||
|
"""
|
||||||
|
self.stream_close()
|
||||||
|
self.stream_start(jid='tester@localhost/full')
|
||||||
|
|
||||||
|
self.xmpp['xep_0060'].unsubscribe(
|
||||||
|
'pubsub.example.com',
|
||||||
|
'somenode',
|
||||||
|
bare=False,
|
||||||
|
block=False)
|
||||||
|
self.send("""
|
||||||
|
<iq type="set" id="1"
|
||||||
|
to="pubsub.example.com">
|
||||||
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
|
<unsubscribe node="somenode" jid="tester@localhost/full" />
|
||||||
|
</pubsub>
|
||||||
|
</iq>
|
||||||
|
""")
|
||||||
|
|
||||||
|
def testUnsubscribeCase5(self):
|
||||||
|
"""
|
||||||
|
Test unsubscribing from a node: Case 5:
|
||||||
|
Subscribee given
|
||||||
|
"""
|
||||||
|
self.xmpp['xep_0060'].unsubscribe(
|
||||||
|
'pubsub.example.com',
|
||||||
|
'somenode',
|
||||||
|
subscribee='user@example.com/foo',
|
||||||
|
ifrom='foo@comp.example.com/bar',
|
||||||
|
block=False)
|
||||||
|
self.send("""
|
||||||
|
<iq type="set" id="1"
|
||||||
|
to="pubsub.example.com" from="foo@comp.example.com/bar">
|
||||||
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
|
<unsubscribe node="somenode" jid="user@example.com/foo" />
|
||||||
|
</pubsub>
|
||||||
|
</iq>
|
||||||
|
""")
|
||||||
|
|
||||||
def testGetDefaultNodeConfig(self):
|
def testGetDefaultNodeConfig(self):
|
||||||
"""Test retrieving the default node config for a pubsub service."""
|
"""Test retrieving the default node config for a pubsub service."""
|
||||||
t = threading.Thread(name='default_config',
|
self.xmpp['xep_0060'].get_node_config(
|
||||||
target=self.xmpp['xep_0060'].get_node_config,
|
'pubsub.example.com',
|
||||||
args=('pubsub.example.com', None))
|
block=False)
|
||||||
t.start()
|
|
||||||
|
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="get" id="1" to="pubsub.example.com">
|
<iq type="get" id="1" to="pubsub.example.com">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
||||||
@ -314,20 +314,12 @@ class TestStreamPubsub(SleekTest):
|
|||||||
</iq>
|
</iq>
|
||||||
""", use_values=False)
|
""", use_values=False)
|
||||||
|
|
||||||
self.recv("""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
def testGetNodeConfig(self):
|
def testGetNodeConfig(self):
|
||||||
"""Test getting the config for a given node."""
|
"""Test getting the config for a given node."""
|
||||||
t = threading.Thread(name='node_config',
|
self.xmpp['xep_0060'].get_node_config(
|
||||||
target=self.xmpp['xep_0060'].get_node_config,
|
'pubsub.example.com',
|
||||||
args=('pubsub.example.com', 'somenode'))
|
'somenode',
|
||||||
t.start()
|
block=False)
|
||||||
|
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="get" id="1" to="pubsub.example.com">
|
<iq type="get" id="1" to="pubsub.example.com">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
||||||
@ -336,13 +328,6 @@ class TestStreamPubsub(SleekTest):
|
|||||||
</iq>
|
</iq>
|
||||||
""", use_values=False)
|
""", use_values=False)
|
||||||
|
|
||||||
self.recv("""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
def testSetNodeConfig(self):
|
def testSetNodeConfig(self):
|
||||||
"""Test setting the configuration for a node."""
|
"""Test setting the configuration for a node."""
|
||||||
form = self.xmpp['xep_0004'].make_form()
|
form = self.xmpp['xep_0004'].make_form()
|
||||||
@ -352,11 +337,11 @@ class TestStreamPubsub(SleekTest):
|
|||||||
value='This is awesome!')
|
value='This is awesome!')
|
||||||
form['type'] = 'submit'
|
form['type'] = 'submit'
|
||||||
|
|
||||||
t = threading.Thread(name='set_config',
|
self.xmpp['xep_0060'].set_node_config(
|
||||||
target=self.xmpp['xep_0060'].set_node_config,
|
'pubsub.example.com',
|
||||||
args=('pubsub.example.com', 'somenode', form))
|
'somenode',
|
||||||
t.start()
|
form,
|
||||||
|
block=False)
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="set" id="1" to="pubsub.example.com">
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
||||||
@ -374,13 +359,6 @@ class TestStreamPubsub(SleekTest):
|
|||||||
</iq>
|
</iq>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
self.recv("""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
def testPublishSingle(self):
|
def testPublishSingle(self):
|
||||||
"""Test publishing a single item."""
|
"""Test publishing a single item."""
|
||||||
payload = AtomEntry()
|
payload = AtomEntry()
|
||||||
@ -388,13 +366,12 @@ class TestStreamPubsub(SleekTest):
|
|||||||
|
|
||||||
register_stanza_plugin(self.xmpp['xep_0060'].stanza.Item, AtomEntry)
|
register_stanza_plugin(self.xmpp['xep_0060'].stanza.Item, AtomEntry)
|
||||||
|
|
||||||
t = threading.Thread(name='publish_single',
|
self.xmpp['xep_0060'].publish(
|
||||||
target=self.xmpp['xep_0060'].publish,
|
'pubsub.example.com',
|
||||||
args=('pubsub.example.com', 'somenode'),
|
'somenode',
|
||||||
kwargs={'item_id': 'ID42',
|
item_id='ID42',
|
||||||
'payload': payload})
|
payload=payload,
|
||||||
t.start()
|
block=False)
|
||||||
|
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="set" id="1" to="pubsub.example.com">
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
@ -409,13 +386,6 @@ class TestStreamPubsub(SleekTest):
|
|||||||
</iq>
|
</iq>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
self.recv("""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
def testPublishSingleOptions(self):
|
def testPublishSingleOptions(self):
|
||||||
"""Test publishing a single item, with options."""
|
"""Test publishing a single item, with options."""
|
||||||
payload = AtomEntry()
|
payload = AtomEntry()
|
||||||
@ -430,14 +400,13 @@ class TestStreamPubsub(SleekTest):
|
|||||||
value='presence')
|
value='presence')
|
||||||
options['type'] = 'submit'
|
options['type'] = 'submit'
|
||||||
|
|
||||||
t = threading.Thread(name='publish_single_options',
|
self.xmpp['xep_0060'].publish(
|
||||||
target=self.xmpp['xep_0060'].publish,
|
'pubsub.example.com',
|
||||||
args=('pubsub.example.com', 'somenode'),
|
'somenode',
|
||||||
kwargs={'item_id': 'ID42',
|
item_id='ID42',
|
||||||
'payload': payload,
|
payload=payload,
|
||||||
'options': options})
|
options=options,
|
||||||
t.start()
|
block=False)
|
||||||
|
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="set" id="1" to="pubsub.example.com">
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
@ -462,13 +431,6 @@ class TestStreamPubsub(SleekTest):
|
|||||||
</iq>
|
</iq>
|
||||||
""", use_values=False)
|
""", use_values=False)
|
||||||
|
|
||||||
self.recv("""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
def testPublishMulti(self):
|
def testPublishMulti(self):
|
||||||
"""Test publishing multiple items."""
|
"""Test publishing multiple items."""
|
||||||
payload1 = AtomEntry()
|
payload1 = AtomEntry()
|
||||||
@ -479,13 +441,12 @@ class TestStreamPubsub(SleekTest):
|
|||||||
|
|
||||||
register_stanza_plugin(self.xmpp['xep_0060'].stanza.Item, AtomEntry)
|
register_stanza_plugin(self.xmpp['xep_0060'].stanza.Item, AtomEntry)
|
||||||
|
|
||||||
t = threading.Thread(name='publish_multi',
|
self.xmpp['xep_0060'].publish(
|
||||||
target=self.xmpp['xep_0060'].publish,
|
'pubsub.example.com',
|
||||||
args=('pubsub.example.com', 'somenode'),
|
'somenode',
|
||||||
kwargs={'items': [('ID1', payload1),
|
items=[('ID1', payload1),
|
||||||
('ID2', payload2)]})
|
('ID2', payload2)],
|
||||||
t.start()
|
block=False)
|
||||||
|
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="set" id="1" to="pubsub.example.com">
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
@ -505,13 +466,6 @@ class TestStreamPubsub(SleekTest):
|
|||||||
</iq>
|
</iq>
|
||||||
""", use_values=False)
|
""", use_values=False)
|
||||||
|
|
||||||
self.recv("""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
def testPublishMultiOptions(self):
|
def testPublishMultiOptions(self):
|
||||||
"""Test publishing multiple items, with options."""
|
"""Test publishing multiple items, with options."""
|
||||||
payload1 = AtomEntry()
|
payload1 = AtomEntry()
|
||||||
@ -529,14 +483,13 @@ class TestStreamPubsub(SleekTest):
|
|||||||
value='presence')
|
value='presence')
|
||||||
options['type'] = 'submit'
|
options['type'] = 'submit'
|
||||||
|
|
||||||
t = threading.Thread(name='publish_multi_options',
|
self.xmpp['xep_0060'].publish(
|
||||||
target=self.xmpp['xep_0060'].publish,
|
'pubsub.example.com',
|
||||||
args=('pubsub.example.com', 'somenode'),
|
'somenode',
|
||||||
kwargs={'items': [('ID1', payload1),
|
items=[('ID1', payload1),
|
||||||
('ID2', payload2)],
|
('ID2', payload2)],
|
||||||
'options': options})
|
options=options,
|
||||||
t.start()
|
block=False)
|
||||||
|
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="set" id="1" to="pubsub.example.com">
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
@ -566,20 +519,13 @@ class TestStreamPubsub(SleekTest):
|
|||||||
</iq>
|
</iq>
|
||||||
""", use_values=False)
|
""", use_values=False)
|
||||||
|
|
||||||
self.recv("""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
def testRetract(self):
|
def testRetract(self):
|
||||||
"""Test deleting an item."""
|
"""Test deleting an item."""
|
||||||
t = threading.Thread(name='retract',
|
self.xmpp['xep_0060'].retract(
|
||||||
target=self.xmpp['xep_0060'].retract,
|
'pubsub.example.com',
|
||||||
args=('pubsub.example.com', 'somenode', 'ID1'))
|
'somenode',
|
||||||
t.start()
|
'ID1',
|
||||||
|
block=False)
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="set" id="1" to="pubsub.example.com">
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub">
|
||||||
@ -590,35 +536,20 @@ class TestStreamPubsub(SleekTest):
|
|||||||
</iq>
|
</iq>
|
||||||
""", use_values=False)
|
""", use_values=False)
|
||||||
|
|
||||||
self.recv("""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
def testPurge(self):
|
def testPurge(self):
|
||||||
"""Test removing all items from a node."""
|
"""Test removing all items from a node."""
|
||||||
t = threading.Thread(name='purge',
|
self.xmpp['xep_0060'].purge(
|
||||||
target=self.xmpp['xep_0060'].purge,
|
'pubsub.example.com',
|
||||||
args=('pubsub.example.com', 'somenode'))
|
'somenode',
|
||||||
t.start()
|
block=False)
|
||||||
|
|
||||||
self.send("""
|
self.send("""
|
||||||
<iq type="set" id="1" to="pubsub.example.com">
|
<iq type="set" id="1" to="pubsub.example.com">
|
||||||
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
|
||||||
<purge node="somenode" />
|
<purge node="somenode" />
|
||||||
</pubsub>
|
</pubsub>
|
||||||
</iq>
|
</iq>
|
||||||
""", use_values=False)
|
|
||||||
|
|
||||||
self.recv("""
|
|
||||||
<iq type="result" id="1"
|
|
||||||
to="tester@localhost" from="pubsub.example.com" />
|
|
||||||
""")
|
""")
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
def testGetItem(self):
|
def testGetItem(self):
|
||||||
"""Test retrieving a single item."""
|
"""Test retrieving a single item."""
|
||||||
pass
|
pass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user