From cadbe37865f68033215116a0b2ec2ed9660d255a Mon Sep 17 00:00:00 2001 From: Maxime Armstrong Date: Wed, 20 Nov 2024 16:31:30 -0500 Subject: [PATCH] Add resync with parameters; lint --- .../dagster-fivetran/dagster_fivetran/resources.py | 2 +- .../dagster_fivetran_tests/experimental/conftest.py | 6 ++++++ .../dagster_fivetran_tests/experimental/test_resources.py | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/python_modules/libraries/dagster-fivetran/dagster_fivetran/resources.py b/python_modules/libraries/dagster-fivetran/dagster_fivetran/resources.py index f780e1500065f..847c34d79689d 100644 --- a/python_modules/libraries/dagster-fivetran/dagster_fivetran/resources.py +++ b/python_modules/libraries/dagster-fivetran/dagster_fivetran/resources.py @@ -632,7 +632,7 @@ def start_sync(self, connector_id: str) -> None: self._start_sync(request_fn=request_fn, connector_id=connector_id) def start_resync( - self, connector_id: str, resync_parameters: Optional[Mapping[str, Sequence[str]]] = None + self, connector_id: str, resync_parameters: Optional[Mapping[str, Sequence[str]]] = None ) -> None: """Initiates a historical sync of all data for multiple schema tables within a Fivetran connector. 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 664caab3fa02d..267b536263d13 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 @@ -473,4 +473,10 @@ def all_api_mocks_fixture( json=SAMPLE_SUCCESS_MESSAGE, status=200, ) + fetch_workspace_data_api_mocks.add( + method=responses.POST, + url=f"{FIVETRAN_API_BASE}/{FIVETRAN_API_VERSION}/{FIVETRAN_CONNECTOR_ENDPOINT}/{connector_id}/schemas/tables/resync", + json=SAMPLE_SUCCESS_MESSAGE, + status=200, + ) yield fetch_workspace_data_api_mocks 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 bd99c892b9aea..43b1bd744918e 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 @@ -52,4 +52,10 @@ def test_basic_resource_request( all_api_mocks.calls.reset() client.start_resync(connector_id=connector_id, resync_parameters=None) assert len(all_api_mocks.calls) == 3 - assert f"{connector_id}/resync" in all_api_mocks.calls[2].request.url \ No newline at end of file + assert f"{connector_id}/resync" in all_api_mocks.calls[2].request.url + + # resync calls with parameters + all_api_mocks.calls.reset() + client.start_resync(connector_id=connector_id, resync_parameters={"property1": ["string"]}) + assert len(all_api_mocks.calls) == 3 + assert f"{connector_id}/schemas/tables/resync" in all_api_mocks.calls[2].request.url