Exemplo n.º 1
0
    def test_get_task_executions(self):
        wf_ex = db_api.create_workflow_execution(WF_EXECS[0])

        values = copy.copy(TASK_EXECS[0])
        values.update({'workflow_execution_id': wf_ex.id})

        created0 = db_api.create_task_execution(values)

        values = copy.copy(TASK_EXECS[1])
        values.update({'workflow_execution_id': wf_ex.id})

        created1 = db_api.create_task_execution(values)

        fetched = db_api.get_task_executions(
            workflow_name=TASK_EXECS[0]['workflow_name'])

        self.assertEqual(2, len(fetched))
        self.assertEqual(created0, fetched[0])
        self.assertEqual(created1, fetched[1])
Exemplo n.º 2
0
    def test_get_task_executions(self):
        wf_ex = db_api.create_workflow_execution(WF_EXECS[0])

        values = copy.deepcopy(TASK_EXECS[0])
        values.update({'workflow_execution_id': wf_ex.id})

        created0 = db_api.create_task_execution(values)

        values = copy.deepcopy(TASK_EXECS[1])
        values.update({'workflow_execution_id': wf_ex.id})

        created1 = db_api.create_task_execution(values)

        fetched = db_api.get_task_executions(
            workflow_name=TASK_EXECS[0]['workflow_name']
        )

        self.assertEqual(2, len(fetched))
        self.assertEqual(created0, fetched[0])
        self.assertEqual(created1, fetched[1])
Exemplo n.º 3
0
    def test_task_execution_repr(self):
        wf_ex = db_api.create_workflow_execution(WF_EXECS[0])

        values = copy.deepcopy(TASK_EXECS[0])
        values.update({'workflow_execution_id': wf_ex.id})

        s = db_api.create_task_execution(values).__repr__()

        self.assertIn('TaskExecution ', s)
        self.assertIn("'state': 'IDLE'", s)
        self.assertIn("'name': 'my_task1'", s)
Exemplo n.º 4
0
    def test_task_execution_repr(self):
        wf_ex = db_api.create_workflow_execution(WF_EXECS[0])

        values = copy.copy(TASK_EXECS[0])
        values.update({'workflow_execution_id': wf_ex.id})

        s = db_api.create_task_execution(values).__repr__()

        self.assertIn('TaskExecution ', s)
        self.assertIn("'state': 'IDLE'", s)
        self.assertIn("'name': 'my_task1'", s)
Exemplo n.º 5
0
    def test_delete_task_execution(self):
        wf_ex = db_api.create_workflow_execution(WF_EXECS[0])

        values = copy.copy(TASK_EXECS[0])
        values.update({'workflow_execution_id': wf_ex.id})

        created = db_api.create_task_execution(values)

        fetched = db_api.get_task_execution(created.id)

        self.assertEqual(created, fetched)

        db_api.delete_task_execution(created.id)

        self.assertRaises(exc.NotFoundException, db_api.get_task_execution,
                          created.id)
Exemplo n.º 6
0
    def test_create_and_get_and_load_task_execution(self):
        wf_ex = db_api.create_workflow_execution(WF_EXECS[0])

        values = copy.deepcopy(TASK_EXECS[0])
        values.update({'workflow_execution_id': wf_ex.id})

        created = db_api.create_task_execution(values)

        fetched = db_api.get_task_execution(created.id)

        self.assertEqual(created, fetched)

        self.assertNotIsInstance(fetched.workflow_execution, list)

        fetched = db_api.load_task_execution(created.id)

        self.assertEqual(created, fetched)

        self.assertIsNone(db_api.load_task_execution("not-existing-id"))
Exemplo n.º 7
0
    def test_delete_task_execution(self):
        wf_ex = db_api.create_workflow_execution(WF_EXECS[0])

        values = copy.deepcopy(TASK_EXECS[0])
        values.update({'workflow_execution_id': wf_ex.id})

        created = db_api.create_task_execution(values)

        fetched = db_api.get_task_execution(created.id)

        self.assertEqual(created, fetched)

        db_api.delete_task_execution(created.id)

        self.assertRaises(
            exc.NotFoundException,
            db_api.get_task_execution,
            created.id
        )
