def test_get_action_errors(mock_get_action):
    '''verify when get_action_db returns None, ApiError is raised'''
    action_resource = ActionsIdResource()
    action_id = '12345678901234567890123456'

    with pytest.raises(ApiError) as expected_exc:
        action_resource.get_action(action_id)
    assert action_id in str(expected_exc)
    assert 'Action not found' in str(expected_exc)
def test_get_action_success():
    """
    Tests the main response from get all actions
    """
    action_resource = ActionsIdResource()
    # stubs for db
    action_resource.get_action_db = actions_db
    action_resource.get_dag_run_db = dag_runs_db
    action_resource.get_tasks_db = tasks_db
    action_resource.get_validations_db = get_validations
    action_resource.get_action_command_audit_db = get_ac_audit

    action = action_resource.get_action('12345678901234567890123456')
    if action['name'] == 'dag_it':
        assert len(action['steps']) == 3
        assert action['dag_status'] == 'FAILED'
        assert len(action['command_audit']) == 2