Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
maximearmstrong committed Dec 17, 2024
1 parent 863f5ef commit ff5bc7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
TEST_CLIENT_SECRET,
TEST_CONNECTION_ID,
TEST_DESTINATION_ID,
TEST_JOB_ID,
TEST_WORKSPACE_ID,
)

Expand Down Expand Up @@ -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
Expand All @@ -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}")

0 comments on commit ff5bc7d

Please sign in to comment.