def test_upload_to_s3_no_bucket_path(): with pytest.raises( Exception, match= "No upload bucket specified. You can specify one in the config file.", ): upload_to_s3("filename", "prefix", Table("table"))
def test_upload_to_s3_client_error(client): from botocore.exceptions import ClientError client.return_value.upload_file.side_effect = ClientError({"Error": {}}, "operation_name") with pytest.raises(ClientError): upload_to_s3("filename", "prefix", Table("table"))
def test_upload_to_s3_client_error(client): config = app.config.copy() app.config["CSV_TO_HIVE_UPLOAD_S3_BUCKET"] = "bucket" from botocore.exceptions import ClientError client.return_value.upload_file.side_effect = ClientError({"Error": {}}, "operation_name") with app.app_context(): with pytest.raises(ClientError): upload_to_s3("filename", "prefix", Table("table")) app.config = config
def test_upload_to_s3_success(client): config = app.config.copy() app.config["CSV_TO_HIVE_UPLOAD_S3_BUCKET"] = "bucket" client.return_value.upload_file.return_value = True with app.app_context(): location = upload_to_s3("filename", "prefix", Table("table")) assert f"s3a://bucket/prefix/table" == location app.config = config
def test_upload_to_s3_success(client): client.return_value.upload_file.return_value = True location = upload_to_s3("filename", "prefix", Table("table")) assert f"s3a://bucket/prefix/table" == location