def test_notifyOnSubscription(self):
        """
        Test notification of last published item on subscription.
        """
        ITEM = NS_PUBSUB % "<item xmlns='%s' id='1'/>"

        class TestNode:
            implements(iidavoll.ILeafNode)
            nodeIdentifier = 'node'
            nodeType = 'leaf'
            def getAffiliation(self, entity):
                if entity is OWNER:
                    return defer.succeed('owner')
            def getConfiguration(self):
                return {'pubsub#deliver_payloads': True,
                        'pubsub#persist_items': False,
                        'pubsub#send_last_published_item': 'on_sub'}
            def getItems(self, maxItems):
                return [ITEM]
            def addSubscription(self, subscriber, state, options):
                self.subscription = pubsub.Subscription('node', subscriber,
                                                        state, options)
                return defer.succeed(None)
            def getSubscription(self, subscriber):
                return defer.succeed(self.subscription)

        class TestStorage:
            def getNode(self, nodeIdentifier):
                return defer.succeed(TestNode())

        def cb(data):
            self.assertEquals('node', data['nodeIdentifier'])
            self.assertEquals([ITEM], data['items'])
            self.assertEquals(OWNER, data['subscription'].subscriber)

        self.storage = TestStorage()
        self.backend = backend.BackendService(self.storage)
        self.storage.backend = self.backend

        d1 = defer.Deferred()
        d1.addCallback(cb)
        self.backend.registerNotifier(d1.callback)
        d2 = self.backend.subscribe('node', OWNER, OWNER_FULL)
        return defer.gatherResults([d1, d2])
dataset/ETHPy150Open ralphm/idavoll/idavoll/test/test_backend.py/BackendTest.test_notifyOnSubscription/swapped operands of `%`