def test_parse_empty_workflow(empty_workflow): with pytest.raises(exceptions.OozieParsingException) as err: wf = model.Workflow(None, empty_workflow, None) assert "Required key 'id' missing or invalid in Workflow" in str(err) empty_workflow['id'] = 'bad-wf-id' with pytest.raises(exceptions.OozieParsingException) as err: wf = model.Workflow(None, empty_workflow, None) assert "Required key 'id' missing or invalid in Workflow" in str(err) empty_workflow['id'] = SAMPLE_WF_ID wf = model.Workflow(None, empty_workflow, None) assert wf.id == SAMPLE_WF_ID assert wf._details == {'wat?': 'blarg'}
def test_workflow_validate_degenerate_fields(empty_workflow): empty_workflow['id'] = SAMPLE_WF_ID empty_workflow['status'] = 'RUNNING' empty_workflow['toString'] = 'Workflow id[blarg] status [RUNNING]' with pytest.raises(exceptions.OozieParsingException) as err: model.Workflow(None, empty_workflow, None) assert 'toString does not contain workflow ID' in str(err) empty_workflow['status'] = 'KILLED' empty_workflow[ 'toString'] = 'Workflow id[' + SAMPLE_WF_ID + '] status[RUNNING]' with pytest.raises(exceptions.OozieParsingException) as err: model.Workflow(None, empty_workflow, None) assert 'toString does not contain status' in str(err)
def test_parse_empty_workflow(empty_workflow, mock_client): with pytest.raises(exceptions.OozieParsingException) as err: wf = model.Workflow(mock_client, empty_workflow, None) assert "Required key 'id' missing or invalid in Workflow" in str(err) empty_workflow['id'] = 'bad-wf-id' with pytest.raises(exceptions.OozieParsingException) as err: wf = model.Workflow(mock_client, empty_workflow, None) assert "Required key 'id' missing or invalid in Workflow" in str(err) empty_workflow['id'] = SAMPLE_WF_ID wf = model.Workflow(mock_client, empty_workflow, None) assert wf.id == SAMPLE_WF_ID assert wf.client_url == 'https://oozie-server:1234/oozie' assert wf._details == {'wat?': 'blarg'}
def test_parse_workflow(valid_workflow): wf = model.Workflow(None, valid_workflow, None) assert wf.id == SAMPLE_WF_ID assert wf.appName == 'my-test-workflow' assert wf.createdTime == datetime.datetime(2016, 6, 2, 13, 16, 46) assert wf.startTime == datetime.datetime(2016, 6, 2, 13, 16, 46) assert wf.endTime == datetime.datetime(2016, 6, 2, 21, 40, 38) assert wf.lastModTime == datetime.datetime(2016, 6, 2, 21, 40, 38) assert wf.status == model.WorkflowStatus.SUCCEEDED assert wf._details == {'wat?': 'blarg'}
def test_parse_workflow(valid_workflow, mock_client): wf = model.Workflow(mock_client, valid_workflow, None) assert wf.id == SAMPLE_WF_ID assert wf.appName == 'my-test-workflow' assert wf.createdTime == datetime.datetime(2016, 6, 2, 13, 16, 46) assert wf.startTime == datetime.datetime(2016, 6, 2, 13, 16, 46) assert wf.endTime == datetime.datetime(2016, 6, 2, 21, 40, 38) assert wf.lastModTime == datetime.datetime(2016, 6, 2, 21, 40, 38) assert wf.status == model.WorkflowStatus.SUCCEEDED assert wf.client_url == 'https://oozie-server:1234/oozie' assert wf._details == {'wat?': 'blarg'}
def test_workflow_extrapolate_degenerate_fields(empty_workflow): empty_workflow['id'] = SAMPLE_WF_ID empty_workflow['status'] = 'RUNNING' wf = model.Workflow(None, empty_workflow, None) assert wf.toString == 'Workflow id[' + SAMPLE_WF_ID + '] status[RUNNING]'
def sample_workflow(valid_workflow, mock_client): return model.Workflow(mock_client, valid_workflow, None)
def sample_workflow(valid_workflow): return model.Workflow(mock.Mock(), valid_workflow, None)