Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_init(self):
wf = Workflow()
self.assertTrue(isinstance(wf, Workflow))
self.assertTrue(wf.s3 is not None)
self.assertTrue(wf.gbdx_connection is not None)
def test_init(self):
wf = Workflow()
self.assertTrue(isinstance(wf, Workflow))
self.assertTrue(wf.s3 is not None)
self.assertTrue(wf.gbdx_connection is not None)
def test_workflow_get(self):
"""
test gbdx.workflows.get()
"""
wf = Workflow()
output = wf.get('4488969848362445219')
self.assertTrue('id' in output.keys())
self.assertTrue('owner' in output.keys())
self.assertTrue('submitted_time' in output.keys())
self.assertTrue('state' in output.keys())
self.assertTrue('callback' in output.keys())
self.assertTrue('tasks' in output.keys())
def test_task_get_stdout(self):
"""
test gbdx.workflows.get_stdout(,)
"""
wf = Workflow()
output = wf.get_stdout('4488969848362445219','4488969848354891944')
self.assertTrue(len(output) > 0)
def test_workflow_callback_is_retrieved_in_workflow_status(self):
"""
Verify we can set task timeouts, it appears in the json, and launching a workflow works
"""
aoptask = self.gbdx.Task("AOP_Strip_Processor", data='testing')
callback_url = 'http://requestb.in/qg8wzqqg'
# launch a workflow and verify it launches:
w = self.gbdx.Workflow([aoptask], callback=callback_url)
w.execute()
wf_api = WorkflowAPI()
wf_body = wf_api.get(w.id)
assert wf_body['callback'] == callback_url
def test_workflow_search(self):
"""
test gbdx.workflow.search(lookback_h=, state=, owner=)
"""
wf = Workflow()
output = wf.search(lookback_h=12, state='all')
self.assertTrue(len(output), 0)
def test_batch_workflows(self):
"""
tests all 3 endpoints for batch workflows, create, fetch, and cancel
:return:
"""
wf = Workflow()
with open(os.path.join(self.data_path, "batch_workflow.json")) as json_file:
self.batch_workflow_json = json.loads(json_file.read())
# test create
batch_workflow_id = wf.launch_batch_workflow(self.batch_workflow_json)
# test status
batch_workflow_status = wf.batch_workflow_status(batch_workflow_id)
self.assertEqual(batch_workflow_id, batch_workflow_status.get("batch_workflow_id"))
# test cancel
batch_workflow_status = wf.batch_workflow_cancel(batch_workflow_id)
workflows = batch_workflow_status.get('workflows')
def test_task_get_stderr(self):
"""
test gbdx.workflows.get_stdout(,)
"""
wf = Workflow()
output = wf.get_stderr('4488969848362445219','4488969848354891944')
self.assertEqual('', output)
def __init__(self, tasks, **kwargs):
self.workflow = WF()
self.name = kwargs.get('name', str(uuid.uuid4())[:8] )
self.id = None
self.callback = kwargs.get('callback', None )
self.definition = None
self.tasks = tasks
batch_values = []
for task in self.tasks:
if task.batch_values:
batch_values.extend(task.batch_values)
if batch_values:
self.batch_values = batch_values