Skip to content

Commit

Permalink
Fix help and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gouline committed Jul 25, 2024
1 parent 365dd48 commit 687d9db
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
2 changes: 2 additions & 0 deletions dbtmetabase/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -380,6 +381,7 @@ def models(
@click.option(
"--tag",
"tags",
metavar="TAG",
multiple=True,
help="Optional tags for exported dbt exposures.",
)
Expand Down
45 changes: 23 additions & 22 deletions tests/test_exposures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
)

0 comments on commit 687d9db

Please sign in to comment.