From 687d9db968dff0b4399e00bd421e157987dd6a98 Mon Sep 17 00:00:00 2001 From: Mike Gouline <1960272+gouline@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:46:05 +1000 Subject: [PATCH] Fix help and tests --- dbtmetabase/__main__.py | 2 ++ tests/test_exposures.py | 45 +++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/dbtmetabase/__main__.py b/dbtmetabase/__main__.py index d98f822..a28a844 100644 --- a/dbtmetabase/__main__.py +++ b/dbtmetabase/__main__.py @@ -155,6 +155,7 @@ def _add_setup(func: Callable) -> Callable: @click.option( "--http-header", "http_headers", + metavar="KEY VALUE", type=(str, str), multiple=True, help="Additional HTTP request headers.", @@ -380,6 +381,7 @@ def models( @click.option( "--tag", "tags", + metavar="TAG", multiple=True, help="Optional tags for exported dbt exposures.", ) diff --git a/tests/test_exposures.py b/tests/test_exposures.py index 7e75a84..5f52e4c 100644 --- a/tests/test_exposures.py +++ b/tests/test_exposures.py @@ -40,6 +40,29 @@ def test_exposures(core: MockDbtMetabase): ) +def test_exposures_aliased_ref(core: MockDbtMetabase): + for model in core.manifest.read_models(): + if not model.name.startswith("stg_"): + model.alias = f"{model.name}_alias" + + aliases = [m.alias for m in core.manifest.read_models()] + assert "orders_alias" in aliases + assert "customers_alias" in aliases + + fixtures_path = FIXTURES_PATH / "exposure" / "default" + output_path = TMP_PATH / "exposure" / "aliased" + core.extract_exposures( + output_path=str(output_path), + output_grouping=None, + tags=["metabase"], + ) + + _assert_exposures( + fixtures_path / "exposures.yml", + output_path / "exposures.yml", + ) + + def test_exposures_collection_grouping(core: MockDbtMetabase): fixtures_path = FIXTURES_PATH / "exposure" / "collection" output_path = TMP_PATH / "exposure" / "collection" @@ -65,25 +88,3 @@ def test_exposures_grouping_type(core: MockDbtMetabase): for file in (fixtures_path / "dashboard").iterdir(): _assert_exposures(file, output_path / "dashboard" / file.name) - - -def test_exposures_aliased_ref(core: MockDbtMetabase): - for model in core.manifest.read_models(): - if not model.name.startswith("stg_"): - model.alias = f"{model.name}_alias" - - aliases = [m.alias for m in core.manifest.read_models()] - assert "orders_alias" in aliases - assert "customers_alias" in aliases - - fixtures_path = FIXTURES_PATH / "exposure" / "default" - output_path = TMP_PATH / "exposure" / "aliased" - core.extract_exposures( - output_path=str(output_path), - output_grouping=None, - ) - - _assert_exposures( - fixtures_path / "exposures.yml", - output_path / "exposures.yml", - )