@@ -243,57 +243,53 @@ def test_place_order(self, create_dict):
243243 self .assert_called_with ('SoftLayer_Product_Order' , 'placeOrder' ,
244244 args = ({'test' : 1 , 'verify' : 1 },))
245245
246- def test_cancel_metal_immediately (self ):
247-
248- result = self .hardware .cancel_metal (6327 , immediate = True )
249-
250- self .assertEqual (result , True )
251- self .assert_called_with ('SoftLayer_Billing_Item' , 'cancelService' ,
252- identifier = 6327 )
253-
254- def test_cancel_metal_on_anniversary (self ):
255-
256- result = self .hardware .cancel_metal (6327 , False )
257-
258- self .assertEqual (result , True )
259- self .assert_called_with ('SoftLayer_Billing_Item' ,
260- 'cancelServiceOnAnniversaryDate' ,
261- identifier = 6327 )
262-
263246 def test_cancel_hardware_without_reason (self ):
264247 mock = self .set_mock ('SoftLayer_Hardware_Server' , 'getObject' )
265- mock .return_value = {'id' : 987 , 'bareMetalInstanceFlag ' : False }
248+ mock .return_value = {'id' : 987 , 'billingItem ' : { 'id' : 1234 } }
266249
267250 result = self .hardware .cancel_hardware (987 )
268251
269- self .assertEqual (result ,
270- fixtures .SoftLayer_Ticket .createCancelServerTicket )
252+ self .assertEqual (result , True )
271253 reasons = self .hardware .get_cancellation_reasons ()
272- args = (987 , reasons ['unneeded' ], '' , True , 'HARDWARE' )
273- self .assert_called_with ('SoftLayer_Ticket' , 'createCancelServerTicket' ,
254+ args = (False , False , reasons ['unneeded' ], '' )
255+ self .assert_called_with ('SoftLayer_Billing_Item' , 'cancelItem' ,
256+ identifier = 1234 ,
274257 args = args )
275258
276259 def test_cancel_hardware_with_reason_and_comment (self ):
277260 mock = self .set_mock ('SoftLayer_Hardware_Server' , 'getObject' )
278- mock .return_value = {'id' : 987 , 'bareMetalInstanceFlag ' : False }
261+ mock .return_value = {'id' : 987 , 'billingItem ' : { 'id' : 1234 } }
279262
280- result = self .hardware .cancel_hardware (987 , 'sales' , 'Test Comment' )
263+ result = self .hardware .cancel_hardware (6327 ,
264+ reason = 'sales' ,
265+ comment = 'Test Comment' )
281266
282- self .assertEqual (result ,
283- fixtures .SoftLayer_Ticket .createCancelServerTicket )
267+ self .assertEqual (result , True )
284268 reasons = self .hardware .get_cancellation_reasons ()
285- args = (987 , reasons ['sales' ], 'Test Comment' , True , 'HARDWARE' )
286- self .assert_called_with ('SoftLayer_Ticket' , 'createCancelServerTicket' ,
269+ args = (False , False , reasons ['sales' ], 'Test Comment' )
270+ self .assert_called_with ('SoftLayer_Billing_Item' , 'cancelItem' ,
271+ identifier = 1234 ,
287272 args = args )
288273
289- def test_cancel_hardware_on_bmc (self ):
274+ def test_cancel_hardware (self ):
290275
291276 result = self .hardware .cancel_hardware (6327 )
292277
293278 self .assertEqual (result , True )
294279 self .assert_called_with ('SoftLayer_Billing_Item' ,
295- 'cancelServiceOnAnniversaryDate' ,
296- identifier = 6327 )
280+ 'cancelItem' ,
281+ identifier = 6327 ,
282+ args = (False , False , 'No longer needed' , '' ))
283+
284+ def test_cancel_hardware_no_billing_item (self ):
285+ mock = self .set_mock ('SoftLayer_Hardware_Server' , 'getObject' )
286+ mock .return_value = {'id' : 987 }
287+
288+ ex = self .assertRaises (SoftLayer .SoftLayerError ,
289+ self .hardware .cancel_hardware ,
290+ 6327 )
291+ self .assertEqual ("No billing item found for hardware" ,
292+ str (ex ))
297293
298294 def test_change_port_speed_public (self ):
299295 self .hardware .change_port_speed (2 , True , 100 )
0 commit comments