Skip to content

Commit

Permalink
Update post review
Browse files Browse the repository at this point in the history
  • Loading branch information
maximearmstrong committed Dec 5, 2024
1 parent a66b2a0 commit 36e9da9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from unittest.mock import MagicMock

import pytest
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -252,6 +254,7 @@ def my_fivetran_assets(context: AssetExecutionContext, fivetran: FivetranWorkspa
[my_fivetran_assets],
resources={"fivetran": workspace},
)

assert result.success
asset_materializations = [
event
Expand All @@ -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
)

0 comments on commit 36e9da9

Please sign in to comment.