@@ -43,7 +43,9 @@ def test_add_bucket(self):
4343 get_multi_response = munch .Munch ({'name' : self ._tenant_name , 'baseObjectRef' : self ._tenant_base_object_ref })
4444 self ._init_global_admin (get_multi_response = get_multi_response , add_response = add_response )
4545 bucket = AmazonS3 (self ._bucket_name , self ._access_key , self ._secret_key )
46- ret = buckets .Buckets (self ._global_admin ).add (self ._bucket_name , bucket , read_only = True , dedicated_to = self ._tenant_name )
46+ ret = buckets .Buckets (self ._global_admin ).add (
47+ self ._bucket_name , bucket , read_only = True ,
48+ dedicated_to = self ._tenant_name , direct = True )
4749 self ._global_admin .api .get_multi .assert_called_once_with (f'/portals/{ self ._tenant_name } ' , mock .ANY )
4850 expected_include = ['/' + attr for attr in portals .Portals .default + ['baseObjectRef' ]]
4951 actual_include = self ._global_admin .api .get_multi .call_args [0 ][1 ]
@@ -53,7 +55,21 @@ def test_add_bucket(self):
5355 self ._global_admin .api .add .assert_called_once_with ('/locations' , mock .ANY )
5456 expected_param = TestCoreBuckets ._customize_bucket (bucket .to_server_object (), name = self ._bucket_name ,
5557 readOnly = True , dedicated = True ,
56- dedicatedPortal = self ._tenant_base_object_ref , trustAllCertificates = False )
58+ dedicatedPortal = self ._tenant_base_object_ref ,
59+ trustAllCertificates = False , directUpload = True )
60+ actual_param = self ._global_admin .api .add .call_args [0 ][1 ]
61+ self ._assert_equal_objects (actual_param , expected_param )
62+ self .assertEqual (ret , add_response )
63+
64+ def test_add_bucket_default_attrs (self ):
65+ add_response = 'Success'
66+ self ._init_global_admin (add_response = add_response )
67+ bucket = AmazonS3 (self ._bucket_name , self ._access_key , self ._secret_key )
68+ ret = buckets .Buckets (self ._global_admin ).add (self ._bucket_name , bucket )
69+ self ._global_admin .api .add .assert_called_once_with ('/locations' , mock .ANY )
70+ expected_param = TestCoreBuckets ._customize_bucket (bucket .to_server_object (), name = self ._bucket_name ,
71+ readOnly = False , dedicated = False ,
72+ dedicatedPortal = None , trustAllCertificates = False )
5773 actual_param = self ._global_admin .api .add .call_args [0 ][1 ]
5874 self ._assert_equal_objects (actual_param , expected_param )
5975 self .assertEqual (ret , add_response )
@@ -68,6 +84,16 @@ def test_modify_bucket_name_ro_remove_dedication(self):
6884 actual_param = self ._global_admin .api .put .call_args [0 ][1 ]
6985 self ._assert_equal_objects (actual_param , expected_param )
7086
87+ def test_modify_bucket_direct_mode (self ):
88+ get_response = munch .Munch ({'name' : self ._bucket_name , 'directUpload' : False })
89+ self ._init_global_admin (get_response = get_response )
90+ buckets .Buckets (self ._global_admin ).modify (self ._bucket_name , direct = True )
91+ self ._global_admin .api .get .assert_called_once_with (f'/locations/{ self ._bucket_name } ' )
92+ self ._global_admin .api .put .assert_called_once_with (f'/locations/{ self ._bucket_name } ' , mock .ANY )
93+ expected_param = TestCoreBuckets ._get_bucket_param (name = self ._bucket_name , directUpload = True )
94+ actual_param = self ._global_admin .api .put .call_args [0 ][1 ]
95+ self ._assert_equal_objects (actual_param , expected_param )
96+
7197 def test_modify_bucket_value_error (self ):
7298 self ._init_global_admin (get_response = None )
7399 with self .assertRaises (ValueError ):
0 commit comments