Changeset 92:f69b08281bec


Ignore:
Timestamp:
Feb 12, 2011, 12:08:30 AM (10 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Properly pass verb element to parse methods, not just the last one.

Author: ralphm.
Fixes: #72.

This also cleans up a few pyflakes warnings, including a masked test.

Location:
wokkel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/pubsub.py

    r90 r92  
    11# -*- test-case-name: wokkel.test.test_pubsub -*-
    22#
    3 # Copyright (c) 2003-2010 Ralph Meijer
     3# Copyright (c) 2003-2011 Ralph Meijer
    44# See LICENSE for details.
    55
     
    534534
    535535        verbs = []
    536         children = []
     536        verbElements = []
    537537        for child in element.pubsub.elements():
    538538            key = (self.stanzaType, child.uri, child.name)
     
    543543
    544544            verbs.append(verb)
    545             children.append(child)
     545            verbElements.append(child)
    546546
    547547        if not verbs:
     
    551551            if 'optionsSet' in verbs and 'subscribe' in verbs:
    552552                self.verb = 'subscribe'
    553                 child = children[verbs.index('subscribe')]
     553                verbElement = verbElements[verbs.index('subscribe')]
    554554            else:
    555555                raise NotImplementedError()
    556556        else:
    557557            self.verb = verbs[0]
     558            verbElement = verbElements[0]
    558559
    559560        for parameter in self._parameters[self.verb]:
    560             getattr(self, '_parse_%s' % parameter)(child)
     561            getattr(self, '_parse_%s' % parameter)(verbElement)
    561562
    562563
     
    11821183    def _toResponse_subscribe(self, result, resource, request):
    11831184        response = domish.Element((NS_PUBSUB, "pubsub"))
    1184         subscription = response.addChild(result.toElement())
     1185        response.addChild(result.toElement())
    11851186        return response
    11861187
  • wokkel/test/test_pubsub.py

    r90 r92  
    1 # Copyright (c) 2003-2010 Ralph Meijer
     1# Copyright (c) 2003-2011 Ralph Meijer
    22# See LICENSE for details.
    33
     
    10571057
    10581058
     1059    def test_fromElementPublishItemsOptions(self):
     1060        """
     1061        Test parsing a publish request with items and options.
     1062
     1063        Note that publishing options are not supported, but passing them
     1064        shouldn't affect processing of the publish request itself.
     1065        """
     1066
     1067        xml = """
     1068        <iq type='set' to='pubsub.example.org'
     1069                       from='user@example.org'>
     1070          <pubsub xmlns='http://jabber.org/protocol/pubsub'>
     1071            <publish node='test'>
     1072              <item id="item1"/>
     1073              <item id="item2"/>
     1074            </publish>
     1075            <publish-options/>
     1076          </pubsub>
     1077        </iq>
     1078        """
     1079
     1080        request = pubsub.PubSubRequest.fromElement(parseXml(xml))
     1081        self.assertEqual(2, len(request.items))
     1082        self.assertEqual(u'item1', request.items[0]["id"])
     1083        self.assertEqual(u'item2', request.items[1]["id"])
     1084
    10591085    def test_fromElementPublishNoNode(self):
    10601086        """
     
    15461572        request = pubsub.PubSubRequest.fromElement(parseXml(xml))
    15471573        self.assertEqual({}, request.options.getValues())
     1574        self.assertEqual(u'mynode', request.nodeIdentifier)
    15481575
    15491576
     
    15681595        request = pubsub.PubSubRequest.fromElement(parseXml(xml))
    15691596        self.assertEqual({}, request.options.getValues())
     1597        self.assertEqual(u'mynode', request.nodeIdentifier)
    15701598
    15711599
     
    22862314
    22872315
    2288     def test_on_unsubscribe(self):
     2316    def test_on_unsubscribeSubscriptionIdentifier(self):
    22892317        """
    22902318        A successful unsubscription with subid should return an empty response.
Note: See TracChangeset for help on using the changeset viewer.