From 99e73bddf6ac242bcf62518cc5d3f5557c1ab28f Mon Sep 17 00:00:00 2001 From: Maxime Armstrong Date: Thu, 5 Dec 2024 15:10:45 -0500 Subject: [PATCH] Update post review --- .../dagster_fivetran/resources.py | 3 ++- .../experimental/conftest.py | 2 +- .../experimental/test_resources.py | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/python_modules/libraries/dagster-fivetran/dagster_fivetran/resources.py b/python_modules/libraries/dagster-fivetran/dagster_fivetran/resources.py index 3ea581594a96f..a2c82215d0e46 100644 --- a/python_modules/libraries/dagster-fivetran/dagster_fivetran/resources.py +++ b/python_modules/libraries/dagster-fivetran/dagster_fivetran/resources.py @@ -1034,7 +1034,8 @@ def sync_and_poll( materialized_asset_keys.add(materialization.asset_key) else: context.log.warning( - f"An unexpected asset was materialized: {materialization.asset_key}" + f"An unexpected asset was materialized: {materialization.asset_key}. " + f"Yielding a materialization event." ) yield materialization diff --git a/python_modules/libraries/dagster-fivetran/dagster_fivetran_tests/experimental/conftest.py b/python_modules/libraries/dagster-fivetran/dagster_fivetran_tests/experimental/conftest.py index 2ae8e65742e8c..3d8c5db724e0c 100644 --- a/python_modules/libraries/dagster-fivetran/dagster_fivetran_tests/experimental/conftest.py +++ b/python_modules/libraries/dagster-fivetran/dagster_fivetran_tests/experimental/conftest.py @@ -518,7 +518,7 @@ def all_api_mocks_fixture( @pytest.fixture(name="sync_and_poll") -def poll_and_sync_fixture(): +def sync_and_poll_fixture(): with patch("dagster_fivetran.resources.FivetranClient.sync_and_poll") as mocked_function: # Fivetran output where all sync'd tables match the workspace data that was used to create the assets def expected_fivetran_output = FivetranOutput( diff --git a/python_modules/libraries/dagster-fivetran/dagster_fivetran_tests/experimental/test_resources.py b/python_modules/libraries/dagster-fivetran/dagster_fivetran_tests/experimental/test_resources.py index b4e76ba9e892c..a371a44feec57 100644 --- a/python_modules/libraries/dagster-fivetran/dagster_fivetran_tests/experimental/test_resources.py +++ b/python_modules/libraries/dagster-fivetran/dagster_fivetran_tests/experimental/test_resources.py @@ -1,3 +1,4 @@ +import re from unittest.mock import MagicMock import pytest @@ -142,7 +143,7 @@ def test_basic_resource_request( "resync_long_success", ], ) -def test_sync_and_poll_methods(method, n_polls, succeed_at_end, connector_id): +def test_sync_and_poll_client_methods(method, n_polls, succeed_at_end, connector_id): resource = FivetranWorkspace( account_id=TEST_ACCOUNT_ID, api_key=TEST_API_KEY, api_secret=TEST_API_SECRET ) @@ -212,10 +213,11 @@ def _mock_interaction(): _mock_interaction() -def test_fivetran_materialization( +def test_fivetran_sync_and_poll_materialization_method( connector_id: str, fetch_workspace_data_api_mocks: responses.RequestsMock, sync_and_poll: MagicMock, + capsys: pytest.CaptureFixture, ) -> None: with environ({"FIVETRAN_API_KEY": TEST_API_KEY, "FIVETRAN_API_SECRET": TEST_API_SECRET}): workspace = FivetranWorkspace( @@ -252,6 +254,7 @@ def my_fivetran_assets(context: AssetExecutionContext, fivetran: FivetranWorkspa [my_fivetran_assets], resources={"fivetran": workspace}, ) + assert result.success asset_materializations = [ event @@ -272,3 +275,11 @@ def my_fivetran_assets(context: AssetExecutionContext, fivetran: FivetranWorkspa AssetKey(["schema_name_in_destination_1", "table_name_in_destination_1"]) not in materialized_asset_keys ) + + captured = capsys.readouterr() + assert re.search( + r"dagster - WARNING - (?s:.)+ - An unexpected asset was materialized", captured.err + ) + assert re.search( + r"dagster - WARNING - (?s:.)+ - Assets were not materialized", captured.err + )