vikit.common.file_tools_test

Test the file tools functions.

Includes tests of files required to be stored on public http url, non public accessible cloud storage, and local files.

Overview

Function

test_copy_file_from_gcs()

Test copying file from GCS

test_copy_file_from_gcs_invalid_url()

Test that copy_file_from_gcs raises ValueError with empty URL

test_download_from_google_cloud_storage(url)

Test the download of a file stored on a Google cloud storage bucket.

test_download_or_copy_file__empty_url()

-

test_download_or_copy_file__unsupported_path()

-

test_download_with_local_file()

-

test_gcs_file_exists__failure()

-

test_gcs_file_exists__invalid_bucket()

-

test_gcs_file_exists__invalid_object()

Test the gcs_file_exists function

test_gcs_file_exists__success()

-

test_get_public_uri_from_gcs_path(gcs_path, expected_public_uri)

-

test_parse_gcs_url(url, expected_result)

-

test_upload_to_bucket(mock_storage_client)

-

test_upload_to_bucket_invalid_parameters(source_file_name, destination_folder_name, destination_file_name)

-

test_url_exists__success()

-

Functions

vikit.common.file_tools_test.test_copy_file_from_gcs()

Test copying file from GCS

vikit.common.file_tools_test.test_copy_file_from_gcs_invalid_url()

Test that copy_file_from_gcs raises ValueError with empty URL

async vikit.common.file_tools_test.test_download_from_google_cloud_storage(url)

Test the download of a file stored on a Google cloud storage bucket.

Prerequisites:
Will need an access token to Google Cloud Storage,
  • either you use gcloud auth application-default login and connect with

your identity before running the tests - or you ensure a service account key file with low privileges (i.e. just read the test bucket files) is available - You could also call the secret manager to get the SA key from it using your own credentials (better for traceability but overkill here)

async vikit.common.file_tools_test.test_download_or_copy_file__empty_url()
async vikit.common.file_tools_test.test_download_or_copy_file__unsupported_path()
async vikit.common.file_tools_test.test_download_with_local_file()
vikit.common.file_tools_test.test_gcs_file_exists__failure()
vikit.common.file_tools_test.test_gcs_file_exists__invalid_bucket()
vikit.common.file_tools_test.test_gcs_file_exists__invalid_object()

Test the gcs_file_exists function

vikit.common.file_tools_test.test_gcs_file_exists__success()
vikit.common.file_tools_test.test_get_public_uri_from_gcs_path(gcs_path, expected_public_uri)
vikit.common.file_tools_test.test_parse_gcs_url(url, expected_result)
async vikit.common.file_tools_test.test_upload_to_bucket(mock_storage_client)
async vikit.common.file_tools_test.test_upload_to_bucket_invalid_parameters(source_file_name, destination_folder_name, destination_file_name)
vikit.common.file_tools_test.test_url_exists__success()

Attributes

vikit.common.file_tools_test.BUCKET_NAME = 'test-bucket'
vikit.common.file_tools_test.DESTINATION_FILE_NAME = 'destination-file.txt'
vikit.common.file_tools_test.DESTINATION_FOLDER_NAME = 'destination-folder'
vikit.common.file_tools_test.SOURCE_FILE_NAME = 'source-file.txt'