From ed6fca90c7d0bfb5598335626fcf871f0cadafa9 Mon Sep 17 00:00:00 2001 From: Maxime Armstrong Date: Thu, 2 Jan 2025 15:03:33 -0500 Subject: [PATCH] Update post review --- .../dagster_tableau_tests/test_asset_specs.py | 10 ++++-- .../test_reconstruction.py | 35 +++++++++++++++++-- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/python_modules/libraries/dagster-tableau/dagster_tableau_tests/test_asset_specs.py b/python_modules/libraries/dagster-tableau/dagster_tableau_tests/test_asset_specs.py index e92b284a7b14e..37a92ffdc54de 100644 --- a/python_modules/libraries/dagster-tableau/dagster_tableau_tests/test_asset_specs.py +++ b/python_modules/libraries/dagster-tableau/dagster_tableau_tests/test_asset_specs.py @@ -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 diff --git a/python_modules/libraries/dagster-tableau/dagster_tableau_tests/test_reconstruction.py b/python_modules/libraries/dagster-tableau/dagster_tableau_tests/test_reconstruction.py index 752cbd4391986..21eb9ce4e7142 100644 --- a/python_modules/libraries/dagster-tableau/dagster_tableau_tests/test_reconstruction.py +++ b/python_modules/libraries/dagster-tableau/dagster_tableau_tests/test_reconstruction.py @@ -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 @@ -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")]) @@ -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