44
55 :license: MIT, see LICENSE for more details.
66"""
7+ from SoftLayer import exceptions
78from SoftLayer import testing
89
910import json
@@ -28,6 +29,32 @@ def test_volume_cancel(self):
2829 self .assert_called_with ('SoftLayer_Billing_Item' , 'cancelItem' ,
2930 args = (False , True , None ))
3031
32+ def test_volume_set_lun_id_in_range (self ):
33+ lun_mock = self .set_mock ('SoftLayer_Network_Storage' , 'createOrUpdateLunId' )
34+ lun_mock .return_value = dict (volumeId = 1234 , value = '42' )
35+ result = self .run_command ('block volume-set-lun-id 1234 42' .split ())
36+ self .assert_no_fail (result )
37+ self .assertEqual ('Block volume with id 1234 is reporting LUN ID 42\n ' ,
38+ result .output )
39+
40+ def test_volume_set_lun_id_in_range_missing_value (self ):
41+ lun_mock = self .set_mock ('SoftLayer_Network_Storage' , 'createOrUpdateLunId' )
42+ lun_mock .return_value = dict (volumeId = 1234 )
43+ result = self .run_command ('block volume-set-lun-id 1234 42' .split ())
44+ self .assert_no_fail (result )
45+ self .assertEqual ('Failed to confirm the new LUN ID on volume 1234\n ' ,
46+ result .output )
47+
48+ def test_volume_set_lun_id_not_in_range (self ):
49+ value = '-1'
50+ lun_mock = self .set_mock ('SoftLayer_Network_Storage' , 'createOrUpdateLunId' )
51+ lun_mock .side_effect = exceptions .SoftLayerAPIError (
52+ 'SoftLayer_Exception_Network_Storage_Iscsi_InvalidLunId' ,
53+ 'The LUN ID specified is out of the valid range: %s [min: 0 max: 4095]' % (value ))
54+ result = self .run_command ('block volume-set-lun-id 1234 42' .split ())
55+ self .assertIsNotNone (result .exception )
56+ self .assertIn ('The LUN ID specified is out of the valid range' , result .exception .faultString )
57+
3158 def test_volume_detail (self ):
3259 result = self .run_command (['block' , 'volume-detail' , '1234' ])
3360
0 commit comments