Exemplo n.º 8
0
    def test_update_task_execution(self):
        wf_ex = db_api.create_workflow_execution(WF_EXECS[0])

        values = copy.copy(TASK_EXECS[0])
        values.update({'workflow_execution_id': wf_ex.id})

        created = db_api.create_task_execution(values)

        self.assertIsNone(created.updated_at)

        updated = db_api.update_task_execution(created.id,
                                               {'workflow_name': 'new_wf'})

        self.assertEqual('new_wf', updated.workflow_name)

        fetched = db_api.get_task_execution(created.id)

        self.assertEqual(updated, fetched)
        self.assertIsNotNone(fetched.updated_at)
Exemplo n.º 9
0
    def test_create_and_get_and_load_task_execution(self):
        wf_ex = db_api.create_workflow_execution(WF_EXECS[0])

        values = copy.copy(TASK_EXECS[0])
        values.update({'workflow_execution_id': wf_ex.id})

        created = db_api.create_task_execution(values)

        fetched = db_api.get_task_execution(created.id)

        self.assertEqual(created, fetched)

        self.assertNotIsInstance(fetched.workflow_execution, list)

        fetched = db_api.load_task_execution(created.id)

        self.assertEqual(created, fetched)

        self.assertIsNone(db_api.load_task_execution("not-existing-id"))
Exemplo n.º 10
0
    def test_update_task_execution(self):
        wf_ex = db_api.create_workflow_execution(WF_EXECS[0])

        values = copy.deepcopy(TASK_EXECS[0])
        values.update({'workflow_execution_id': wf_ex.id})

        created = db_api.create_task_execution(values)

        self.assertIsNone(created.updated_at)

        updated = db_api.update_task_execution(
            created.id,
            {'workflow_name': 'new_wf'}
        )

        self.assertEqual('new_wf', updated.workflow_name)

        fetched = db_api.get_task_execution(created.id)

        self.assertEqual(updated, fetched)
        self.assertIsNotNone(fetched.updated_at)
Exemplo n.º 11
0
    def test_action_executions(self):
        # Store one task with two invocations.
        with db_api.transaction():
            wf_ex = db_api.create_workflow_execution(WF_EXECS[0])

            values = copy.deepcopy(TASK_EXECS[0])
            values.update({'workflow_execution_id': wf_ex.id})

            task = db_api.create_task_execution(values)

            self.assertEqual(0, len(task.executions))

            a_ex1 = db_models.ActionExecution()
            a_ex2 = db_models.ActionExecution()

            task.executions.append(a_ex1)
            task.executions.append(a_ex2)

            self.assertEqual(2, len(task.executions))

        # Make sure associated objects were saved.
        with db_api.transaction():
            task = db_api.get_task_execution(task.id)

            self.assertEqual(2, len(task.executions))

            self.assertNotIsInstance(task.executions[0].task_execution, list)

        # Remove associated objects from collection.
        with db_api.transaction():
            task = db_api.get_task_execution(task.id)

            del task.executions[:]

        # Make sure associated objects were deleted.
        with db_api.transaction():
            task = db_api.get_task_execution(task.id)

            self.assertEqual(0, len(task.executions))
Exemplo n.º 12
0
    def test_action_executions(self):
        # Store one task with two invocations.
        with db_api.transaction():
            wf_ex = db_api.create_workflow_execution(WF_EXECS[0])

            values = copy.copy(TASK_EXECS[0])
            values.update({'workflow_execution_id': wf_ex.id})

            task = db_api.create_task_execution(values)

            self.assertEqual(0, len(task.executions))

            a_ex1 = db_models.ActionExecution()
            a_ex2 = db_models.ActionExecution()

            task.executions.append(a_ex1)
            task.executions.append(a_ex2)

            self.assertEqual(2, len(task.executions))

        # Make sure associated objects were saved.
        with db_api.transaction():
            task = db_api.get_task_execution(task.id)

            self.assertEqual(2, len(task.executions))

            self.assertNotIsInstance(task.executions[0].task_execution, list)

        # Remove associated objects from collection.
        with db_api.transaction():
            task = db_api.get_task_execution(task.id)

            del task.executions[:]

        # Make sure associated objects were deleted.
        with db_api.transaction():
            task = db_api.get_task_execution(task.id)

            self.assertEqual(0, len(task.executions))