Пример #1
0
 def test_workReceived(self):
     """
     Should run the work in a thread
     """
     receiver = FakeReceiver([IResult])
     
     w = ThreadedWorker()
     ISource(w).subscribe(receiver)
     
     def foo(a, b):
         return a + b
     w.registerFunction('foo', 'version1', foo)
     
     work = Work('bob', 'foo', 'version1', 'aaaa', [
         ('a', 'v1', 'xxxx', 'big', 'BIG'),
         ('b', 'v1', 'xxxx', 'fish', 'FISH'),
     ])
     yield w.workReceived(work)
     receiver.receive.assert_called_once_with(work.toResult('bigfish'))
Пример #2
0
 def test_workReceived_error(self):
     """
     If there's an error doing the work, tell the result_receiver
     """
     receiver = FakeReceiver([IResultError])
     
     w = ThreadedWorker()
     ISource(w).subscribe(receiver)
     
     exc = Exception('foo')
     
     def foo(a):
         raise exc
     w.registerFunction('foo', 'v1', foo)
     
     work = Work('bob', 'foo', 'v1', 'xxxx', [
         ('a', 'v1', 'xxxx', 'big', 'BIG'),
     ])
     yield w.workReceived(work)
     receiver.receive.assert_called_once_with(work.toResultError(repr(exc)))