@@ -309,7 +309,26 @@ def test_get_price_id_list(self):
309309
310310 prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM2' ], "8" )
311311
312- list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, itemCategory, keyName, prices[categories]' )
312+ list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, capacity, itemCategory, keyName, '
313+ 'prices[categories]' )
314+ self .assertEqual ([price1 ['id' ], price2 ['id' ]], prices )
315+
316+ def test_get_price_id_list_no_core (self ):
317+ category1 = {'categoryCode' : 'cat1' }
318+ price1 = {'id' : 1234 , 'locationGroupId' : None , 'categories' : [{"categoryCode" : "guest_core" }],
319+ 'itemCategory' : [category1 ]}
320+ item1 = {'id' : 1111 , 'keyName' : 'ITEM1' , 'itemCategory' : category1 , 'prices' : [price1 ]}
321+ category2 = {'categoryCode' : 'cat2' }
322+ price2 = {'id' : 5678 , 'locationGroupId' : None , 'categories' : [category2 ]}
323+ item2 = {'id' : 2222 , 'keyName' : 'ITEM2' , 'itemCategory' : category2 , 'prices' : [price2 ]}
324+
325+ with mock .patch .object (self .ordering , 'list_items' ) as list_mock :
326+ list_mock .return_value = [item1 , item2 ]
327+
328+ prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM2' ], None )
329+
330+ list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, capacity, itemCategory, keyName, '
331+ 'prices[categories]' )
313332 self .assertEqual ([price1 ['id' ], price2 ['id' ]], prices )
314333
315334 def test_get_price_id_list_item_not_found (self ):
@@ -323,7 +342,8 @@ def test_get_price_id_list_item_not_found(self):
323342 exc = self .assertRaises (exceptions .SoftLayerError ,
324343 self .ordering .get_price_id_list ,
325344 'PACKAGE_KEYNAME' , ['ITEM2' ], "8" )
326- list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, itemCategory, keyName, prices[categories]' )
345+ list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, capacity, itemCategory, keyName, '
346+ 'prices[categories]' )
327347 self .assertEqual ("Item ITEM2 does not exist for package PACKAGE_KEYNAME" , str (exc ))
328348
329349 def test_get_price_id_list_gpu_items_with_two_categories (self ):
@@ -337,7 +357,8 @@ def test_get_price_id_list_gpu_items_with_two_categories(self):
337357
338358 prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM1' ], "8" )
339359
340- list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, itemCategory, keyName, prices[categories]' )
360+ list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, capacity, itemCategory, keyName, '
361+ 'prices[categories]' )
341362 self .assertEqual ([price2 ['id' ], price1 ['id' ]], prices )
342363
343364 def test_generate_no_complex_type (self ):
@@ -587,7 +608,8 @@ def test_location_group_id_none(self):
587608
588609 prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM2' ], "8" )
589610
590- list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, itemCategory, keyName, prices[categories]' )
611+ list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, capacity, itemCategory, keyName, '
612+ 'prices[categories]' )
591613 self .assertEqual ([price1 ['id' ], price2 ['id' ]], prices )
592614
593615 def test_location_groud_id_empty (self ):
@@ -604,7 +626,8 @@ def test_location_groud_id_empty(self):
604626
605627 prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM2' ], "8" )
606628
607- list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, itemCategory, keyName, prices[categories]' )
629+ list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, capacity, itemCategory, keyName, '
630+ 'prices[categories]' )
608631 self .assertEqual ([price1 ['id' ], price2 ['id' ]], prices )
609632
610633 def test_get_item_price_id_without_capacity_restriction (self ):
@@ -672,3 +695,20 @@ def test_clean_quote_verify(self):
672695 order_container = call .args [0 ]
673696 self .assertNotIn ('testProperty' , order_container )
674697 self .assertNotIn ('reservedCapacityId' , order_container )
698+
699+ def test_get_item_capacity (self ):
700+
701+ items = [{
702+ "capacity" : "1" ,
703+ "id" : 6131 ,
704+ "keyName" : "OS_RHEL_7_X_LAMP_64_BIT" ,
705+ },
706+ {
707+ "capacity" : "1" ,
708+ "id" : 10201 ,
709+ "keyName" : "GUEST_CORE_1_DEDICATED" ,
710+ }]
711+
712+ item_capacity = self .ordering .get_item_capacity (items , ['GUEST_CORE_1_DEDICATED' , 'OS_RHEL_7_X_LAMP_64_BIT' ])
713+
714+ self .assertEqual (1 , int (item_capacity ))
0 commit comments