MockBlob#

class safir.testing.gcs.MockBlob(name, expected_expiration=None)#

Bases: Mock

Mock version of google.cloud.storage.blob.Blob.

Parameters:
  • name (str) – Name of the blob.

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

Methods Summary

generate_signed_url(*, version, expiration, ...)

Generate a mock signed URL for testing.

Methods Documentation

generate_signed_url(*, version, expiration, method, response_type=None, credentials=None)#

Generate a mock signed URL for testing.

Parameters:
  • version (str) – Must be v4.

  • expiration (timedelta) – Must match the expected_expiration argument to the constructor if it was given.

  • method (str) – Must be GET.

  • response_type (Optional[str], default: None) – May be anything and is ignored.

  • credentials (Optional[Any], default: None) – May be anything and is ignored.

Returns:

Always returns https://example.com/name where name is the name of the blob.

Return type:

str