@@ -174,21 +174,41 @@ def test_create_bucket(self):
174174 self .case_buckets_to_delete .append (new_bucket_name )
175175 self .assertEqual (created .name , new_bucket_name )
176176
177+ def test_bucket_create_w_alt_storage_class (self ):
178+ from google .cloud .storage import constants
179+
180+ new_bucket_name = "bucket-w-archive" + unique_resource_id ("-" )
181+ self .assertRaises (
182+ exceptions .NotFound , Config .CLIENT .get_bucket , new_bucket_name
183+ )
184+ bucket = Config .CLIENT .bucket (new_bucket_name )
185+ bucket .storage_class = constants .ARCHIVE_STORAGE_CLASS
186+ retry_429_503 (bucket .create )()
187+ self .case_buckets_to_delete .append (new_bucket_name )
188+ created = Config .CLIENT .get_bucket (new_bucket_name )
189+ self .assertEqual (created .storage_class , constants .ARCHIVE_STORAGE_CLASS )
190+
177191 def test_lifecycle_rules (self ):
192+ from google .cloud .storage import constants
193+
178194 new_bucket_name = "w-lifcycle-rules" + unique_resource_id ("-" )
179195 self .assertRaises (
180196 exceptions .NotFound , Config .CLIENT .get_bucket , new_bucket_name
181197 )
182198 bucket = Config .CLIENT .bucket (new_bucket_name )
183199 bucket .add_lifecycle_delete_rule (age = 42 )
184200 bucket .add_lifecycle_set_storage_class_rule (
185- "COLDLINE" , is_live = False , matches_storage_class = ["NEARLINE" ]
201+ constants .COLDLINE_STORAGE_CLASS ,
202+ is_live = False ,
203+ matches_storage_class = [constants .NEARLINE_STORAGE_CLASS ],
186204 )
187205
188206 expected_rules = [
189207 LifecycleRuleDelete (age = 42 ),
190208 LifecycleRuleSetStorageClass (
191- "COLDLINE" , is_live = False , matches_storage_class = ["NEARLINE" ]
209+ constants .COLDLINE_STORAGE_CLASS ,
210+ is_live = False ,
211+ matches_storage_class = [constants .NEARLINE_STORAGE_CLASS ],
192212 ),
193213 ]
194214
@@ -1235,34 +1255,38 @@ def test_rewrite_rotate_with_user_project(self):
12351255
12361256class TestStorageUpdateStorageClass (TestStorageFiles ):
12371257 def test_update_storage_class_small_file (self ):
1258+ from google .cloud .storage import constants
1259+
12381260 blob = self .bucket .blob ("SmallFile" )
12391261
12401262 file_data = self .FILES ["simple" ]
12411263 blob .upload_from_filename (file_data ["path" ])
12421264 self .case_blobs_to_delete .append (blob )
12431265
1244- blob .update_storage_class ("NEARLINE" )
1266+ blob .update_storage_class (constants . NEARLINE_STORAGE_CLASS )
12451267 blob .reload ()
1246- self .assertEqual (blob .storage_class , "NEARLINE" )
1268+ self .assertEqual (blob .storage_class , constants . NEARLINE_STORAGE_CLASS )
12471269
1248- blob .update_storage_class ("COLDLINE" )
1270+ blob .update_storage_class (constants . COLDLINE_STORAGE_CLASS )
12491271 blob .reload ()
1250- self .assertEqual (blob .storage_class , "COLDLINE" )
1272+ self .assertEqual (blob .storage_class , constants . COLDLINE_STORAGE_CLASS )
12511273
12521274 def test_update_storage_class_large_file (self ):
1275+ from google .cloud .storage import constants
1276+
12531277 blob = self .bucket .blob ("BigFile" )
12541278
12551279 file_data = self .FILES ["big" ]
12561280 blob .upload_from_filename (file_data ["path" ])
12571281 self .case_blobs_to_delete .append (blob )
12581282
1259- blob .update_storage_class ("NEARLINE" )
1283+ blob .update_storage_class (constants . NEARLINE_STORAGE_CLASS )
12601284 blob .reload ()
1261- self .assertEqual (blob .storage_class , "NEARLINE" )
1285+ self .assertEqual (blob .storage_class , constants . NEARLINE_STORAGE_CLASS )
12621286
1263- blob .update_storage_class ("COLDLINE" )
1287+ blob .update_storage_class (constants . COLDLINE_STORAGE_CLASS )
12641288 blob .reload ()
1265- self .assertEqual (blob .storage_class , "COLDLINE" )
1289+ self .assertEqual (blob .storage_class , constants . COLDLINE_STORAGE_CLASS )
12661290
12671291
12681292class TestStorageNotificationCRUD (unittest .TestCase ):
0 commit comments