From 5d523340b208f5d8882750ec2a6c270a431b6479 Mon Sep 17 00:00:00 2001 From: Maxime Armstrong Date: Thu, 12 Dec 2024 18:51:33 -0500 Subject: [PATCH] Add test --- .../dagster_airbyte_tests/experimental/conftest.py | 9 ++++++++- .../dagster_airbyte_tests/experimental/test_resources.py | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) 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 67d366c7c5717..1e5f397e76b20 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 @@ -27,6 +27,7 @@ TEST_STREAM_NAME = "test_stream" TEST_SELECTED = True TEST_JSON_SCHEMA = {} +TEST_JOB_ID = "3fa85f64-5717-4562-b3fc-2c963f66afa6" TEST_AIRBYTE_CONNECTION_TABLE_PROPS = AirbyteConnectionTableProps( table_name=f"{TEST_STREAM_PREFIX}{TEST_STREAM_NAME}", @@ -165,7 +166,7 @@ # Taken from Airbyte REST API documentation # https://reference.airbyte.com/reference/getjob SAMPLE_JOB_RESPONSE = { - "jobId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", + "jobId": TEST_JOB_ID, "status": "running", "jobType": "sync", "startTime": "2023-03-25T01:30:50Z", @@ -226,4 +227,10 @@ def all_api_mocks_fixture( json=SAMPLE_JOB_RESPONSE, status=200, ) + fetch_workspace_data_api_mocks.add( + method=responses.GET, + 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 144bad731c115..b051434862885 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 @@ -18,6 +18,7 @@ TEST_CLIENT_SECRET, TEST_CONNECTION_ID, TEST_DESTINATION_ID, + TEST_JOB_ID, TEST_WORKSPACE_ID, ) @@ -128,8 +129,9 @@ def test_basic_resource_request( client.get_connection_details(connection_id=TEST_CONNECTION_ID) 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) - assert len(all_api_mocks.calls) == 5 + assert len(all_api_mocks.calls) == 6 # 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 @@ -139,3 +141,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}")