@@ -216,15 +216,19 @@ def test_generate_signed_url_w_explicit_method(self):
216216 self .assertEqual (SIGNER ._signed , [(EXPECTED_ARGS , EXPECTED_KWARGS )])
217217
218218 def test_exists_miss (self ):
219+ from six .moves .http_client import NOT_FOUND
219220 NONESUCH = 'nonesuch'
220- connection = _Connection ()
221+ not_found_response = {'status' : NOT_FOUND }
222+ connection = _Connection (not_found_response )
221223 bucket = _Bucket (connection )
222224 blob = self ._makeOne (NONESUCH , bucket = bucket )
223225 self .assertFalse (blob .exists ())
224226
225227 def test_exists_hit (self ):
228+ from six .moves .http_client import OK
226229 BLOB_NAME = 'blob-name'
227- connection = _Connection ()
230+ found_response = {'status' : OK }
231+ connection = _Connection (found_response )
228232 bucket = _Bucket (connection )
229233 blob = self ._makeOne (BLOB_NAME , bucket = bucket )
230234 bucket ._blobs [BLOB_NAME ] = 1
@@ -245,8 +249,10 @@ def test_rename(self):
245249 self .assertTrue (NEW_NAME in bucket ._blobs )
246250
247251 def test_delete (self ):
252+ from six .moves .http_client import NOT_FOUND
248253 BLOB_NAME = 'blob-name'
249- connection = _Connection ()
254+ not_found_response = {'status' : NOT_FOUND }
255+ connection = _Connection (not_found_response )
250256 bucket = _Bucket (connection )
251257 blob = self ._makeOne (BLOB_NAME , bucket = bucket )
252258 bucket ._blobs [BLOB_NAME ] = 1
@@ -1000,7 +1006,12 @@ def __init__(self, *responses):
10001006 self .http = _HTTP (* responses )
10011007
10021008 def api_request (self , ** kw ):
1003- return self ._respond (** kw )
1009+ from six .moves .http_client import NOT_FOUND
1010+ from gcloud .exceptions import NotFound
1011+ result = self ._respond (** kw )
1012+ if result .get ('status' ) == NOT_FOUND :
1013+ raise NotFound (result )
1014+ return result
10041015
10051016 def build_api_url (self , path , query_params = None ,
10061017 api_base_url = API_BASE_URL , upload = False ):
@@ -1031,9 +1042,6 @@ def __init__(self, connection):
10311042 self ._blobs = {}
10321043 self ._deleted = []
10331044
1034- def get_blob (self , blob_name ):
1035- return self ._blobs .get (blob_name )
1036-
10371045 def copy_blob (self , blob , destination_bucket , new_name ):
10381046 destination_bucket ._blobs [new_name ] = self ._blobs [blob .name ]
10391047 return blob .__class__ (None , bucket = destination_bucket ,
0 commit comments