From c5556dc79dd892041cfe44dc0a01d325ce2a88d9 Mon Sep 17 00:00:00 2001 From: lmossman Date: Tue, 19 Sep 2023 12:03:14 -0700 Subject: [PATCH] get tests passing --- .../lib/metadata_service/commands.py | 2 +- .../lib/metadata_service/gcs_upload.py | 1 - .../metadata_service/lib/tests/test_gcs_upload.py | 14 ++++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/airbyte-ci/connectors/metadata_service/lib/metadata_service/commands.py b/airbyte-ci/connectors/metadata_service/lib/metadata_service/commands.py index a7783c695ea9..6a724b1175b0 100644 --- a/airbyte-ci/connectors/metadata_service/lib/metadata_service/commands.py +++ b/airbyte-ci/connectors/metadata_service/lib/metadata_service/commands.py @@ -49,7 +49,7 @@ def validate(metadata_file_path: pathlib.Path, doc_path: pathlib.Path): @click.option("--prerelease", type=click.STRING, required=False, default=None, help="The prerelease tag of the connector.") def upload(metadata_file_path: pathlib.Path, doc_path: pathlib.Path, bucket_name: str, prerelease: str): metadata_file_path = metadata_file_path if not metadata_file_path.is_dir() else metadata_file_path / METADATA_FILE_NAME - validator_opts = ValidatorOptions(doc_path=doc_path, prerelease_tag=prerelease) + validator_opts = ValidatorOptions(doc_path=str(doc_path), prerelease_tag=prerelease) try: upload_info = upload_metadata_to_gcs(bucket_name, metadata_file_path, validator_opts) log_metadata_upload_info(upload_info) diff --git a/airbyte-ci/connectors/metadata_service/lib/metadata_service/gcs_upload.py b/airbyte-ci/connectors/metadata_service/lib/metadata_service/gcs_upload.py index da316658b88b..3bca0c97d4a0 100644 --- a/airbyte-ci/connectors/metadata_service/lib/metadata_service/gcs_upload.py +++ b/airbyte-ci/connectors/metadata_service/lib/metadata_service/gcs_upload.py @@ -109,7 +109,6 @@ def upload_file_if_changed( print(f"Remote {blob_path} md5_hash: {remote_blob_md5_hash}") if local_file_md5_hash != remote_blob_md5_hash: - print(f"~~~~ Uploading {local_file_path} to {blob_path}...") uploaded = _save_blob_to_gcs(remote_blob, local_file_path, disable_cache=disable_cache) return uploaded, remote_blob.id diff --git a/airbyte-ci/connectors/metadata_service/lib/tests/test_gcs_upload.py b/airbyte-ci/connectors/metadata_service/lib/tests/test_gcs_upload.py index 0681058bd46b..d57dce88ee06 100644 --- a/airbyte-ci/connectors/metadata_service/lib/tests/test_gcs_upload.py +++ b/airbyte-ci/connectors/metadata_service/lib/tests/test_gcs_upload.py @@ -65,9 +65,9 @@ def setup_upload_mocks(mocker, version_blob_md5_hash, latest_blob_md5_hash, loca # Mock md5 hash def side_effect_compute_gcs_md5(file_path): - if file_path == metadata_file_path: + if str(file_path) == str(metadata_file_path): return local_file_md5_hash - elif file_path == doc_file_path: + elif str(file_path) == str(doc_file_path): return doc_local_file_md5_hash else: raise ValueError(f"Unexpected path: {file_path}") @@ -165,6 +165,8 @@ def test_upload_metadata_to_gcs_valid_metadata( metadata_file_path = Path(valid_metadata_upload_file) metadata = ConnectorMetadataDefinitionV0.parse_obj(yaml.safe_load(metadata_file_path.read_text())) + doc_file_path = Path(valid_doc_file) + mocks = setup_upload_mocks(mocker, version_blob_md5_hash, latest_blob_md5_hash, local_file_md5_hash, local_doc_file_md5_hash, doc_version_blob_md5_hash, doc_latest_blob_md5_hash, metadata_file_path, valid_doc_file) expected_version_key = f"metadata/{metadata.data.dockerRepository}/{metadata.data.dockerImageTag}/{METADATA_FILE_NAME}" @@ -216,11 +218,11 @@ def test_upload_metadata_to_gcs_valid_metadata( assert upload_info.metadata_uploaded if not doc_version_blob_exists: - mocks["mock_doc_version_blob"].upload_from_filename.assert_called_with(valid_doc_file) + mocks["mock_doc_version_blob"].upload_from_filename.assert_called_with(doc_file_path) assert doc_version_uploaded_file.uploaded if not doc_latest_blob_exists: - mocks["mock_doc_latest_blob"].upload_from_filename.assert_called_with(valid_doc_file) + mocks["mock_doc_latest_blob"].upload_from_filename.assert_called_with(doc_file_path) assert doc_latest_uploaded_file.uploaded if version_blob_md5_hash != local_file_md5_hash: @@ -232,11 +234,11 @@ def test_upload_metadata_to_gcs_valid_metadata( assert upload_info.metadata_uploaded if doc_version_blob_md5_hash != local_doc_file_md5_hash: - mocks["mock_doc_version_blob"].upload_from_filename.assert_called_with(valid_doc_file) + mocks["mock_doc_version_blob"].upload_from_filename.assert_called_with(doc_file_path) assert doc_version_uploaded_file.uploaded if doc_latest_blob_md5_hash != local_doc_file_md5_hash: - mocks["mock_doc_latest_blob"].upload_from_filename.assert_called_with(valid_doc_file) + mocks["mock_doc_latest_blob"].upload_from_filename.assert_called_with(doc_file_path) assert doc_latest_uploaded_file.uploaded # clear the call count