Skip to content

Commit

Permalink
test: add test for backwards compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Brugman <sfbbrugman@gmail.com>
  • Loading branch information
sbrugman committed Oct 9, 2023
1 parent e3dec7c commit d7255d6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kedro-airflow/kedro_airflow/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _load_config(context: KedroContext) -> dict[str, Any]:
config_loader = context.config_loader
if not hasattr(config_loader, "config_patterns"):
return config_loader.get("airflow*", "airflow/**")

# Set the default pattern for `airflow` if not provided in `settings.py`
if "airflow" not in config_loader.config_patterns.keys():
config_loader.config_patterns.update( # pragma: no cover
Expand Down
24 changes: 23 additions & 1 deletion kedro-airflow/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@

import pytest
import yaml
from kedro.config import ConfigLoader
from kedro.framework.context import KedroContext
from pluggy import PluginManager

from kedro_airflow.plugin import commands
from kedro_airflow.plugin import _load_config, commands


@pytest.mark.parametrize(
Expand Down Expand Up @@ -264,3 +267,22 @@ def test_create_airflow_all_and_pipeline(cli_runner, metadata):
"Error: Invalid value: The `--all` and `--pipeline` option are mutually exclusive."
in result.stdout
)


def test_config_loader_backwards_compatibility(cli_runner, metadata):
# Emulate ConfigLoader in kedro <= 0.18.2
conf_source = Path.cwd() / "conf"
config_loader = ConfigLoader(conf_source=conf_source)
del config_loader.config_patterns
context = KedroContext(
config_loader=config_loader,
hook_manager=PluginManager(project_name=metadata.project_name),
package_name=metadata.package_name,
project_path=metadata.project_path,
)

config = _load_config(context)
assert config == {
"default": {"owner": "again someone else"},
"ds": {"owner": "finally someone else"},
}

0 comments on commit d7255d6

Please sign in to comment.