Skip to content

Commit

Permalink
Update post review
Browse files Browse the repository at this point in the history
  • Loading branch information
maximearmstrong committed Jan 2, 2025
1 parent ec0c8f1 commit ed6fca9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,13 @@ def test_translator_custom_metadata_legacy(
resource.build_client()

# Pass the translator type
all_asset_specs = load_tableau_asset_specs(
workspace=resource, dagster_tableau_translator=MyCustomTranslator
)
with pytest.warns(
DeprecationWarning,
match=r"Support of `dagster_tableau_translator` as a Type\[DagsterTableauTranslator\]",
):
all_asset_specs = load_tableau_asset_specs(
workspace=resource, dagster_tableau_translator=MyCustomTranslator
)
asset_spec = next(spec for spec in all_asset_specs)

assert "custom" in asset_spec.metadata
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest.mock import MagicMock

import pytest
from dagster._core.code_pointer import CodePointer
from dagster._core.definitions.asset_spec import AssetSpec
from dagster._core.definitions.definitions_class import Definitions
Expand Down Expand Up @@ -86,9 +87,13 @@ def get_asset_spec(self, data: TableauTranslatorData) -> AssetSpec:
return default_spec.replace_attributes(key=default_spec.key.with_prefix("my_prefix"))

# Pass the translator type
tableau_specs = load_tableau_asset_specs(
workspace=resource, dagster_tableau_translator=MyCoolTranslator
)
with pytest.warns(
DeprecationWarning,
match=r"Support of `dagster_tableau_translator` as a Type\[DagsterTableauTranslator\]",
):
tableau_specs = load_tableau_asset_specs(
workspace=resource, dagster_tableau_translator=MyCoolTranslator
)

return Definitions(assets=[*tableau_specs], jobs=[define_asset_job("all_asset_job")])

Expand Down Expand Up @@ -208,3 +213,27 @@ def test_load_assets_workspace_data_translator(
assert all(
key.path[0] == "my_prefix" for key in repository_def.assets_defs_by_key.keys()
), repository_def.assets_defs_by_key


def test_load_assets_workspace_data_translator_legacy(
sign_in: MagicMock,
get_workbooks: MagicMock,
get_workbook: MagicMock,
get_view: MagicMock,
get_job: MagicMock,
refresh_workbook: MagicMock,
cancel_job: MagicMock,
) -> None:
with instance_for_test() as _instance:
repository_def = initialize_repository_def_from_pointer(
pointer=CodePointer.from_python_file(
__file__,
"cacheable_asset_defs_custom_translator_legacy",
None,
)
)

assert len(repository_def.assets_defs_by_key) == 3
assert all(
key.path[0] == "my_prefix" for key in repository_def.assets_defs_by_key.keys()
), repository_def.assets_defs_by_key

0 comments on commit ed6fca9

Please sign in to comment.