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

Bases: Mock

Mock version of

Only supports bucket, and the resulting object only supports the blob method. The resulting blob only supports the generate_signed_url method.

  • 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.

  • bucket_name (str | None, default: None) – If set, all requests for a bucket with a name other than the one provided will produce assertion failures.

Methods Summary


Retrieve a mock bucket.

Methods Documentation


Retrieve a mock bucket.


bucket_name (str) – Name of the bucket. If a bucket name was given to the constructor, this name will be checked against that one and a mismatch will cause an assertion failure.


The mock bucket.

Return type: