def upgrade():
    Session = sessionmaker(bind=op.get_bind())
    session = Session()
    workflows = session.query(Workflow).all()
    for wf in workflows:
        try:
            Workflow._verify_specification(wf.specification)
        except Exception, e:
            continue  # dont modify invalid workflows
        yaml_dict = yaml.load(wf.specification)
        if not (yaml_dict.get("form")):
            yaml_dict["form"] = FormDict
            wf.specification = yaml.dump(yaml_dict)
def upgrade():
    Session = sessionmaker(bind=op.get_bind())
    session = Session()
    workflows = session.query(Workflow).all()
    for wf in workflows:
        try:
            Workflow._verify_specification(wf.specification)
        except Exception, e:
            continue #dont modify invalid workflows
        yaml_dict = yaml.load(wf.specification)
        if yaml_dict.get('form', IncorrectFormDict) == IncorrectFormDict:
            yaml_dict['form'] = CorrectedFormDict
            wf.specification = yaml.dump(yaml_dict)
def upgrade():
    connection = op.get_bind()
    fetch_workflows = text("select * from workflow")
    update_workflows = text("update workflow set specification = :spec where id = :id")
    for wf in connection.execute(fetch_workflows):
        try:
            Workflow._verify_specification(wf.specification)
        except Exception, e:
            continue #dont modify invalid workflows
        yaml_dict = Yaml.unserialize(wf.specification)
        if not(yaml_dict.get('form')):
            yaml_dict['form'] = FormDict
            specification = Yaml.serialize(yaml_dict)
            connection.execute(update_workflows, spec=specification, id=wf.id)
def upgrade():
    connection = op.get_bind()
    fetch_workflows = text("select * from workflow")
    update_workflows = text(
        "update workflow set specification = :spec where id = :id")
    for wf in connection.execute(fetch_workflows):
        try:
            Workflow._verify_specification(wf.specification)
        except Exception, e:
            continue  #dont modify invalid workflows
        yaml_dict = Yaml.unserialize(wf.specification)
        if not (yaml_dict.get('form')):
            yaml_dict['form'] = FormDict
            specification = Yaml.serialize(yaml_dict)
            connection.execute(update_workflows, spec=specification, id=wf.id)
Esempio n. 5
0
 def test_workflow_verify_specification_fail(self, client):
     """Tests invalid specification workflow yaml"""
     name = 'invalid specification workflow'
     specification = '\n'.join([
         'name: %s' % name,
         'entry: non-existing-step',
         'steps: ',
         '  step-0:',
         '    operation: flux:test-operation',
         '    postoperation:',
         '     - actions:',
         '       - action: execute-operation',
         '         operation: flux:test-operation',
         '       condition: some condition',
         '       terminal: false',
     ])
     with self.assertRaises(OperationError):
         Workflow._verify_specification(specification)
Esempio n. 6
0
 def test_workflow_verify_specification_pass(self, client):
     """Tests valid specification workflow yaml"""
     name = 'valid specification workflow'
     specification = '\n'.join([
         'name: %s' % name,
         'form:',
         '  schema:',
         '    fieldtype: structure',
         '    structure:',
         '      some_test_arg:',
         '        fieldtype: text',
         '        required: true',
         '  layout:',
         '    - title: Test Section 1',
         '      elements:',
         '        - type: textbox',
         '          field: some_test_arg',
         '          label: Test Field #1',
         '          options:',
         '            multiline: true',
         'entry: step-0',
         'steps: ',
         '  step-0:',
         '    operation: flux:test-operation',
         '    timeout: 30',
         '    preoperation:',
         '     - actions:',
         '       - action: execute-step',
         '         step: step-1',
         '         parameters:',
         '           arg1: ${some_test_arg}',
         '           arg2: literal arg',
         '    postoperation:',
         '     - actions:',
         '       - action: execute-operation',
         '         operation: flux:test-operation',
         '       condition: some condition',
         '       terminal: false',
         '  step-1:',
         '     operation: flux:test-operation',
     ])
     Workflow._verify_specification(specification)