20
20
from ads .aqua .common .errors import AquaValueError
21
21
from ads .aqua .common .utils import load_config
22
22
from ads .aqua .ui import AquaUIApp
23
- from ads .config import AQUA_CONFIG_FOLDER , AQUA_RESOURCE_LIMIT_NAMES_CONFIG
24
23
25
24
26
25
class TestDataset :
27
26
SERVICE_COMPARTMENT_ID = "ocid1.compartment.oc1..<OCID>"
28
27
USER_COMPARTMENT_ID = "ocid1.compartment.oc1..<USER_COMPARTMENT_OCID>"
29
28
TENANCY_OCID = "ocid1.tenancy.oc1..<OCID>"
30
29
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" ]
32
32
33
33
34
34
class TestAquaUI (unittest .TestCase ):
@@ -333,7 +333,7 @@ def test_list_vcn(self, mock_list_vcns):
333
333
mock_list_vcns .return_value .data = [oci .core .models .Vcn (** vcn ) for vcn in vcns ]
334
334
results = self .app .list_vcn ()
335
335
336
- mock_list_vcns .called_once ()
336
+ mock_list_vcns .assert_called_once ()
337
337
expected_attributes = {
338
338
"cidrBlock" ,
339
339
"cidrBlocks" ,
@@ -370,7 +370,7 @@ def test_list_subnets(self, mock_list_subnets):
370
370
]
371
371
results = self .app .list_subnets (vcn_id = TestDataset .VCN_ID )
372
372
373
- mock_list_subnets .called_once ()
373
+ mock_list_subnets .assert_called_once ()
374
374
expected_attributes = {
375
375
"cidrBlock" ,
376
376
"compartmentId" ,
@@ -409,20 +409,14 @@ def test_get_shape_availability(self, mock_get_resource_availability):
409
409
with open (resource_availability_json , "r" ) as _file :
410
410
resource_availability = json .load (_file )
411
411
412
- artifact_path = AQUA_CONFIG_FOLDER
413
- config = load_config (
414
- artifact_path ,
415
- config_file_name = AQUA_RESOURCE_LIMIT_NAMES_CONFIG ,
416
- )
417
-
418
412
mock_get_resource_availability .return_value .data = (
419
413
oci .limits .models .ResourceAvailability (** resource_availability )
420
414
)
421
415
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 ]
423
418
)
424
419
425
- mock_get_resource_availability .called_once ()
426
420
expected_attributes = {"available_count" }
427
421
self .assertTrue (
428
422
expected_attributes .issuperset (set (result )), "Attributes mismatch"
@@ -432,10 +426,11 @@ def test_get_shape_availability(self, mock_get_resource_availability):
432
426
with pytest .raises (
433
427
AquaValueError ,
434
428
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' ]} ." ,
436
430
):
437
431
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 ]
439
434
)
440
435
441
436
with pytest .raises (
@@ -445,9 +440,10 @@ def test_get_shape_availability(self, mock_get_resource_availability):
445
440
self .app .get_shape_availability (instance_shape = "" )
446
441
447
442
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 ]
449
445
)
450
- assert result == {}
446
+ assert result == {'available_count' : 2 }
451
447
452
448
@parameterized .expand ([True , False ])
453
449
@patch ("ads.common.object_storage_details.ObjectStorageDetails.from_path" )
0 commit comments