Changeset 90:1ffd4dd005e4


Ignore:
Timestamp:
Feb 25, 2010, 11:55:52 AM (11 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Ignore error messages in PubSubClient?.

Author: ralphm
Reviewer: arjan
Fixes: #69

Location:
wokkel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/pubsub.py

    r88 r90  
    664664
    665665    def _onEvent(self, message):
     666        if message.getAttribute('type') == 'error':
     667            return
     668
    666669        try:
    667670            sender = jid.JID(message["from"])
  • wokkel/test/test_pubsub.py

    r88 r90  
    184184        self.stub.send(message)
    185185        return d
     186
     187
     188    def test_eventItemsError(self):
     189        """
     190        An error message with embedded event should not be handled.
     191
     192        This test uses an items event, which should not result in itemsReceived
     193        being called. In general message.handled should be False.
     194        """
     195        message = domish.Element((None, 'message'))
     196        message['from'] = 'pubsub.example.org'
     197        message['to'] = 'user@example.org/home'
     198        message['type'] = 'error'
     199        event = message.addElement((NS_PUBSUB_EVENT, 'event'))
     200        items = event.addElement('items')
     201        items['node'] = 'test'
     202
     203        class UnexpectedCall(Exception):
     204            pass
     205
     206        def itemsReceived(event):
     207            raise UnexpectedCall("Unexpected call to itemsReceived")
     208
     209        self.protocol.itemsReceived = itemsReceived
     210        self.stub.send(message)
     211        self.assertFalse(message.handled)
    186212
    187213
Note: See TracChangeset for help on using the changeset viewer.