def test_get_tasks_db(mock_get_tasks_by_id):
    expected = {
        'id': '43',
        'action_id': '12345678901234567890123456',
        'validation_name': 'It has shiny goodness',
        'details': 'This was not very shiny.'
    }
    mock_get_tasks_by_id.return_value = expected
    action_resource = ActionsIdResource()
    dag_id = 'test_dag_id'
    execution_date = 'test_execution_date'

    result = action_resource.get_tasks_db(dag_id, execution_date)
    mock_get_tasks_by_id.assert_called_once_with(dag_id=dag_id,
                                                 execution_date=execution_date)
    assert result == expected
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