2020from ads .aqua .common .errors import AquaValueError
2121from ads .aqua .common .utils import load_config
2222from ads .aqua .ui import AquaUIApp
23- from ads .config import AQUA_CONFIG_FOLDER , AQUA_RESOURCE_LIMIT_NAMES_CONFIG
2423
2524
2625class TestDataset :
2726 SERVICE_COMPARTMENT_ID = "ocid1.compartment.oc1..<OCID>"
2827 USER_COMPARTMENT_ID = "ocid1.compartment.oc1..<USER_COMPARTMENT_OCID>"
2928 TENANCY_OCID = "ocid1.tenancy.oc1..<OCID>"
3029 VCN_ID = "ocid1.vcn.oc1.iad.<OCID>"
31- DEPLOYMENT_SHAPE_NAMES = ["VM.GPU.A10.1" , "BM.GPU4.8" , "VM.Standard.2.16" ]
30+ DEPLOYMENT_SHAPE_NAMES = ["VM.GPU.A10.1" , "BM.GPU4.8" , "VM.GPU.A10.2" ]
31+ LIMIT_NAMES = ["ds-gpu-a10-count" ,"ds-gpu4-count" ,"ds-gpu-a10-count" ]
3232
3333
3434class TestAquaUI (unittest .TestCase ):
@@ -333,7 +333,7 @@ def test_list_vcn(self, mock_list_vcns):
333333 mock_list_vcns .return_value .data = [oci .core .models .Vcn (** vcn ) for vcn in vcns ]
334334 results = self .app .list_vcn ()
335335
336- mock_list_vcns .called_once ()
336+ mock_list_vcns .assert_called_once ()
337337 expected_attributes = {
338338 "cidrBlock" ,
339339 "cidrBlocks" ,
@@ -370,7 +370,7 @@ def test_list_subnets(self, mock_list_subnets):
370370 ]
371371 results = self .app .list_subnets (vcn_id = TestDataset .VCN_ID )
372372
373- mock_list_subnets .called_once ()
373+ mock_list_subnets .assert_called_once ()
374374 expected_attributes = {
375375 "cidrBlock" ,
376376 "compartmentId" ,
@@ -409,20 +409,14 @@ def test_get_shape_availability(self, mock_get_resource_availability):
409409 with open (resource_availability_json , "r" ) as _file :
410410 resource_availability = json .load (_file )
411411
412- artifact_path = AQUA_CONFIG_FOLDER
413- config = load_config (
414- artifact_path ,
415- config_file_name = AQUA_RESOURCE_LIMIT_NAMES_CONFIG ,
416- )
417-
418412 mock_get_resource_availability .return_value .data = (
419413 oci .limits .models .ResourceAvailability (** resource_availability )
420414 )
421415 result = self .app .get_shape_availability (
422- instance_shape = TestDataset .DEPLOYMENT_SHAPE_NAMES [0 ]
416+ instance_shape = TestDataset .DEPLOYMENT_SHAPE_NAMES [0 ],
417+ limit_name = TestDataset .LIMIT_NAMES [0 ]
423418 )
424419
425- mock_get_resource_availability .called_once ()
426420 expected_attributes = {"available_count" }
427421 self .assertTrue (
428422 expected_attributes .issuperset (set (result )), "Attributes mismatch"
@@ -432,10 +426,11 @@ def test_get_shape_availability(self, mock_get_resource_availability):
432426 with pytest .raises (
433427 AquaValueError ,
434428 match = f"Inadequate resource is available to create the { TestDataset .DEPLOYMENT_SHAPE_NAMES [1 ]} resource. The number of available "
435- f"resource associated with the limit name { config [ TestDataset .DEPLOYMENT_SHAPE_NAMES [ 1 ] ]} is { resource_availability ['available' ]} ." ,
429+ f"resource associated with the limit name { TestDataset .LIMIT_NAMES [ 1 ]} is { resource_availability ['available' ]} ." ,
436430 ):
437431 self .app .get_shape_availability (
438- instance_shape = TestDataset .DEPLOYMENT_SHAPE_NAMES [1 ]
432+ instance_shape = TestDataset .DEPLOYMENT_SHAPE_NAMES [1 ],
433+ limit_name = TestDataset .LIMIT_NAMES [1 ]
439434 )
440435
441436 with pytest .raises (
@@ -445,9 +440,10 @@ def test_get_shape_availability(self, mock_get_resource_availability):
445440 self .app .get_shape_availability (instance_shape = "" )
446441
447442 result = self .app .get_shape_availability (
448- instance_shape = TestDataset .DEPLOYMENT_SHAPE_NAMES [2 ]
443+ instance_shape = TestDataset .DEPLOYMENT_SHAPE_NAMES [2 ],
444+ limit_name = TestDataset .LIMIT_NAMES [2 ]
449445 )
450- assert result == {}
446+ assert result == {'available_count' : 2 }
451447
452448 @parameterized .expand ([True , False ])
453449 @patch ("ads.common.object_storage_details.ObjectStorageDetails.from_path" )
0 commit comments