def test_SingleSyncChunk_SingleThen(self):
     expected = [lambda r: self.assertEqual(1, r.get())]
     check = checker(expected, self)
     f = Chain([lambda: 1], ioLoop=self.io_loop)
     f.then(check)
     self.wait(timeout=0.5)
     self.assertTrue(len(expected) == 0)
Пример #2
0
 def test_SingleSyncChunk_SingleThen(self):
     expected = [
         lambda r: self.assertEqual(1, r.get()),
     ]
     check = checker(expected, self)
     f = Chain([lambda: 1], ioLoop=self.io_loop)
     f.then(check)
     self.wait(timeout=0.5)
     self.assertTrue(len(expected) == 0)
    def test_SingleErrorChunk_SingleThen(self):
        expected = [lambda r: self.assertRaises(Exception, r.get)]
        check = checker(expected, self)

        def firstStep():
            raise Exception("Actual")

        f = Chain([firstStep], ioLoop=self.io_loop)
        f.then(check)
        self.wait(timeout=0.5)
        self.assertTrue(len(expected) == 0)
    def test_Chain_YieldEmptyServiceInside(self):
        expected = [lambda r: self.assertEqual("Ok", r.get())]
        check = checker(expected, self)

        def firstStep():
            r1 = yield ServiceMock(chunks=[], T=self.T, ioLoop=self.io_loop, interval=0.002).execute()
            yield "Ok"

        f = Chain([firstStep], ioLoop=self.io_loop)
        f.then(check)
        self.wait()
        self.assertTrue(len(expected) == 0)
    def test_SingleSyncChunk_MultipleThen(self):
        expected = [lambda r: self.assertEqual(6, r.get())]
        check = checker(expected, self)
        f = Chain([lambda: 2], ioLoop=self.io_loop)

        def firstStep(futureResult):
            r = futureResult.get()
            r *= 3
            return r

        f.then(firstStep).then(check)
        self.wait(timeout=0.5)
        self.assertTrue(len(expected) == 0)
Пример #6
0
    def test_SingleErrorChunk_SingleThen(self):
        expected = [
            lambda r: self.assertRaises(Exception, r.get),
        ]
        check = checker(expected, self)

        def firstStep():
            raise Exception('Actual')

        f = Chain([firstStep], ioLoop=self.io_loop)
        f.then(check)
        self.wait(timeout=0.5)
        self.assertTrue(len(expected) == 0)
    def test_SingleErrorChunk_MultipleThen(self):
        expected = [lambda r: self.assertRaises(Exception, r.get)]
        check = checker(expected, self)

        def firstStep():
            raise Exception("Actual")

        def secondStep(futureResult):
            futureResult.get()
            self.fail("This one should never be seen by anyone")

        f = Chain([firstStep], ioLoop=self.io_loop)
        f.then(secondStep).then(check)
        self.wait(timeout=0.5)
        self.assertTrue(len(expected) == 0)
Пример #8
0
    def test_SingleSyncChunk_MultipleThen(self):
        expected = [
            lambda r: self.assertEqual(6, r.get()),
        ]
        check = checker(expected, self)
        f = Chain([lambda: 2], ioLoop=self.io_loop)

        def firstStep(futureResult):
            r = futureResult.get()
            r *= 3
            return r

        f.then(firstStep).then(check)
        self.wait(timeout=0.5)
        self.assertTrue(len(expected) == 0)
    def test_YieldChainAndEmptyServiceInside_MultipleSteps(self):
        expected = [lambda r: self.assertEqual("Really Ok", r.get())]
        check = checker(expected, self)

        def firstStep():
            yield ServiceMock(chunks=[], T=self.T, ioLoop=self.io_loop, interval=0.004).execute()
            yield ServiceMock(chunks=[], T=self.T, ioLoop=self.io_loop, interval=0.002).execute()
            yield "Ok"

        def secondStep(result):
            yield "Really " + result.get()

        f = Chain([firstStep], ioLoop=self.io_loop).then(secondStep)
        f.then(check)
        self.wait()
        self.assertTrue(len(expected) == 0)
Пример #10
0
    def test_Chain_YieldEmptyServiceInside(self):
        expected = [
            lambda r: self.assertEqual('Ok', r.get()),
        ]
        check = checker(expected, self)

        def firstStep():
            r1 = yield ServiceMock(chunks=[],
                                   T=self.T,
                                   ioLoop=self.io_loop,
                                   interval=0.002).execute()
            yield 'Ok'

        f = Chain([firstStep], ioLoop=self.io_loop)
        f.then(check)
        self.wait()
        self.assertTrue(len(expected) == 0)
Пример #11
0
    def test_SingleErrorChunk_MultipleThen(self):
        expected = [
            lambda r: self.assertRaises(Exception, r.get),
        ]
        check = checker(expected, self)

        def firstStep():
            raise Exception('Actual')

        def secondStep(futureResult):
            futureResult.get()
            self.fail('This one should never be seen by anyone')

        f = Chain([firstStep], ioLoop=self.io_loop)
        f.then(secondStep).then(check)
        self.wait(timeout=0.5)
        self.assertTrue(len(expected) == 0)
Пример #12
0
    def test_YieldChainAndEmptyServiceInside_MultipleSteps(self):
        expected = [
            lambda r: self.assertEqual('Really Ok', r.get()),
        ]
        check = checker(expected, self)

        def firstStep():
            yield ServiceMock(chunks=[],
                              T=self.T,
                              ioLoop=self.io_loop,
                              interval=0.004).execute()
            yield ServiceMock(chunks=[],
                              T=self.T,
                              ioLoop=self.io_loop,
                              interval=0.002).execute()
            yield 'Ok'

        def secondStep(result):
            yield 'Really ' + result.get()

        f = Chain([firstStep], ioLoop=self.io_loop).then(secondStep)
        f.then(check)
        self.wait()
        self.assertTrue(len(expected) == 0)