@@ -65,15 +65,15 @@ def test_updated_lb_health(self):
6565 def test_get_lbaas_uuid_id_uuid (self ):
6666 uuid = '1a1aa111-4474-4e16-9f02-4de959229b85'
6767 my_id = 1111111
68- lb_uuid ,lb_id = self .lb_mgr .get_lbaas_uuid_id (uuid )
68+ lb_uuid , lb_id = self .lb_mgr .get_lbaas_uuid_id (uuid )
6969 self .assert_called_with ('SoftLayer_Network_LBaaS_LoadBalancer' , 'getLoadBalancer' , args = (uuid ,))
7070 self .assertEqual (lb_uuid , uuid )
7171 self .assertEqual (lb_id , my_id )
7272
7373 def test_get_lbaas_uuid_id_id (self ):
7474 uuid = '1a1aa111-4474-4e16-9f02-4de959229b85'
7575 my_id = 1111111
76- lb_uuid ,lb_id = self .lb_mgr .get_lbaas_uuid_id (my_id )
76+ lb_uuid , lb_id = self .lb_mgr .get_lbaas_uuid_id (my_id )
7777 self .assert_called_with ('SoftLayer_Network_LBaaS_LoadBalancer' , 'getObject' , identifier = my_id )
7878 self .assertEqual (lb_uuid , uuid )
7979 self .assertEqual (lb_id , my_id )
@@ -121,16 +121,49 @@ def test_remove_lb_listener(self):
121121 self .assert_called_with ('SoftLayer_Network_LBaaS_Listener' , 'deleteLoadBalancerProtocols' ,
122122 args = (uuid , [listener ]))
123123
124- def order_lbaas (self ):
124+ def test_order_lbaas (self ):
125125 datacenter = 'tes01'
126126 name = 'test-lb'
127127 desc = 'my lb'
128128 protocols = {'frontendPort' : 80 , 'frontendProtocol' : 'HTTP' }
129129 subnet_id = 12345
130130 public = True
131131 verify = False
132+ package = [
133+ {
134+ 'id' : 805 ,
135+ 'keyNake' : 'LBAAS' ,
136+ 'itemPrices' : [
137+ {
138+ 'id' : 1 ,
139+ 'name' : 'A test price' ,
140+ 'locationGroupId' : None
141+ },
142+ {
143+ 'id' : 2 ,
144+ 'name' : 'A test price 2' ,
145+ 'locationGroupId' : 123
146+ }
147+ ]
148+ }
149+ ]
150+ mock = self .set_mock ('SoftLayer_Product_Package' , 'getAllObjects' )
151+ mock .return_value = package
152+ order_data = {
153+ 'complexType' : 'SoftLayer_Container_Product_Order_Network_LoadBalancer_AsAService' ,
154+ 'name' : name ,
155+ 'description' : desc ,
156+ 'location' : datacenter ,
157+ 'packageId' : package [0 ]['id' ],
158+ 'useHourlyPricing' : True , # Required since LBaaS is an hourly service
159+ 'prices' : [{'id' : package [0 ]['itemPrices' ][0 ]['id' ]}],
160+ 'protocolConfigurations' : protocols ,
161+ 'subnets' : [{'id' : subnet_id }],
162+ 'isPublic' : public
163+ }
132164 self .lb_mgr .order_lbaas (datacenter , name , desc , protocols , subnet_id , public , verify )
133- self .assert_called_with ('SoftLayer_Product_Order' , 'placeOrder' )
165+ self .assert_called_with ('SoftLayer_Product_Order' , 'placeOrder' , args = (order_data ,))
166+ self .assert_called_with ('SoftLayer_Product_Package' , 'getAllObjects' )
134167 verify = True
135168 self .lb_mgr .order_lbaas (datacenter , name , desc , protocols , subnet_id , public , verify )
136169 self .assert_called_with ('SoftLayer_Product_Order' , 'verifyOrder' )
@@ -143,4 +176,3 @@ def test_cancel_lbaas(self):
143176 uuid = 'aa-bb-cc'
144177 self .lb_mgr .cancel_lbaas (uuid )
145178 self .assert_called_with ('SoftLayer_Network_LBaaS_LoadBalancer' , 'cancelLoadBalancer' , args = (uuid ,))
146-
0 commit comments