def test_gcs_writes_binary_string(self, google_client): blob = MagicMock() google_client.return_value.bucket = MagicMock(return_value=MagicMock( blob=MagicMock(return_value=blob))) result = GCSResult(bucket="foo", filepath_template="nothing/here.txt") result.value = None new_result = result.format() new_result.write() assert blob.upload_from_string.called assert isinstance(blob.upload_from_string.call_args[0][0], str)
def test_gcs_writes_to_blob_using_rendered_template_name( self, google_client): bucket = MagicMock() google_client.return_value.bucket = MagicMock(return_value=bucket) result = GCSResult(bucket="foo", filepath_template="{thing}/here.txt") result.value = "so-much-data" new_result = result.format(thing=42) new_result.write() assert bucket.blob.called assert bucket.blob.call_args[0][0] == "42/here.txt"