Skip to content

Commit 73c285c

Browse files
committed
Adding test that covers explicit content type argument
1 parent bae74e8 commit 73c285c

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

gcloud/storage/test_blob.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,38 @@ def _basic_generate_signed_url_helper(self, credentials=None):
156156
def test_generate_signed_url_w_default_method(self):
157157
self._basic_generate_signed_url_helper()
158158

159+
def test_generate_signed_url_w_content_type(self):
160+
from gcloud._testing import _Monkey
161+
from gcloud.storage import blob as MUT
162+
163+
BLOB_NAME = 'parent/child'
164+
EXPIRATION = '2014-10-16T20:34:37.000Z'
165+
connection = _Connection()
166+
client = _Client(connection)
167+
bucket = _Bucket(client)
168+
blob = self._makeOne(BLOB_NAME, bucket=bucket)
169+
URI = ('http://example.com/abucket/a-blob-name?Signature=DEADBEEF'
170+
'&Expiration=2014-10-16T20:34:37.000Z')
171+
172+
SIGNER = _Signer()
173+
with _Monkey(MUT, generate_signed_url=SIGNER):
174+
signed_url = blob.generate_signed_url(EXPIRATION,
175+
content_type="text/html")
176+
self.assertEqual(signed_url, URI)
177+
178+
EXPECTED_ARGS = (_Connection.credentials,)
179+
EXPECTED_KWARGS = {
180+
'api_access_endpoint': 'https://storage.googleapis.com',
181+
'expiration': EXPIRATION,
182+
'method': 'GET',
183+
'resource': '/name/parent%2Fchild',
184+
'content_type': "text/html",
185+
'response_type': None,
186+
'response_disposition': None,
187+
'generation': None,
188+
}
189+
self.assertEqual(SIGNER._signed, [(EXPECTED_ARGS, EXPECTED_KWARGS)])
190+
159191
def test_generate_signed_url_w_credentials(self):
160192
credentials = object()
161193
self._basic_generate_signed_url_helper(credentials=credentials)

0 commit comments

Comments
 (0)