@@ -210,15 +210,15 @@ def test_get_latest_cost_export_for_path(self):
210
210
type(mock_blob ).name = name_attr # kludge to set name attribute on Mock
211
211
212
212
svc = self .get_mock_client (blob_list = [mock_blob ])
213
- cost_export = svc .get_latest_cost_export_for_path (report_path , self .container_name , ".csv.gz" )
213
+ cost_export = svc .get_latest_cost_export_for_path (report_path , self .container_name )
214
214
self .assertEqual (cost_export .last_modified .date (), self .current_date_time .date ())
215
215
216
216
def test_get_latest_cost_export_for_path_missing (self ):
217
217
"""Test that the no cost export is returned for a missing path."""
218
218
report_path = FAKE .word ()
219
219
svc = self .get_mock_client ()
220
220
with self .assertRaises (AzureCostReportNotFound ):
221
- svc .get_latest_cost_export_for_path (report_path , self .container_name , ".csv.gz" )
221
+ svc .get_latest_cost_export_for_path (report_path , self .container_name )
222
222
223
223
def test_describe_cost_management_exports (self ):
224
224
"""Test that cost management exports are returned for the account."""
@@ -259,7 +259,7 @@ def test_get_latest_cost_export_http_error(self):
259
259
svc = self .get_mock_client (blob_list = [mock_blob ])
260
260
svc ._cloud_storage_account .get_container_client .side_effect = throw_azure_http_error
261
261
with self .assertRaises (AzureCostReportNotFound ):
262
- svc .get_latest_cost_export_for_path (report_path , self .container_name , ".csv.gz" )
262
+ svc .get_latest_cost_export_for_path (report_path , self .container_name )
263
263
264
264
def test_get_latest_cost_export_http_error_403 (self ):
265
265
"""Test that the latest cost export catches the error for Azure HttpError 403."""
@@ -272,7 +272,7 @@ def test_get_latest_cost_export_http_error_403(self):
272
272
svc = self .get_mock_client (blob_list = [mock_blob ])
273
273
svc ._cloud_storage_account .get_container_client .side_effect = throw_azure_http_error_403
274
274
with self .assertRaises (AzureCostReportNotFound ):
275
- svc .get_latest_cost_export_for_path (report_path , self .container_name , ".csv.gz" )
275
+ svc .get_latest_cost_export_for_path (report_path , self .container_name )
276
276
277
277
def test_get_latest_cost_export_no_container (self ):
278
278
"""Test that the latest cost export catches the error for no container."""
@@ -285,7 +285,7 @@ def test_get_latest_cost_export_no_container(self):
285
285
286
286
svc = self .get_mock_client (blob_list = [mock_blob ])
287
287
with self .assertRaises (AzureCostReportNotFound ):
288
- svc .get_latest_cost_export_for_path (report_path , container_name , ".csv.gz" )
288
+ svc .get_latest_cost_export_for_path (report_path , container_name )
289
289
290
290
def test_get_latest_manifest_for_path (self ):
291
291
"""Given a list of blobs with multiple manifests, ensure the latest one is returned"""
@@ -422,9 +422,7 @@ def test_get_latest_cost_export_for_path_exception(self, mock_factory):
422
422
service = AzureService (
423
423
self .tenant_id , self .client_id , self .client_secret , self .resource_group_name , self .storage_account_name
424
424
)
425
- service .get_latest_cost_export_for_path (
426
- report_path = FAKE .word (), container_name = FAKE .word (), compression = ".csv.gz"
427
- )
425
+ service .get_latest_cost_export_for_path (report_path = FAKE .word (), container_name = FAKE .word ())
428
426
429
427
def test_describe_cost_management_exports_with_scope_and_name (self ):
430
428
"""Test that cost management exports using scope and name are returned for the account."""
@@ -465,7 +463,6 @@ def test_get_latest_blob(self):
465
463
"""
466
464
report_path = "/container/report/path"
467
465
blobs = (
468
- FakeBlob (f"{ report_path } /_manifest.json" , datetime (2022 , 12 , 18 )),
469
466
FakeBlob (f"{ report_path } /file01.csv" , datetime (2022 , 12 , 16 )),
470
467
FakeBlob (f"{ report_path } /file02.csv" , datetime (2022 , 12 , 15 )),
471
468
FakeBlob ("some/other/path/file01.csv" , datetime (2022 , 12 , 1 )),
@@ -487,7 +484,7 @@ def test_get_latest_cost_export_missing_container(self):
487
484
svc = self .get_mock_client (blob_list = [mock_blob ])
488
485
svc ._cloud_storage_account .get_container_client .side_effect = ResourceNotFoundError ("Oops!" )
489
486
with self .assertRaises (AzureCostReportNotFound ):
490
- svc .get_latest_cost_export_for_path (report_path , self .container_name , ".csv.gz" )
487
+ svc .get_latest_cost_export_for_path (report_path , self .container_name )
491
488
492
489
@patch ("masu.external.downloader.azure.azure_service.AzureClientFactory" )
493
490
def test_azure_service_missing_credentials (self , mock_factory ):
@@ -507,27 +504,6 @@ def test_azure_service_missing_credentials(self, mock_factory):
507
504
508
505
self .assertIn ("Azure Service credentials are not configured." , str (context .exception ))
509
506
510
- @patch ("masu.external.downloader.azure.azure_service.AzureClientFactory" )
511
- @patch .object (AzureService , "_get_latest_blob_for_path" )
512
- def test_get_latest_cost_export_for_path_invalid_compression (self , mock_get_latest_blob , mock_factory ):
513
- """Test when an invalid compression type is provided and ValueError is raised."""
514
- mock_get_latest_blob .return_value = None
515
- mock_factory .return_value .credentials = Mock ()
516
-
517
- service = AzureService (
518
- tenant_id = "fake_tenant_id" ,
519
- client_id = "fake_client_id" ,
520
- client_secret = "fake_client_secret" ,
521
- resource_group_name = "fake_resource_group" ,
522
- storage_account_name = "fake_storage_account" ,
523
- subscription_id = "fake_subscription_id" ,
524
- )
525
-
526
- with self .assertRaises (ValueError ) as context :
527
- service .get_latest_cost_export_for_path ("fake_report_path" , "fake_container_name" , "invalid_compression" )
528
-
529
- self .assertIn ("Invalid compression type" , str (context .exception ))
530
-
531
507
@patch ("masu.external.downloader.azure.azure_service.AzureService._list_blobs" )
532
508
@patch ("masu.external.downloader.azure.azure_service.AzureClientFactory" )
533
509
@patch ("masu.external.downloader.azure.azure_service.NamedTemporaryFile" )
@@ -627,24 +603,6 @@ def test_download_file_raises_exception(self, mock_tempfile, mock_client_factory
627
603
628
604
self .assertIn ("Failed to download cost export" , str (context .exception ))
629
605
630
- @patch ("masu.external.downloader.azure.azure_service.AzureClientFactory" )
631
- def test_invalid_compression_type (self , mock_factory ):
632
- """Test that an invalid compression type raises an exception."""
633
-
634
- service = AzureService (
635
- tenant_id = "fake_tenant_id" ,
636
- client_id = "fake_client_id" ,
637
- client_secret = "fake_client_secret" ,
638
- resource_group_name = "fake_resource_group" ,
639
- storage_account_name = "fake_storage_account" ,
640
- subscription_id = "fake_subscription_id" ,
641
- )
642
-
643
- with self .assertRaises (ValueError ) as context :
644
- service .get_latest_cost_export_for_path ("fake_report_path" , "fake_container_name" , "invalid_compression" )
645
-
646
- self .assertIn ("Invalid compression type" , str (context .exception ))
647
-
648
606
@patch ("masu.external.downloader.azure.azure_service.AzureService._list_blobs" )
649
607
@patch ("masu.external.downloader.azure.azure_service.AzureClientFactory" )
650
608
@patch ("masu.external.downloader.azure.azure_service.NamedTemporaryFile" )
0 commit comments