Exemplo n.º 1
0
    def test_onNextChange_cancel(self):
        """
        You can cancel the deferred returned by onNextChange
        """
        world = World(MagicMock())

        obj = world.create('foo')
        d = world.onNextChange(obj['id'], 'hey')
        d.cancel()

        world.setAttr(obj['id'], 'hey', 3)

        self.assertFailure(d, defer.CancelledError)
Exemplo n.º 2
0
    def test_onNextChange_cancel(self):
        """
        You can cancel the deferred returned by onNextChange
        """
        world = World(MagicMock())

        obj = world.create('foo')
        d = world.onNextChange(obj['id'], 'hey')
        d.cancel()

        world.setAttr(obj['id'], 'hey', 3)

        self.assertFailure(d, defer.CancelledError)
Exemplo n.º 3
0
    def test_onNextChange(self):
        """
        You can get a Deferred which will fire when an attribute changes
        """
        world = World(MagicMock())

        obj = world.create('foo')
        d = world.onNextChange(obj['id'], 'hey')
        self.assertFalse(d.called)

        world.setAttr(obj['id'], 'ho', 8)
        self.assertFalse(d.called)

        world.setAttr(obj['id'], 'hey', 3)
        self.assertEqual(self.successResultOf(d), 3)

        # make sure it isn't called again
        world.setAttr(obj['id'], 'hey', 2)
Exemplo n.º 4
0
    def test_onNextChange(self):
        """
        You can get a Deferred which will fire when an attribute changes
        """
        world = World(MagicMock())

        obj = world.create('foo')
        d = world.onNextChange(obj['id'], 'hey')
        self.assertFalse(d.called)

        world.setAttr(obj['id'], 'ho', 8)
        self.assertFalse(d.called)

        world.setAttr(obj['id'], 'hey', 3)
        self.assertEqual(self.successResultOf(d), 3)

        # make sure it isn't called again
        world.setAttr(obj['id'], 'hey', 2)