@@ -3472,23 +3472,55 @@ def test_make_public_w_timeout_w_retry(self):
34723472 retry = retry ,
34733473 )
34743474
3475- def test_make_private (self ):
3476- BLOB_NAME = "blob-name"
3475+ def test_make_private_w_defaults (self ):
3476+ blob_name = "blob-name"
34773477 no_permissions = []
3478- after = ({ "status" : http_client . OK }, { " acl" : no_permissions })
3479- connection = _Connection ( after )
3480- client = _Client ( connection )
3478+ api_response = { " acl" : no_permissions }
3479+ client = mock . Mock ( spec = [ "_patch_resource" ] )
3480+ client . _patch_resource . return_value = api_response
34813481 bucket = _Bucket (client = client )
3482- blob = self ._make_one (BLOB_NAME , bucket = bucket )
3482+ blob = self ._make_one (blob_name , bucket = bucket )
34833483 blob .acl .loaded = True
3484+
34843485 blob .make_private ()
3486+
34853487 self .assertEqual (list (blob .acl ), no_permissions )
3486- kw = connection ._requested
3487- self .assertEqual (len (kw ), 1 )
3488- self .assertEqual (kw [0 ]["method" ], "PATCH" )
3489- self .assertEqual (kw [0 ]["path" ], "/b/name/o/%s" % BLOB_NAME )
3490- self .assertEqual (kw [0 ]["data" ], {"acl" : no_permissions })
3491- self .assertEqual (kw [0 ]["query_params" ], {"projection" : "full" })
3488+
3489+ expected_patch_data = {"acl" : no_permissions }
3490+ expected_query_params = {"projection" : "full" }
3491+ client ._patch_resource .assert_called_once_with (
3492+ blob .path ,
3493+ expected_patch_data ,
3494+ query_params = expected_query_params ,
3495+ timeout = self ._get_default_timeout (),
3496+ retry = DEFAULT_RETRY ,
3497+ )
3498+
3499+ def test_make_private_w_timeout_w_retry (self ):
3500+ blob_name = "blob-name"
3501+ no_permissions = []
3502+ api_response = {"acl" : no_permissions }
3503+ client = mock .Mock (spec = ["_patch_resource" ])
3504+ client ._patch_resource .return_value = api_response
3505+ bucket = _Bucket (client = client )
3506+ blob = self ._make_one (blob_name , bucket = bucket )
3507+ blob .acl .loaded = True
3508+ timeout = 42
3509+ retry = mock .Mock (spec = [])
3510+
3511+ blob .make_private (timeout = timeout , retry = retry )
3512+
3513+ self .assertEqual (list (blob .acl ), no_permissions )
3514+
3515+ expected_patch_data = {"acl" : no_permissions }
3516+ expected_query_params = {"projection" : "full" }
3517+ client ._patch_resource .assert_called_once_with (
3518+ blob .path ,
3519+ expected_patch_data ,
3520+ query_params = expected_query_params ,
3521+ timeout = timeout ,
3522+ retry = retry ,
3523+ )
34923524
34933525 def test_compose_wo_content_type_set (self ):
34943526 SOURCE_1 = "source-1"
0 commit comments