Example #1
0
 def test_start__KeyboardInterrupt(self):
     worker = self.worker
     worker.blueprint = Mock(name='blueprint')
     worker.blueprint.start.side_effect = KeyboardInterrupt()
     worker.stop = Mock(name='stop')
     worker.start()
     worker.stop.assert_called_with(exitcode=EX_FAILURE)
Example #2
0
 def test_start__KeyboardInterrupt(self):
     worker = self.worker
     worker.blueprint = Mock(name='blueprint')
     worker.blueprint.start.side_effect = KeyboardInterrupt()
     worker.stop = Mock(name='stop')
     worker.start()
     worker.stop.assert_called_with(exitcode=EX_FAILURE)
Example #3
0
 def test_step_raises(self):
     worker = self.worker
     step = Mock()
     worker.steps = [step]
     step.start.side_effect = TypeError()
     worker.stop = Mock()
     worker.start()
     worker.stop.assert_called_with(exitcode=EX_FAILURE)
Example #4
0
 def test_step_raises(self):
     worker = self.worker
     step = Mock()
     worker.steps = [step]
     step.start.side_effect = TypeError()
     worker.stop = Mock()
     worker.start()
     worker.stop.assert_called_with(exitcode=EX_FAILURE)
Example #5
0
 def test_start__terminate(self):
     worker = self.worker
     worker.blueprint.shutdown_complete.set()
     worker.blueprint.started = 5
     worker.blueprint.state = RUN
     worker.steps = [MockStep() for _ in range(5)]
     worker.start()
     for w in worker.steps[:3]:
         w.start.assert_called()
     assert worker.blueprint.started == len(worker.steps)
     assert worker.blueprint.state == RUN
     worker.terminate()
     for step in worker.steps:
         step.terminate.assert_called()
     worker.blueprint.state = TERMINATE
     worker.terminate()
Example #6
0
 def test_start__terminate(self):
     worker = self.worker
     worker.blueprint.shutdown_complete.set()
     worker.blueprint.started = 5
     worker.blueprint.state = RUN
     worker.steps = [MockStep() for _ in range(5)]
     worker.start()
     for w in worker.steps[:3]:
         w.start.assert_called()
     assert worker.blueprint.started == len(worker.steps)
     assert worker.blueprint.state == RUN
     worker.terminate()
     for step in worker.steps:
         step.terminate.assert_called()
     worker.blueprint.state = TERMINATE
     worker.terminate()
Example #7
0
    def test_start__stop(self):
        worker = self.worker
        worker.blueprint.shutdown_complete.set()
        worker.steps = [MockStep(StartStopStep(self)) for _ in range(4)]
        worker.blueprint.state = RUN
        worker.blueprint.started = 4
        for w in worker.steps:
            w.start = Mock()
            w.close = Mock()
            w.stop = Mock()

        worker.start()
        for w in worker.steps:
            w.start.assert_called()
        worker.consumer = Mock()
        worker.stop(exitcode=3)
        for stopstep in worker.steps:
            stopstep.close.assert_called()
            stopstep.stop.assert_called()

        # Doesn't close pool if no pool.
        worker.start()
        worker.pool = None
        worker.stop()

        # test that stop of None is not attempted
        worker.steps[-1] = None
        worker.start()
        worker.stop()
Example #8
0
    def test_start__stop(self):
        worker = self.worker
        worker.blueprint.shutdown_complete.set()
        worker.steps = [MockStep(StartStopStep(self)) for _ in range(4)]
        worker.blueprint.state = RUN
        worker.blueprint.started = 4
        for w in worker.steps:
            w.start = Mock()
            w.close = Mock()
            w.stop = Mock()

        worker.start()
        for w in worker.steps:
            w.start.assert_called()
        worker.consumer = Mock()
        worker.stop(exitcode=3)
        for stopstep in worker.steps:
            stopstep.close.assert_called()
            stopstep.stop.assert_called()

        # Doesn't close pool if no pool.
        worker.start()
        worker.pool = None
        worker.stop()

        # test that stop of None is not attempted
        worker.steps[-1] = None
        worker.start()
        worker.stop()