def test_more_workers_stop(self): upgrade_center = UpgradeCenter() normal_worker1 = NormalWorker() normal_worker2 = NormalWorker() upgrade_center.register(normal_worker1) upgrade_center.register(normal_worker2) upgrade_center.start() upgrade_center.stop() self.assertEqual( [normal_worker1.is_stopped, normal_worker2.is_stopped], [True, True])
def test_normal_stop(self): upgrade_center = UpgradeCenter() normal_worker = NormalWorker() upgrade_center.register(normal_worker) upgrade_center.start() upgrade_center.stop() self.assertTrue(normal_worker.is_stopped, 'Worker is stopped')
def test_before_after_workers(self): upgrade_center = UpgradeCenter() before_worker = NormalWorker() before_worker.group = UPGRADE_GROUP.BEFORE_ALL upgrade_center.register(before_worker) after_worker = NormalWorker() after_worker.group = UPGRADE_GROUP.AFTER_ALL upgrade_center.register(after_worker) upgrade_center.register(NormalWorker()) upgrade_center.register(NormalWorker()) upgrade_center.register(NormalWorker()) upgrade_center.on('finish', self.handle_done) upgrade_center.start()
def test_with_error_worker(self): upgrade_center = UpgradeCenter() upgrade_center.register(ErrorWorker()) upgrade_center.register(NormalWorker()) upgrade_center.on('error', self.handle_error) upgrade_center.start()
def test_more_workers(self): upgrade_center = UpgradeCenter() upgrade_center.register(NormalWorker()) upgrade_center.register(NormalWorker()) upgrade_center.on('finish', self.handle_done) upgrade_center.start()
def test_start_2_times(self): upgrade_center = UpgradeCenter() upgrade_center.register(NormalWorker()) _ = upgrade_center.start() second_result = upgrade_center.start() self.assertFalse(second_result, 'Cannot start 2 times')