def test_GetMultipleChunks(self): f = ServiceMock(chunks=[1, 2, 3], T=self.T, ioLoop=self.io_loop).execute() r1 = f.get() r2 = f.get() r3 = f.get() self.assertEqual(1, r1) self.assertEqual(2, r2) self.assertEqual(3, r3)
def test_GetMultipleChunks(self): f = ServiceMock(chunks=[1, 2, 3], T=self.T, ioLoop=self.io_loop).execute() r1 = f.get() r2 = f.get() r3 = f.get() self.assertEqual(1, r1) self.assertEqual(2, r2) self.assertEqual(3, r3)
def test_GetMultipleMixChunksWithComplexChain(self): def middleMan(result): r = result.get() if r == 2: raise Exception('=(') yield r f = ServiceMock(chunks=[1, 2, 3], T=self.T, ioLoop=self.io_loop).execute() f.then(middleMan) self.assertEqual(1, f.get()) self.assertRaises(Exception, f.get) self.assertEqual(3, f.get())
def test_GetMultipleMixChunksWithComplexChain(self): def middleMan(result): r = result.get() if r == 2: raise Exception('=(') yield r f = ServiceMock(chunks=[1, 2, 3], T=self.T, ioLoop=self.io_loop).execute() f.then(middleMan) self.assertEqual(1, f.get()) self.assertRaises(Exception, f.get) self.assertEqual(3, f.get())
def test_GetSingleChunkAfterMultipleWaiting(self): f = ServiceMock(chunks=[1], T=self.T, ioLoop=self.io_loop).execute() f.wait() f.wait() f.wait() r = f.get() self.assertEqual(1, r)
def test_PartialGenerator(self): f = ServiceMock(chunks=[1, 2, 3], T=self.T, ioLoop=self.io_loop).execute() collect = [f.get()] for r in f: collect.append(r) self.assertEqual([1, 2, 3], collect)
def test_GetSingleChunkAfterMultipleWaiting(self): f = ServiceMock(chunks=[1], T=self.T, ioLoop=self.io_loop).execute() f.wait() f.wait() f.wait() r = f.get() self.assertEqual(1, r)
def test_GetMultipleMixChunks(self): f = ServiceMock(chunks=[ValueError('Oops1'), 1, IOError('Oops2')], T=self.T, ioLoop=self.io_loop).execute() self.assertRaises(ValueError, f.get) self.assertEqual(1, f.get()) self.assertRaises(IOError, f.get)
def test_GetMultipleChunksDeferredly(self): f1 = ServiceMock(chunks=[1], T=self.T, ioLoop=self.io_loop).execute() f2 = ServiceMock(chunks=[2], T=self.T, ioLoop=self.io_loop).execute() self.assertEqual(2, f2.get()) self.assertEqual(1, f1.get())
def test_PartialGenerator(self): f = ServiceMock(chunks=[1, 2, 3], T=self.T, ioLoop=self.io_loop).execute() collect = [f.get()] for r in f: collect.append(r) self.assertEqual([1, 2, 3], collect)
def test_GetExtraChunksResultsInChokeEvent(self): f = ServiceMock(chunks=[1], T=self.T, ioLoop=self.io_loop).execute() r = f.get() self.assertEqual(1, r) self.assertRaises(ChokeEvent, f.get) self.assertRaises(ChokeEvent, f.get)
def test_GetMultipleMixChunks(self): f = ServiceMock(chunks=[ValueError("Oops1"), 1, IOError("Oops2")], T=self.T, ioLoop=self.io_loop).execute() self.assertRaises(ValueError, f.get) self.assertEqual(1, f.get()) self.assertRaises(IOError, f.get)
def test_GetSingleChunk(self): f = ServiceMock(chunks=[1], T=self.T, ioLoop=self.io_loop).execute() r = f.get() self.assertEqual(1, r)
def test_GetMultipleChunksDeferredly(self): f1 = ServiceMock(chunks=[1], T=self.T, ioLoop=self.io_loop).execute() f2 = ServiceMock(chunks=[2], T=self.T, ioLoop=self.io_loop).execute() self.assertEqual(2, f2.get()) self.assertEqual(1, f1.get())
def test_GetExtraChunksResultsInChokeEvent(self): f = ServiceMock(chunks=[1], T=self.T, ioLoop=self.io_loop).execute() r = f.get() self.assertEqual(1, r) self.assertRaises(ChokeEvent, f.get) self.assertRaises(ChokeEvent, f.get)
def test_GetSingleChunk(self): f = ServiceMock(chunks=[1], T=self.T, ioLoop=self.io_loop).execute() r = f.get() self.assertEqual(1, r)