Ejemplo n.º 1
0
def trigger_create(values, session=None):
    trigger = m.Trigger()
    trigger.update(values.copy())

    try:
        trigger.save(session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntry("Duplicate entry for Trigger: %s" %
                                   e.columns)

    return trigger
Ejemplo n.º 2
0
def task_create(workbook_name, execution_id, values, session=None):
    task = m.Task()
    task.update(values)
    task.update({'workbook_name': workbook_name, 'execution_id': execution_id})

    try:
        task.save(session=session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntry("Duplicate entry for Task: %s" % e.columns)

    return task
Ejemplo n.º 3
0
def workbook_create(values, session=None):
    workbook = m.Workbook()
    workbook.update(values.copy())

    try:
        workbook.save(session=session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntry("Duplicate entry for Workbook: %s" %
                                   e.columns)

    return workbook
Ejemplo n.º 4
0
def create_cron_trigger(values, session=None):
    cron_trigger = models.CronTrigger()

    cron_trigger.update(values)

    try:
        cron_trigger.save(session=session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntry(
            "Duplicate entry for cron trigger %s: %s"
            % (cron_trigger.name, e.columns)
        )
    # TODO(nmakhotkin): Remove this 'except' after fixing
    # https://bugs.launchpad.net/oslo.db/+bug/1458583.
    except db_exc.DBError as e:
        raise exc.DBDuplicateEntry(
            "Duplicate entry for cron trigger: %s" % e
        )

    return cron_trigger
Ejemplo n.º 5
0
def create_delayed_call(values, session=None):
    delayed_call = models.DelayedCall()
    delayed_call.update(values.copy())

    try:
        delayed_call.save(session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntry("Duplicate entry for DelayedCall: %s"
                                   % e.columns)

    return delayed_call
Ejemplo n.º 6
0
def execution_create(workbook_name, values, session=None):
    execution = m.WorkflowExecution()
    execution.update(values.copy())
    execution.update({'workbook_name': workbook_name})

    try:
        execution.save(session=session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntry("Duplicate entry for Execution: %s" %
                                   e.columns)

    return execution
Ejemplo n.º 7
0
def create_environment(values, session=None):
    env = models.Environment()

    env.update(values)

    try:
        env.save(session=session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntry(
            "Duplicate entry for Environment: %s" % e.columns
        )

    return env
Ejemplo n.º 8
0
def create_task_execution(values, session=None):
    task_ex = models.TaskExecution()

    task_ex.update(values)

    try:
        task_ex.save(session=session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntry(
            "Duplicate entry for TaskExecution: %s" % e.columns
        )

    return task_ex
Ejemplo n.º 9
0
def create_workflow_execution(values, session=None):
    wf_ex = models.WorkflowExecution()

    wf_ex.update(values.copy())

    try:
        wf_ex.save(session=session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntry(
            "Duplicate entry for WorkflowExecution: %s" % e.columns
        )

    return wf_ex
Ejemplo n.º 10
0
def create_action_execution(values, session=None):
    a_ex = models.ActionExecution()

    a_ex.update(values.copy())

    try:
        a_ex.save(session=session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntry(
            "Duplicate entry for ActionExecution: %s" % e.columns
        )

    return a_ex
Ejemplo n.º 11
0
def create_action_definition(values, session=None):
    a_def = models.ActionDefinition()

    a_def.update(values)

    try:
        a_def.save(session=session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntry(
            "Duplicate entry for action %s: %s" % (a_def.name, e.columns)
        )

    return a_def
Ejemplo n.º 12
0
def create_workbook(values, session=None):
    wb = models.Workbook()

    wb.update(values.copy())

    try:
        wb.save(session=session)
    except db_exc.DBDuplicateEntry as e:
        raise exc.DBDuplicateEntry(
            "Duplicate entry for WorkbookDefinition: %s" % e.columns
        )

    return wb
Ejemplo n.º 13
0
workflows:
  flow:
    type: direct
    tasks:
      task1:
        action: std.echo output=<% * %>
"""

MOCK_WORKBOOK = mock.MagicMock(return_value=WORKBOOK_DB)
MOCK_WORKBOOKS = mock.MagicMock(return_value=[WORKBOOK_DB])
MOCK_UPDATED_WORKBOOK = mock.MagicMock(return_value=UPDATED_WORKBOOK_DB)
MOCK_DELETE = mock.MagicMock(return_value=None)
MOCK_EMPTY = mock.MagicMock(return_value=[])
MOCK_NOT_FOUND = mock.MagicMock(side_effect=exc.NotFoundException())
MOCK_DUPLICATE = mock.MagicMock(side_effect=exc.DBDuplicateEntry())


class TestWorkbooksController(base.FunctionalTest):
    @mock.patch.object(db_api, "get_workbook", MOCK_WORKBOOK)
    def test_get(self):
        resp = self.app.get('/v2/workbooks/123')

        self.assertEqual(resp.status_int, 200)
        self.assertDictEqual(WORKBOOK, resp.json)

    @mock.patch.object(db_api, "get_workbook", MOCK_NOT_FOUND)
    def test_get_not_found(self):
        resp = self.app.get('/v2/workbooks/123', expect_errors=True)

        self.assertEqual(resp.status_int, 404)
Ejemplo n.º 14
0
 def test_duplicate_obj_code(self):
     exc = exceptions.DBDuplicateEntry()
     self.assertIn("Database object already exists", six.text_type(exc))
     self.assertEqual(exc.http_code, 409)