vikit.common.file_tools_test ============================ .. py:module:: vikit.common.file_tools_test .. autoapi-nested-parse:: 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 -------- .. list-table:: Function :header-rows: 0 :widths: auto :class: summarytable * - :py:obj:`test_copy_file_from_gcs `\ () - Test copying file from GCS * - :py:obj:`test_copy_file_from_gcs_invalid_url `\ () - Test that copy_file_from_gcs raises ValueError with empty URL * - :py:obj:`test_download_from_google_cloud_storage `\ (url) - Test the download of a file stored on a Google cloud storage bucket. * - :py:obj:`test_download_or_copy_file__empty_url `\ () - \- * - :py:obj:`test_download_or_copy_file__unsupported_path `\ () - \- * - :py:obj:`test_download_with_local_file `\ () - \- * - :py:obj:`test_gcs_file_exists__failure `\ () - \- * - :py:obj:`test_gcs_file_exists__invalid_bucket `\ () - \- * - :py:obj:`test_gcs_file_exists__invalid_object `\ () - Test the gcs_file_exists function * - :py:obj:`test_gcs_file_exists__success `\ () - \- * - :py:obj:`test_get_public_uri_from_gcs_path `\ (gcs_path, expected_public_uri) - \- * - :py:obj:`test_parse_gcs_url `\ (url, expected_result) - \- * - :py:obj:`test_upload_to_bucket `\ (mock_storage_client) - \- * - :py:obj:`test_upload_to_bucket_invalid_parameters `\ (source_file_name, destination_folder_name, destination_file_name) - \- * - :py:obj:`test_url_exists__success `\ () - \- .. list-table:: Attributes :header-rows: 0 :widths: auto :class: summarytable * - :py:obj:`BUCKET_NAME ` - \- * - :py:obj:`DESTINATION_FILE_NAME ` - \- * - :py:obj:`DESTINATION_FOLDER_NAME ` - \- * - :py:obj:`SOURCE_FILE_NAME ` - \- Functions --------- .. py:function:: test_copy_file_from_gcs() Test copying file from GCS .. py:function:: test_copy_file_from_gcs_invalid_url() Test that copy_file_from_gcs raises ValueError with empty URL .. py:function:: test_download_from_google_cloud_storage(url) :async: 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) .. py:function:: test_download_or_copy_file__empty_url() :async: .. py:function:: test_download_or_copy_file__unsupported_path() :async: .. py:function:: test_download_with_local_file() :async: .. py:function:: test_gcs_file_exists__failure() .. py:function:: test_gcs_file_exists__invalid_bucket() .. py:function:: test_gcs_file_exists__invalid_object() Test the gcs_file_exists function .. py:function:: test_gcs_file_exists__success() .. py:function:: test_get_public_uri_from_gcs_path(gcs_path, expected_public_uri) .. py:function:: test_parse_gcs_url(url, expected_result) .. py:function:: test_upload_to_bucket(mock_storage_client) :async: .. py:function:: test_upload_to_bucket_invalid_parameters(source_file_name, destination_folder_name, destination_file_name) :async: .. py:function:: test_url_exists__success() Attributes ---------- .. py:data:: BUCKET_NAME :value: 'test-bucket' .. py:data:: DESTINATION_FILE_NAME :value: 'destination-file.txt' .. py:data:: DESTINATION_FOLDER_NAME :value: 'destination-folder' .. py:data:: SOURCE_FILE_NAME :value: 'source-file.txt'