MockBucket#

class safir.testing.gcs.MockBucket(spec=None, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs)#

Bases: Mock

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

Parameters:
  • bucket_name (str)

  • expected_expiration (timedelta | None, 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 (Path | None, 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.

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