From 48f6c5e9a122857354f5282c34b5a209667c7a08 Mon Sep 17 00:00:00 2001 From: Maxime Armstrong Date: Thu, 12 Dec 2024 19:00:49 -0500 Subject: [PATCH] Add test --- .../libraries/dagster-airbyte/dagster_airbyte/resources.py | 4 +++- .../dagster_airbyte_tests/experimental/conftest.py | 6 ++++++ .../dagster_airbyte_tests/experimental/test_resources.py | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/python_modules/libraries/dagster-airbyte/dagster_airbyte/resources.py b/python_modules/libraries/dagster-airbyte/dagster_airbyte/resources.py index 7daf470948a46..b00fc7c9f625f 100644 --- a/python_modules/libraries/dagster-airbyte/dagster_airbyte/resources.py +++ b/python_modules/libraries/dagster-airbyte/dagster_airbyte/resources.py @@ -1009,7 +1009,9 @@ def get_job_details(self, job_id: int) -> Mapping[str, Any]: ) def cancel_job(self, job_id: int) -> Mapping[str, Any]: - return self.make_request(method="DELETE", endpoint=f"jobs/{job_id}") + return self._make_request( + method="DELETE", endpoint=f"jobs/{job_id}", base_url=self.rest_api_base_url + ) @experimental diff --git a/python_modules/libraries/dagster-airbyte/dagster_airbyte_tests/experimental/conftest.py b/python_modules/libraries/dagster-airbyte/dagster_airbyte_tests/experimental/conftest.py index 1e5f397e76b20..ff8cb9b4a25ae 100644 --- a/python_modules/libraries/dagster-airbyte/dagster_airbyte_tests/experimental/conftest.py +++ b/python_modules/libraries/dagster-airbyte/dagster_airbyte_tests/experimental/conftest.py @@ -233,4 +233,10 @@ def all_api_mocks_fixture( json=SAMPLE_JOB_RESPONSE, status=200, ) + fetch_workspace_data_api_mocks.add( + method=responses.DELETE, + url=f"{AIRBYTE_REST_API_BASE}/{AIRBYTE_REST_API_VERSION}/jobs/{TEST_JOB_ID}", + json=SAMPLE_JOB_RESPONSE, + status=200, + ) yield fetch_workspace_data_api_mocks diff --git a/python_modules/libraries/dagster-airbyte/dagster_airbyte_tests/experimental/test_resources.py b/python_modules/libraries/dagster-airbyte/dagster_airbyte_tests/experimental/test_resources.py index b051434862885..a249a5902f32b 100644 --- a/python_modules/libraries/dagster-airbyte/dagster_airbyte_tests/experimental/test_resources.py +++ b/python_modules/libraries/dagster-airbyte/dagster_airbyte_tests/experimental/test_resources.py @@ -130,8 +130,9 @@ def test_basic_resource_request( client.get_destination_details(destination_id=TEST_DESTINATION_ID) client.start_sync_job(connection_id=TEST_CONNECTION_ID) client.get_job_details(job_id=TEST_JOB_ID) + client.cancel_job(job_id=TEST_JOB_ID) - assert len(all_api_mocks.calls) == 6 + assert len(all_api_mocks.calls) == 7 # The first call is to create the access token api_calls = assert_token_call_and_split_calls(calls=all_api_mocks.calls) # The next calls are actual API calls @@ -142,3 +143,4 @@ def test_basic_resource_request( assert_rest_api_call(call=api_calls[2], endpoint=f"destinations/{TEST_DESTINATION_ID}") assert_rest_api_call(call=api_calls[3], endpoint="jobs", object_id=TEST_CONNECTION_ID) assert_rest_api_call(call=api_calls[4], endpoint=f"jobs/{TEST_JOB_ID}") + assert_rest_api_call(call=api_calls[5], endpoint=f"jobs/{TEST_JOB_ID}")