MockBucket#

class safir.testing.gcs.MockBucket(bucket_name, expected_expiration=None, path=None)#

Bases: Mock

Mock version of google.cloud.storage.bucket.Bucket.

Parameters:
  • expected_expiration (Optional[timedelta], default: None) – The expiration that should be requested in a call to generate_signed_url on an underlying blob. A non-matching call will produce an assertion failure.

  • path (Optional[Path], default: None) – Root of the file path for blobs, if given. If not given, a simpler mock blob will be used that only supports generate_signed_url.

  • bucket_name (str) –

Methods Summary

blob(blob_name)

Retrieve a mock blob.

Methods Documentation

blob(blob_name)#

Retrieve a mock blob.

Parameters:

blob_name (str) – The name of the blob, used later to form its signed URL.

Returns:

The mock blob.

Return type:

MockBlob