def test_operator():
    airflow = pytest.importorskip("airflow")

    from airflow import DAG
    from airflow.models import TaskInstance

    dag = DAG(dag_id="foo", start_date=datetime.now())
    task = DominoOperator(
        dag=dag,
        task_id="foo",
        project=TEST_PROJECT,
        isDirect=True,
        command=["python -V"],
    )
    ti = TaskInstance(task=task, execution_date=datetime.now())
    task.execute(ti.get_template_context())
def test_operator_fail(caplog):
    airflow = pytest.importorskip("airflow")

    from airflow import DAG
    from airflow.models import TaskInstance

    dag = DAG(dag_id="foo", start_date=datetime.now())
    task = DominoOperator(
        dag=dag,
        task_id="foo",
        project=TEST_PROJECT,
        isDirect=True,
        command=["python -c 'import sys; sys.exit(1)'"],
    )
    ti = TaskInstance(task=task, execution_date=datetime.now())
    
    with pytest.raises(RunFailedException):
        task.execute(ti.get_template_context())
def test_operator_fail_invalid_tier(caplog):
    airflow = pytest.importorskip("airflow")

    from airflow import DAG
    from airflow.models import TaskInstance

    dag = DAG(dag_id="foo", start_date=datetime.now())
    task = DominoOperator(
        dag=dag,
        task_id="foo",
        project=TEST_PROJECT,
        isDirect=True,
        command=["python -V"],
        tier='this tier does not exist',
    )
    ti = TaskInstance(task=task, execution_date=datetime.now())
    
    with pytest.raises(ValueError):
        task.execute(ti.get_template_context())
Exemple #4
0
def test_my_operator():
    """
    To run this test you need to have at least configured airflow in
    local mode and run:

    `airflow initdb`
    """
    airflow = pytest.importorskip("airflow")

    from airflow import DAG
    from airflow.models import TaskInstance

    dag = DAG(dag_id="foo", start_date=datetime.now())
    task = DominoOperator(
        dag=dag,
        task_id="foo",
        project=TEST_PROJECT,
        isDirect=True,
        command=["python -V"],
    )
    ti = TaskInstance(task=task, execution_date=datetime.now())
    task.execute(ti.get_template_context())
from domino.airflow import DominoOperator

api_key = Variable.get("DOMINO_USER_API_KEY")
host = Variable.get("DOMINO_API_HOST")

default_args = {
    "owner": "domino",
    "depends_on_past": False,
    "start_date": datetime(2019, 6, 5),
    "retries": 1,
    "retry_delay": timedelta(minutes=0.5),
}

dag = DAG(
    "domino_pipeline",
    description="Execute Airflow DAG in Domino",
    default_args=default_args,
    schedule_interval=timedelta(days=1),
)

t1 = DominoOperator(
    task_id="hello_world",
    api_key=api_key,
    host=host,
    project="weaton/domino-test",
    isDirect=True,
    dag=dag,
    command=["python -V"],
)