@@ -370,6 +370,36 @@ def test_generate_order_with_preset(self):
370370 mock_get_ids .assert_called_once_with (pkg , items , 8 )
371371 self .assertEqual (expected_order , order )
372372
373+ def test_generate_order_with_quantity (self ):
374+ pkg = 'PACKAGE_KEYNAME'
375+ quantity = 2
376+ items = ['ITEM1' , 'ITEM2' ]
377+ extras = {"hardware" : [{"hostname" : "test01" , "domain" : "example.com" },
378+ {"hostname" : "test02" , "domain" : "example.com" }]}
379+ complex_type = 'My_Type'
380+ expected_order = {'orderContainers' : [
381+ {'complexType' : 'My_Type' ,
382+ 'hardware' : [{'domain' : 'example.com' ,
383+ 'hostname' : 'test01' },
384+ {'domain' : 'example.com' ,
385+ 'hostname' : 'test02' }],
386+ 'location' : 1854895 ,
387+ 'packageId' : 1234 ,
388+ 'prices' : [{'id' : 1111 }, {'id' : 2222 }],
389+ 'quantity' : 2 ,
390+ 'useHourlyPricing' : True }
391+ ]}
392+
393+ mock_pkg , mock_preset , mock_get_ids = self ._patch_for_generate ()
394+
395+ order = self .ordering .generate_order (pkg , 'DALLAS13' , items , complex_type = complex_type , quantity = quantity ,
396+ extras = extras )
397+
398+ mock_pkg .assert_called_once_with (pkg , mask = 'id' )
399+ mock_preset .assert_not_called ()
400+ mock_get_ids .assert_called_once_with (pkg , items , None )
401+ self .assertEqual (expected_order , order )
402+
373403 def test_generate_order (self ):
374404 pkg = 'PACKAGE_KEYNAME'
375405 items = ['ITEM1' , 'ITEM2' ]
@@ -444,6 +474,33 @@ def test_place_order(self):
444474 extras = extras , quantity = quantity )
445475 self .assertEqual (ord_mock .return_value , order )
446476
477+ def test_place_order_with_quantity (self ):
478+ ord_mock = self .set_mock ('SoftLayer_Product_Order' , 'placeOrder' )
479+ ord_mock .return_value = {'id' : 1234 }
480+ pkg = 'PACKAGE_KEYNAME'
481+ location = 'DALLAS13'
482+ items = ['ITEM1' , 'ITEM2' ]
483+ hourly = True
484+ preset_keyname = 'PRESET'
485+ complex_type = 'Complex_Type'
486+ extras = {"hardware" : [{"hostname" : "test01" , "domain" : "example.com" },
487+ {"hostname" : "test02" , "domain" : "example.com" }]}
488+ quantity = 2
489+
490+ with mock .patch .object (self .ordering , 'generate_order' ) as gen_mock :
491+ gen_mock .return_value = {'order' : {}}
492+
493+ order = self .ordering .place_order (pkg , location , items , hourly = hourly ,
494+ preset_keyname = preset_keyname ,
495+ complex_type = complex_type ,
496+ extras = extras , quantity = quantity )
497+
498+ gen_mock .assert_called_once_with (pkg , location , items , hourly = hourly ,
499+ preset_keyname = preset_keyname ,
500+ complex_type = complex_type ,
501+ extras = extras , quantity = quantity )
502+ self .assertEqual (ord_mock .return_value , order )
503+
447504 def test_place_quote (self ):
448505 ord_mock = self .set_mock ('SoftLayer_Product_Order' , 'placeQuote' )
449506 ord_mock .return_value = {'id' : 1234 }
0 commit comments