@@ -296,7 +296,8 @@ def test_get_preset_by_key_preset_not_found(self):
296296
297297 def test_get_price_id_list (self ):
298298 category1 = {'categoryCode' : 'cat1' }
299- price1 = {'id' : 1234 , 'locationGroupId' : None , 'itemCategory' : [category1 ]}
299+ price1 = {'id' : 1234 , 'locationGroupId' : None , 'categories' : [{"categoryCode" : "guest_core" }],
300+ 'itemCategory' : [category1 ]}
300301 item1 = {'id' : 1111 , 'keyName' : 'ITEM1' , 'itemCategory' : category1 , 'prices' : [price1 ]}
301302 category2 = {'categoryCode' : 'cat2' }
302303 price2 = {'id' : 5678 , 'locationGroupId' : None , 'categories' : [category2 ]}
@@ -305,7 +306,7 @@ def test_get_price_id_list(self):
305306 with mock .patch .object (self .ordering , 'list_items' ) as list_mock :
306307 list_mock .return_value = [item1 , item2 ]
307308
308- prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM2' ])
309+ prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM2' ], "8" )
309310
310311 list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, itemCategory, keyName, prices[categories]' )
311312 self .assertEqual ([price1 ['id' ], price2 ['id' ]], prices )
@@ -320,7 +321,7 @@ def test_get_price_id_list_item_not_found(self):
320321
321322 exc = self .assertRaises (exceptions .SoftLayerError ,
322323 self .ordering .get_price_id_list ,
323- 'PACKAGE_KEYNAME' , ['ITEM2' ])
324+ 'PACKAGE_KEYNAME' , ['ITEM2' ], "8" )
324325 list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, itemCategory, keyName, prices[categories]' )
325326 self .assertEqual ("Item ITEM2 does not exist for package PACKAGE_KEYNAME" , str (exc ))
326327
@@ -333,7 +334,7 @@ def test_get_price_id_list_gpu_items_with_two_categories(self):
333334 with mock .patch .object (self .ordering , 'list_items' ) as list_mock :
334335 list_mock .return_value = [item1 , item1 ]
335336
336- prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM1' ])
337+ prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM1' ], "8" )
337338
338339 list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, itemCategory, keyName, prices[categories]' )
339340 self .assertEqual ([price2 ['id' ], price1 ['id' ]], prices )
@@ -366,7 +367,7 @@ def test_generate_order_with_preset(self):
366367
367368 mock_pkg .assert_called_once_with (pkg , mask = 'id' )
368369 mock_preset .assert_called_once_with (pkg , preset )
369- mock_get_ids .assert_called_once_with (pkg , items )
370+ mock_get_ids .assert_called_once_with (pkg , items , 8 )
370371 self .assertEqual (expected_order , order )
371372
372373 def test_generate_order (self ):
@@ -388,7 +389,7 @@ def test_generate_order(self):
388389
389390 mock_pkg .assert_called_once_with (pkg , mask = 'id' )
390391 mock_preset .assert_not_called ()
391- mock_get_ids .assert_called_once_with (pkg , items )
392+ mock_get_ids .assert_called_once_with (pkg , items , None )
392393 self .assertEqual (expected_order , order )
393394
394395 def test_verify_order (self ):
@@ -526,7 +527,7 @@ def test_location_group_id_none(self):
526527 with mock .patch .object (self .ordering , 'list_items' ) as list_mock :
527528 list_mock .return_value = [item1 , item2 ]
528529
529- prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM2' ])
530+ prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM2' ], "8" )
530531
531532 list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, itemCategory, keyName, prices[categories]' )
532533 self .assertEqual ([price1 ['id' ], price2 ['id' ]], prices )
@@ -543,7 +544,28 @@ def test_location_groud_id_empty(self):
543544 with mock .patch .object (self .ordering , 'list_items' ) as list_mock :
544545 list_mock .return_value = [item1 , item2 ]
545546
546- prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM2' ])
547+ prices = self .ordering .get_price_id_list ('PACKAGE_KEYNAME' , ['ITEM1' , 'ITEM2' ], "8" )
547548
548549 list_mock .assert_called_once_with ('PACKAGE_KEYNAME' , mask = 'id, itemCategory, keyName, prices[categories]' )
549550 self .assertEqual ([price1 ['id' ], price2 ['id' ]], prices )
551+
552+ def test_get_item_price_id_without_capacity_restriction (self ):
553+ category1 = {'categoryCode' : 'cat1' }
554+ category2 = {'categoryCode' : 'cat2' }
555+ prices = [{'id' : 1234 , 'locationGroupId' : '' , 'categories' : [category1 ]},
556+ {'id' : 2222 , 'locationGroupId' : 509 , 'categories' : [category2 ]}]
557+
558+ price_id = self .ordering .get_item_price_id ("8" , prices )
559+
560+ self .assertEqual (1234 , price_id )
561+
562+ def test_get_item_price_id_with_capacity_restriction (self ):
563+ category1 = {'categoryCode' : 'cat1' }
564+ price1 = [{'id' : 1234 , 'locationGroupId' : '' , "capacityRestrictionMaximum" : "16" ,
565+ "capacityRestrictionMinimum" : "1" , 'categories' : [category1 ]},
566+ {'id' : 2222 , 'locationGroupId' : '' , "capacityRestrictionMaximum" : "56" ,
567+ "capacityRestrictionMinimum" : "36" , 'categories' : [category1 ]}]
568+
569+ price_id = self .ordering .get_item_price_id ("8" , price1 )
570+
571+ self .assertEqual (1234 , price_id )
0 commit comments