Esempio n. 1
0
    def test_callbacks(self):
        source = Mock(name='source')
        p = PromiseProxy(source)
        cbA = Mock(name='cbA')
        cbB = Mock(name='cbB')
        cbC = Mock(name='cbC')
        p.__then__(cbA, p)
        p.__then__(cbB, p)
        self.assertFalse(p.__evaluated__())
        self.assertTrue(object.__getattribute__(p, '__pending__'))

        self.assertTrue(repr(p))
        with self.assertRaises(AttributeError):
            object.__getattribute__(p, '__pending__')
        cbA.assert_called_with(p)
        cbB.assert_called_with(p)

        self.assertTrue(p.__evaluated__())
        p.__then__(cbC, p)
        cbC.assert_called_with(p)

        with self.assertRaises(AttributeError):
            object.__getattribute__(p, '__pending__')
Esempio n. 2
0
    def test_callbacks(self):
        source = Mock(name="source")
        p = PromiseProxy(source)
        cbA = Mock(name="cbA")
        cbB = Mock(name="cbB")
        cbC = Mock(name="cbC")
        p.__then__(cbA, p)
        p.__then__(cbB, p)
        self.assertFalse(p.__evaluated__())
        self.assertTrue(object.__getattribute__(p, "__pending__"))

        self.assertTrue(repr(p))
        with self.assertRaises(AttributeError):
            object.__getattribute__(p, "__pending__")
        cbA.assert_called_with(p)
        cbB.assert_called_with(p)

        self.assertTrue(p.__evaluated__())
        p.__then__(cbC, p)
        cbC.assert_called_with(p)

        with self.assertRaises(AttributeError):
            object.__getattribute__(p, "__pending__")
Esempio n. 3
0
    def test_callbacks(self):
        source = Mock(name='source')
        p = PromiseProxy(source)
        cbA = Mock(name='cbA')
        cbB = Mock(name='cbB')
        cbC = Mock(name='cbC')
        p.__then__(cbA, p)
        p.__then__(cbB, p)
        assert not p.__evaluated__()
        assert object.__getattribute__(p, '__pending__')

        assert repr(p)
        assert p.__evaluated__()
        with pytest.raises(AttributeError):
            object.__getattribute__(p, '__pending__')
        cbA.assert_called_with(p)
        cbB.assert_called_with(p)

        assert p.__evaluated__()
        p.__then__(cbC, p)
        cbC.assert_called_with(p)

        with pytest.raises(AttributeError):
            object.__getattribute__(p, '__pending__')
Esempio n. 4
0
    def test_callbacks(self):
        source = Mock(name='source')
        p = PromiseProxy(source)
        cbA = Mock(name='cbA')
        cbB = Mock(name='cbB')
        cbC = Mock(name='cbC')
        p.__then__(cbA, p)
        p.__then__(cbB, p)
        assert not p.__evaluated__()
        assert object.__getattribute__(p, '__pending__')

        assert repr(p)
        assert p.__evaluated__()
        with pytest.raises(AttributeError):
            object.__getattribute__(p, '__pending__')
        cbA.assert_called_with(p)
        cbB.assert_called_with(p)

        assert p.__evaluated__()
        p.__then__(cbC, p)
        cbC.assert_called_with(p)

        with pytest.raises(AttributeError):
            object.__getattribute__(p, '__pending__')