def test_task_list(self): INIT = consts.TaskStatus.INIT task_init = sorted(self._create_task()["uuid"] for i in moves.range(3)) FINISHED = consts.TaskStatus.FINISHED task_finished = sorted( self._create_task({ "status": FINISHED, "deployment_uuid": self.deploy["uuid"] })["uuid"] for i in moves.range(3)) task_all = sorted(task_init + task_finished) def get_uuids(status=None, deployment=None): tasks = db.task_list(status=status, deployment=deployment) return sorted(task["uuid"] for task in tasks) self.assertEqual(task_all, get_uuids(None)) self.assertEqual(task_init, get_uuids(status=INIT)) self.assertEqual(task_finished, get_uuids(status=FINISHED)) self.assertRaises(exceptions.DeploymentNotFound, get_uuids, deployment="non-existing-deployment") deleted_task_uuid = task_finished.pop() db.task_delete(deleted_task_uuid) self.assertEqual(task_init, get_uuids(INIT)) self.assertEqual(sorted(task_finished), get_uuids(FINISHED))
def cleanup_previous_tasks(self, deployment_id): tasks = self.get_tasks_uuid_from_db(deployment_id) for task_id in tasks: db.task_delete(task_id) logging.info("Delete all tasks of deployment[ID: %s]" % deployment_id)
def test_task_list(self): fake_deploy_uuid = str(uuid.uuid4()) INIT = consts.TaskStatus.INIT task_init = sorted(self._create_task()['uuid'] for i in xrange(3)) FINISHED = consts.TaskStatus.FINISHED task_finished = sorted(self._create_task( {'status': FINISHED, 'deployment_uuid': fake_deploy_uuid})[ 'uuid'] for i in xrange(3)) task_all = sorted(task_init + task_finished) def get_uuids(status=None, deployment=None): tasks = db.task_list(status=status, deployment=deployment) return sorted(task['uuid'] for task in tasks) self.assertEqual(task_all, get_uuids(None)) self.assertEqual(task_init, get_uuids(status=INIT)) self.assertEqual(task_finished, get_uuids(status=FINISHED)) self.assertRaises(exceptions.DeploymentNotFound, get_uuids, deployment=fake_deploy_uuid) deleted_task_uuid = task_finished.pop() db.task_delete(deleted_task_uuid) self.assertEqual(task_init, get_uuids(INIT)) self.assertEqual(sorted(task_finished), get_uuids(FINISHED))
def test_task_list(self): INIT = consts.TaskStatus.INIT task_init = sorted(self._create_task()["uuid"] for i in moves.range(3)) FINISHED = consts.TaskStatus.FINISHED task_finished = sorted(self._create_task( {"status": FINISHED, "deployment_uuid": self.deploy["uuid"]})[ "uuid"] for i in moves.range(3)) task_all = sorted(task_init + task_finished) def get_uuids(status=None, deployment=None): tasks = db.task_list(status=status, deployment=deployment) return sorted(task["uuid"] for task in tasks) self.assertEqual(task_all, get_uuids(None)) self.assertEqual(task_init, get_uuids(status=INIT)) self.assertEqual(task_finished, get_uuids(status=FINISHED)) self.assertRaises(exceptions.DeploymentNotFound, get_uuids, deployment="non-existing-deployment") deleted_task_uuid = task_finished.pop() db.task_delete(deleted_task_uuid) self.assertEqual(task_init, get_uuids(INIT)) self.assertEqual(sorted(task_finished), get_uuids(FINISHED))
def test_task_delete_with_results(self): task_id = self._create_task()['uuid'] db.task_result_create(task_id, {task_id: task_id}, {task_id: task_id}) res = db.task_result_get_all_by_uuid(task_id) self.assertEqual(len(res), 1) db.task_delete(task_id) res = db.task_result_get_all_by_uuid(task_id) self.assertEqual(len(res), 0)
def test_task_delete_by_uuid_and_status(self): values = { 'status': consts.TaskStatus.FINISHED, } task1 = self._create_task(values=values)['uuid'] task2 = self._create_task(values=values)['uuid'] db.task_delete(task1, status=consts.TaskStatus.FINISHED) self.assertRaises(exceptions.TaskNotFound, self._get_task, task1) self.assertEqual(task2, self._get_task(task2)['uuid'])
def test_task_list(self): INIT = consts.TaskStatus.INIT task_init = sorted(self._create_task()['uuid'] for i in xrange(3)) FINISHED = consts.TaskStatus.FINISHED task_finished = sorted(self._create_task({'status': FINISHED})['uuid'] for i in xrange(3)) task_all = sorted(task_init + task_finished) def get_uuids(status): tasks = db.task_list(status=status) return sorted(task['uuid'] for task in tasks) self.assertEqual(task_all, get_uuids(None)) self.assertEqual(task_init, get_uuids(INIT)) self.assertEqual(task_finished, get_uuids(FINISHED)) deleted_task_uuid = task_finished.pop() db.task_delete(deleted_task_uuid) self.assertEqual(task_init, get_uuids(INIT)) self.assertEqual(sorted(task_finished), get_uuids(FINISHED))
def test_task_list(self): INIT = consts.TaskStatus.INIT task_init = sorted(self._create_task()["uuid"] for i in xrange(3)) FINISHED = consts.TaskStatus.FINISHED task_finished = sorted(self._create_task({"status": FINISHED})["uuid"] for i in xrange(3)) task_all = sorted(task_init + task_finished) def get_uuids(status, active=True): tasks = db.task_list(status=status, active=active) return sorted(task["uuid"] for task in tasks) self.assertEqual(task_all, get_uuids(None)) self.assertEqual(task_init, get_uuids(INIT)) self.assertEqual(task_finished, get_uuids(FINISHED)) deleted_task_uuid = task_finished.pop() db.task_delete(deleted_task_uuid) self.assertEqual(sorted(task_finished), get_uuids(FINISHED)) self.assertEqual(task_all, get_uuids(None, active=None)) self.assertEqual([deleted_task_uuid], get_uuids(None, active=False))
def test_task_list(self): INIT = consts.TaskStatus.INIT task_init = sorted(self._create_task()['uuid'] for i in xrange(3)) FINISHED = consts.TaskStatus.FINISHED task_finished = sorted( self._create_task({'status': FINISHED})['uuid'] for i in xrange(3)) task_all = sorted(task_init + task_finished) def get_uuids(status): tasks = db.task_list(status=status) return sorted(task['uuid'] for task in tasks) self.assertEqual(task_all, get_uuids(None)) self.assertEqual(task_init, get_uuids(INIT)) self.assertEqual(task_finished, get_uuids(FINISHED)) deleted_task_uuid = task_finished.pop() db.task_delete(deleted_task_uuid) self.assertEqual(task_init, get_uuids(INIT)) self.assertEqual(sorted(task_finished), get_uuids(FINISHED))
def test_task_delete(self): task1, task2 = self._create_task()['uuid'], self._create_task()['uuid'] db.task_delete(task1) self.assertRaises(exceptions.TaskNotFound, self._get_task, task1) self.assertEqual(task2, self._get_task(task2)['uuid'])
def delete(self, status=None): db.task_delete(self.task["uuid"], status=status)
def delete(self, status=None): db.task_delete(self.task['uuid'], status=status)
def delete_by_uuid(uuid, status=None): db.task_delete(uuid, status=status)