Esempio n. 1
0
 def test_patch_create_job_flags(self):
     wd = WorkflowDefinition()
     jd = wd.job_definitions.add()
     workflow = Workflow(
         name='test-workflow',
         project_id=123,
         config=wd.SerializeToString(),
         forkable=False,
         state=WorkflowState.READY,
     )
     db.session.add(workflow)
     db.session.flush()
     job = Job(name='test_job',
               job_type=JobType(1),
               config=jd.SerializeToString(),
               workflow_id=workflow.id,
               project_id=123,
               state=JobState.STOPPED,
               is_disabled=False)
     db.session.add(job)
     db.session.flush()
     workflow.job_ids = str(job.id)
     db.session.commit()
     response = self.patch_helper(f'/api/v2/workflows/{workflow.id}',
                                  data={'create_job_flags': [3]})
     self.assertEqual(response.status_code, HTTPStatus.OK)
     patched_job = Job.query.get(job.id)
     self.assertEqual(patched_job.is_disabled, True)
     response = self.patch_helper(f'/api/v2/workflows/{workflow.id}',
                                  data={'create_job_flags': [1]})
     self.assertEqual(response.status_code, HTTPStatus.OK)
     patched_job = Job.query.get(job.id)
     self.assertEqual(patched_job.is_disabled, False)
Esempio n. 2
0
def add_fake_workflow(session):
    wd = WorkflowDefinition()
    jd = wd.job_definitions.add()
    workflow = Workflow(
        name='test-workflow',
        project_id=123,
        config=wd.SerializeToString(),
        forkable=False,
        state=WorkflowState.READY,
    )
    session.add(workflow)
    session.flush()
    job = Job(name='test_job',
              job_type=JobType(1),
              config=jd.SerializeToString(),
              workflow_id=workflow.id,
              project_id=123,
              state=JobState.STOPPED,
              is_disabled=False)
    session.add(job)
    session.flush()
    workflow.job_ids = str(job.id)
    session.commit()
    return workflow, job