-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from airflow-laminar/tkp/enabled
Small fixes to dag enablement
- Loading branch information
Showing
6 changed files
with
102 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
airflow_config/tests/setups/good/dag-disable-perdag/config/test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# @package _global_ | ||
_target_: airflow_config.Configuration | ||
default_args: | ||
_target_: airflow_config.TaskArgs | ||
owner: test | ||
email: [[email protected]] | ||
email_on_failure: false | ||
email_on_retry: false | ||
retries: 0 | ||
depends_on_past: false | ||
|
||
default_dag_args: | ||
_target: airflow_config.DagArgs | ||
schedule: "01:00" | ||
start_date: "2024-01-01" | ||
catchup: false | ||
tags: ["utility", "test"] | ||
enabled: false | ||
|
||
dags: | ||
example_dag: | ||
default_args: | ||
owner: "custom_owner" | ||
description: "this is an example dag" | ||
schedule: "0 3 * * *" | ||
max_active_tasks: 1 | ||
max_active_runs: 1 | ||
enabled: true | ||
|
||
example_dag2: | ||
default_args: | ||
owner: "custom_owner2" | ||
schedule: "0 4 * * *" |
14 changes: 14 additions & 0 deletions
14
airflow_config/tests/setups/good/dag-disable-perdag/test_dag_disable_perdag.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from unittest.mock import patch | ||
|
||
from airflow_config import DAG, load_config | ||
|
||
|
||
def test_create_dag_from_config(): | ||
with patch("sys.exit") as sys_exit: | ||
conf = load_config("config", "test") | ||
DAG(dag_id="testdag", config=conf) | ||
assert sys_exit.call_count == 1 | ||
DAG(dag_id="example_dag", config=conf) | ||
assert sys_exit.call_count == 1 | ||
DAG(dag_id="example_da2", config=conf) | ||
assert sys_exit.call_count == 2 |
32 changes: 32 additions & 0 deletions
32
airflow_config/tests/setups/good/dag-disable/config/test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# @package _global_ | ||
_target_: airflow_config.Configuration | ||
default_args: | ||
_target_: airflow_config.TaskArgs | ||
owner: test | ||
email: [[email protected]] | ||
email_on_failure: false | ||
email_on_retry: false | ||
retries: 0 | ||
depends_on_past: false | ||
|
||
default_dag_args: | ||
_target: airflow_config.DagArgs | ||
schedule: "01:00" | ||
start_date: "2024-01-01" | ||
catchup: false | ||
tags: ["utility", "test"] | ||
enabled: false | ||
|
||
dags: | ||
example_dag: | ||
default_args: | ||
owner: "custom_owner" | ||
description: "this is an example dag" | ||
schedule: "0 3 * * *" | ||
max_active_tasks: 1 | ||
max_active_runs: 1 | ||
|
||
example_dag2: | ||
default_args: | ||
owner: "custom_owner2" | ||
schedule: "0 4 * * *" |
12 changes: 12 additions & 0 deletions
12
airflow_config/tests/setups/good/dag-disable/test_dag_disable.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from unittest.mock import patch | ||
|
||
from airflow_config import DAG, load_config | ||
|
||
|
||
def test_create_dag_from_config(): | ||
with patch("sys.exit") as sys_exit: | ||
conf = load_config("config", "test") | ||
DAG(dag_id="testdag", config=conf) | ||
assert sys_exit.call_count == 1 | ||
DAG(dag_id="example_dag", config=conf) | ||
assert sys_exit.call_count == 2 |