@@ -125,12 +125,12 @@ def test_generate_signed_url_w_default_method(self):
125125 from gcloud .storage import blob as MUT
126126
127127 BLOB_NAME = 'blob-name'
128- EXPIRATION = '2014-10-16T20:34:37Z '
128+ EXPIRATION = '2014-10-16T20:34:37.000Z '
129129 connection = _Connection ()
130130 bucket = _Bucket (connection )
131131 blob = self ._makeOne (BLOB_NAME , bucket = bucket )
132132 URI = ('http://example.com/abucket/a-blob-name?Signature=DEADBEEF'
133- '&Expiration=2014-10-16T20:34:37Z ' )
133+ '&Expiration=2014-10-16T20:34:37.000Z ' )
134134
135135 SIGNER = _Signer ()
136136 with _Monkey (MUT , generate_signed_url = SIGNER ):
@@ -151,12 +151,12 @@ def test_generate_signed_url_w_slash_in_name(self):
151151 from gcloud .storage import blob as MUT
152152
153153 BLOB_NAME = 'parent/child'
154- EXPIRATION = '2014-10-16T20:34:37Z '
154+ EXPIRATION = '2014-10-16T20:34:37.000Z '
155155 connection = _Connection ()
156156 bucket = _Bucket (connection )
157157 blob = self ._makeOne (BLOB_NAME , bucket = bucket )
158158 URI = ('http://example.com/abucket/a-blob-name?Signature=DEADBEEF'
159- '&Expiration=2014-10-16T20:34:37Z ' )
159+ '&Expiration=2014-10-16T20:34:37.000Z ' )
160160
161161 SIGNER = _Signer ()
162162 with _Monkey (MUT , generate_signed_url = SIGNER ):
@@ -176,12 +176,12 @@ def test_generate_signed_url_w_explicit_method(self):
176176 from gcloud .storage import blob as MUT
177177
178178 BLOB_NAME = 'blob-name'
179- EXPIRATION = '2014-10-16T20:34:37Z '
179+ EXPIRATION = '2014-10-16T20:34:37.000Z '
180180 connection = _Connection ()
181181 bucket = _Bucket (connection )
182182 blob = self ._makeOne (BLOB_NAME , bucket = bucket )
183183 URI = ('http://example.com/abucket/a-blob-name?Signature=DEADBEEF'
184- '&Expiration=2014-10-16T20:34:37Z ' )
184+ '&Expiration=2014-10-16T20:34:37.000Z ' )
185185
186186 SIGNER = _Signer ()
187187 with _Monkey (MUT , generate_signed_url = SIGNER ):
@@ -267,7 +267,6 @@ def test_download_to_file(self):
267267 def test_download_to_filename (self ):
268268 import os
269269 import time
270- import datetime
271270 from six .moves .http_client import OK
272271 from six .moves .http_client import PARTIAL_CONTENT
273272 from tempfile import NamedTemporaryFile
@@ -292,11 +291,7 @@ def test_download_to_filename(self):
292291 with open (f .name , 'rb' ) as g :
293292 wrote = g .read ()
294293 mtime = os .path .getmtime (f .name )
295- updatedTime = time .mktime (
296- datetime .datetime .strptime (
297- blob ._properties ['updated' ],
298- '%Y-%m-%dT%H:%M:%S.%fz' ).timetuple ()
299- )
294+ updatedTime = time .mktime (blob .updated .timetuple ())
300295 self .assertEqual (wrote , b'abcdef' )
301296 self .assertEqual (mtime , updatedTime )
302297
@@ -990,22 +985,36 @@ def test_storage_class(self):
990985 self .assertEqual (blob .storage_class , STORAGE_CLASS )
991986
992987 def test_time_deleted (self ):
988+ import datetime
993989 BLOB_NAME = 'blob-name'
994990 connection = _Connection ()
995991 bucket = _Bucket (connection )
996- TIME_DELETED = '2014-11-05T20:34:37Z'
992+ TIMESTAMP = datetime .datetime (2014 , 11 , 5 , 20 , 34 , 37 )
993+ TIME_DELETED = TIMESTAMP .isoformat () + '.000Z'
997994 properties = {'timeDeleted' : TIME_DELETED }
998995 blob = self ._makeOne (BLOB_NAME , bucket = bucket , properties = properties )
999- self .assertEqual (blob .time_deleted , TIME_DELETED )
996+ self .assertEqual (blob .time_deleted , TIMESTAMP )
997+
998+ def test_time_deleted_unset (self ):
999+ BUCKET = object ()
1000+ blob = self ._makeOne ('blob-name' , bucket = BUCKET )
1001+ self .assertEqual (blob .time_deleted , None )
10001002
10011003 def test_updated (self ):
1004+ import datetime
10021005 BLOB_NAME = 'blob-name'
10031006 connection = _Connection ()
10041007 bucket = _Bucket (connection )
1005- UPDATED = '2014-11-05T20:34:37Z'
1008+ TIMESTAMP = datetime .datetime (2014 , 11 , 5 , 20 , 34 , 37 )
1009+ UPDATED = TIMESTAMP .isoformat () + '.000Z'
10061010 properties = {'updated' : UPDATED }
10071011 blob = self ._makeOne (BLOB_NAME , bucket = bucket , properties = properties )
1008- self .assertEqual (blob .updated , UPDATED )
1012+ self .assertEqual (blob .updated , TIMESTAMP )
1013+
1014+ def test_updated_unset (self ):
1015+ BUCKET = object ()
1016+ blob = self ._makeOne ('blob-name' , bucket = BUCKET )
1017+ self .assertEqual (blob .updated , None )
10091018
10101019
10111020class _Responder (object ):
0 commit comments