def test_action_acquire(self): action = _create_action(self.ctx) timestamp = time.time() action = db_api.action_acquire(self.ctx, action.id, 'worker1', timestamp) self.assertEqual('worker1', action.owner) self.assertEqual(db_api.ACTION_RUNNING, action.status) self.assertEqual(timestamp, action.start_time) action = db_api.action_acquire(self.ctx, action.id, 'worker2', timestamp) self.assertIsNone(action)
def test_action_acquire(self): action = _create_action(self.ctx) db_api.action_update(self.ctx, action.id, {'status': 'READY'}) timestamp = time.time() action = db_api.action_acquire(self.ctx, action.id, 'worker1', timestamp) self.assertEqual('worker1', action.owner) self.assertEqual(consts.ACTION_RUNNING, action.status) self.assertEqual(timestamp, action.start_time) action = db_api.action_acquire(self.ctx, action.id, 'worker2', timestamp) self.assertIsNone(action)
def test_action_acquire_failed(self): action = _create_action(self.ctx) timestamp = time.time() action = db_api.action_acquire(self.ctx, action.id, 'worker1', timestamp) self.assertIsNone(action)