Changeset 10:a5e3c32d23ca for wokkel/test/test_pubsub.py
- Timestamp:
- Jan 3, 2008, 10:58:54 AM (15 years ago)
- Branch:
- default
- Convert:
- svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@34
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/test/test_pubsub.py
r6 r10 1 # Copyright (c) 2003-200 7Ralph Meijer1 # Copyright (c) 2003-2008 Ralph Meijer 2 2 # See LICENSE for details. 3 3 … … 12 12 13 13 from wokkel import pubsub 14 from wokkel.test.helpers import XmlStreamStub 15 16 try: 17 from twisted.words.protocols.jabber.xmlstream import toResponse 18 except ImportError: 19 from wokkel.compat import toResponse 20 21 NS_PUBSUB = 'http://jabber.org/protocol/pubsub' 22 NS_PUBSUB_ERRORS = 'http://jabber.org/protocol/pubsub#errors' 23 24 class PubSubClientTest(unittest.TestCase): 25 26 def setUp(self): 27 self.stub = XmlStreamStub() 28 self.protocol = pubsub.PubSubClient() 29 self.protocol.xmlstream = self.stub.xmlstream 30 31 def test_unsubscribe(self): 32 """ 33 Test sending unsubscription request. 34 """ 35 d = self.protocol.unsubscribe(JID('pubsub.example.org'), 'test', 36 JID('user@example.org')) 37 38 iq = self.stub.output[-1] 39 self.assertEquals('pubsub.example.org', iq.getAttribute('to')) 40 self.assertEquals('set', iq.getAttribute('type')) 41 self.assertEquals('pubsub', iq.pubsub.name) 42 self.assertEquals(NS_PUBSUB, iq.pubsub.uri) 43 children = list(domish.generateElementsQNamed(iq.pubsub.children, 44 'unsubscribe', NS_PUBSUB)) 45 self.assertEquals(1, len(children)) 46 child = children[0] 47 self.assertEquals('test', child['node']) 48 self.assertEquals('user@example.org', child['jid']) 49 50 self.stub.send(toResponse(iq, 'result')) 51 return d 52 14 53 15 54 class PubSubServiceTest(unittest.TestCase): … … 28 67 iq['to'] = 'pubsub.example.org' 29 68 iq['type'] = 'set' 30 iq.addElement(( 'http://jabber.org/protocol/pubsub', 'pubsub'))69 iq.addElement((NS_PUBSUB, 'pubsub')) 31 70 iq.pubsub.addElement('publish') 32 71 handler.handleRequest(iq) … … 47 86 iq['from'] = 'user@example.org' 48 87 iq['to'] = 'pubsub.example.org' 49 iq.addElement(( 'http://jabber.org/protocol/pubsub', 'pubsub'))88 iq.addElement((NS_PUBSUB, 'pubsub')) 50 89 iq.pubsub.addElement('publish') 51 90 iq.pubsub.publish['node'] = 'test' … … 62 101 iq['to'] = 'pubsub.example.org' 63 102 iq['type'] = 'get' 64 iq.addElement(( 'http://jabber.org/protocol/pubsub', 'pubsub'))103 iq.addElement((NS_PUBSUB, 'pubsub')) 65 104 iq.pubsub.addElement('options') 66 105 handler.handleRequest(iq) … … 69 108 self.assertEquals('feature-not-implemented', e.condition) 70 109 self.assertEquals('unsupported', e.appCondition.name) 71 self.assertEquals('http://jabber.org/protocol/pubsub#errors', 72 e.appCondition.uri) 110 self.assertEquals(NS_PUBSUB_ERRORS, e.appCondition.uri)
Note: See TracChangeset
for help on using the changeset viewer.