-
Notifications
You must be signed in to change notification settings - Fork 1
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 #11 from airflow-laminar/tkp/config
integrate with airflow-config
- Loading branch information
Showing
14 changed files
with
107 additions
and
19 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from pathlib import Path | ||
|
||
conf_text = """# @package _global_ | ||
_target_: airflow_config.Configuration | ||
default_args: | ||
_target_: airflow_config.DefaultArgs | ||
owner: test | ||
extensions: | ||
priority: | ||
_target_: airflow_config.PriorityConfiguration | ||
slack: | ||
_target_: airflow_config.SlackConfiguration | ||
token: abc | ||
channel: def | ||
""" | ||
|
||
|
||
def test_config_loading_via_airflow_config(airflow_config, dag_run): | ||
dags_path = Path(airflow_config) / "dags" | ||
conf_path = dags_path / "config" | ||
conf_path.mkdir(parents=True, exist_ok=True) | ||
conf_file = conf_path / "config.yaml" | ||
conf_file.write_text(conf_text) | ||
|
||
from airflow_config import Configuration | ||
|
||
config = Configuration.load("config", "config", basepath=str(dags_path), _offset=4) | ||
ret = getattr(getattr(config.extensions.get("priority", None), "slack", None), "token", None) | ||
assert ret == "abc" | ||
|
||
|
||
def test_call_plugin_via_airflow_config(airflow_config, dag_run): | ||
dags_path = Path(airflow_config) / "dags" | ||
conf_path = dags_path / "config" | ||
conf_path.mkdir(parents=True, exist_ok=True) | ||
conf_file = conf_path / "config.yaml" | ||
conf_file.write_text(conf_text) | ||
from airflow_priority.plugins.slack import get_client | ||
|
||
client = get_client() | ||
assert client is not None | ||
assert client.token == "abc" | ||
# with patch("airflow_priority.plugins.slack.send_metric_slack") as p2, \ | ||
# patch("airflow_priority.plugins.slack.send_metric_slack") as p1: | ||
# on_dag_run_failed(dag_run, "test") | ||
|
||
# assert p1.call_args == [] |
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
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
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