Exemple #1
0
def test_workflow_action_extrapolate_degenerate_fields(empty_workflow_action):
    empty_workflow_action['id'] = SAMPLE_WF_ACTION
    action = model.WorkflowAction(None, empty_workflow_action, None)
    assert action.name == 'action'

    empty_workflow_action['status'] = 'OK'
    action = model.WorkflowAction(None, empty_workflow_action, None)
    assert action.toString == 'Action name[action] status[OK]'
Exemple #2
0
def test_parse_empty_workflow_action(empty_workflow_action):
    with pytest.raises(exceptions.OozieParsingException) as err:
        wf = model.WorkflowAction(None, empty_workflow_action, None)
    assert "Required key 'id' missing or invalid in WorkflowAction" in str(err)

    empty_workflow_action['id'] = 'bad-wf-action@foo'
    with pytest.raises(exceptions.OozieParsingException) as err:
        wf = model.WorkflowAction(None, empty_workflow_action, None)
    assert "Required key 'id' missing or invalid in WorkflowAction" in str(err)

    empty_workflow_action['id'] = SAMPLE_WF_ACTION
    wf = model.WorkflowAction(None, empty_workflow_action, None)
    assert wf.id == SAMPLE_WF_ACTION
    assert wf._details == {'wat?': 'blarg'}
Exemple #3
0
def test_parse_empty_workflow_action(empty_workflow_action, mock_client):
    with pytest.raises(exceptions.OozieParsingException) as err:
        wf = model.WorkflowAction(mock_client, empty_workflow_action, None)
    assert "Required key 'id' missing or invalid in WorkflowAction" in str(err)

    empty_workflow_action['id'] = 'bad-wf-action@foo'
    with pytest.raises(exceptions.OozieParsingException) as err:
        wf = model.WorkflowAction(mock_client, empty_workflow_action, None)
    assert "Required key 'id' missing or invalid in WorkflowAction" in str(err)

    empty_workflow_action['id'] = SAMPLE_WF_ACTION
    wf = model.WorkflowAction(mock_client, empty_workflow_action, None)
    assert wf.id == SAMPLE_WF_ACTION
    assert wf.client_url == 'https://oozie-server:1234/oozie'
    assert wf._details == {'wat?': 'blarg'}
Exemple #4
0
def test_parse_workflow_action(valid_workflow_action):
    wf = model.WorkflowAction(None, valid_workflow_action, None)
    assert wf.id == SAMPLE_SUBWF_ACTION
    assert wf.name == 'my-sub-workflow'
    assert wf.startTime == datetime.datetime(2016, 6, 2, 13, 16, 48)
    assert wf.endTime == datetime.datetime(2016, 6, 2, 13, 23, 47)
    assert wf.status == model.WorkflowActionStatus.OK
    assert isinstance(wf.conf, six.string_types)  # Does NOT get parsed
    assert wf._details == {'wat?': 'blarg'}
Exemple #5
0
def test_workflow_action_validate_degenerate_fields(empty_workflow_action):
    empty_workflow_action['id'] = SAMPLE_WF_ACTION
    empty_workflow_action['name'] = 'bad-action'
    with pytest.raises(exceptions.OozieParsingException) as err:
        model.WorkflowAction(None, empty_workflow_action, None)
    assert 'name does not match workflow action ID' in str(err)

    empty_workflow_action['name'] = 'action'
    empty_workflow_action['status'] = 'OK'
    empty_workflow_action['toString'] = 'Action name[blarg] status[OK]'
    with pytest.raises(exceptions.OozieParsingException) as err:
        model.WorkflowAction(None, empty_workflow_action, None)
    assert 'toString does not contain workflow action name' in str(err)

    empty_workflow_action['status'] = 'ERROR'
    empty_workflow_action[
        'toString'] = 'Action name[' + SAMPLE_WF_ACTION + '] status[OK]'
    with pytest.raises(exceptions.OozieParsingException) as err:
        model.WorkflowAction(None, empty_workflow_action, None)
    assert 'toString does not contain status' in str(err)
Exemple #6
0
def sample_start_action(valid_start_action, mock_client):
    return model.WorkflowAction(mock_client, valid_start_action, None)
Exemple #7
0
def sample_start_action(valid_start_action):
    return model.WorkflowAction(mock.Mock(), valid_start_action, None)