<s> """<STR_LIT>""" <EOL> import mock <EOL> from oslo_config import cfg <EOL> from oslo_utils import importutils <EOL> from ironic . common import boot_devices <EOL> from ironic . common import exception <EOL> from ironic . conductor import task_manager <EOL> from ironic . drivers . modules . ucs import helper as ucs_helper <EOL> from ironic . drivers . modules . ucs import management as ucs_mgmt <EOL> from ironic . tests . unit . conductor import mgr_utils <EOL> from ironic . tests . unit . db import base as db_base <EOL> from ironic . tests . unit . db import utils as db_utils <EOL> from ironic . tests . unit . objects import utils as obj_utils <EOL> ucs_error = importutils . try_import ( '<STR_LIT>' ) <EOL> INFO_DICT = db_utils . get_test_ucs_info ( ) <EOL> CONF = cfg . CONF <EOL> class UcsManagementTestCase ( db_base . DbTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( UcsManagementTestCase , self ) . setUp ( ) <EOL> mgr_utils . mock_the_extension_manager ( driver = '<STR_LIT>' ) <EOL> self . node = obj_utils . create_test_node ( self . context , <EOL> driver = '<STR_LIT>' , <EOL> driver_info = INFO_DICT ) <EOL> self . interface = ucs_mgmt . UcsManagement ( ) <EOL> self . task = mock . Mock ( ) <EOL> self . task . node = self . node <EOL> def test_get_properties ( self ) : <EOL> expected = ucs_helper . COMMON_PROPERTIES <EOL> self . assertEqual ( expected , self . interface . get_properties ( ) ) <EOL> def test_get_supported_boot_devices ( self ) : <EOL> with task_manager . acquire ( self . context , self . node . uuid ) as task : <EOL> expected = [ boot_devices . PXE , boot_devices . DISK , <EOL> boot_devices . CDROM ] <EOL> self . assertEqual ( <EOL> sorted ( expected ) , <EOL> sorted ( self . interface . get_supported_boot_devices ( task ) ) ) <EOL> @ mock . patch ( '<STR_LIT>' , <EOL> spec_set = True , autospec = True ) <EOL> @ mock . patch ( <EOL> '<STR_LIT>' , <EOL> spec_set = True , autospec = True ) <EOL> def test_get_boot_device ( self , mock_ucs_mgmt , mock_helper ) : <EOL> mock_helper . generate_ucsm_handle . return_value = ( True , mock . Mock ( ) ) <EOL> mock_mgmt = mock_ucs_mgmt . return_value <EOL> mock_mgmt . get_boot_device . return_value = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : False <EOL> } <EOL> with task_manager . acquire ( self . context , self . node . uuid , <EOL> shared = False ) as task : <EOL> expected_device = boot_devices . DISK <EOL> expected_response = { '<STR_LIT>' : expected_device , <EOL> '<STR_LIT>' : False } <EOL> self . assertEqual ( expected_response , <EOL> self . interface . get_boot_device ( task ) ) <EOL> mock_mgmt . get_boot_device . assert_called_once_with ( ) <EOL> @ mock . patch ( '<STR_LIT>' , <EOL> spec_set = True , autospec = True ) <EOL> @ mock . patch ( <EOL> '<STR_LIT>' , <EOL> spec_set = True , autospec = True ) <EOL> def test_get_boot_device_fail ( self , mock_ucs_mgmt , mock_helper ) : <EOL> mock_helper . generate_ucsm_handle . return_value = ( True , mock . Mock ( ) ) <EOL> mock_mgmt = mock_ucs_mgmt . return_value <EOL> side_effect = ucs_error . UcsOperationError ( <EOL> operation = '<STR_LIT>' , <EOL> error = '<STR_LIT>' , <EOL> node = self . node . uuid <EOL> ) <EOL> mock_mgmt . get_boot_device . side_effect = side_effect <EOL> with task_manager . acquire ( self . context , self . node . uuid , <EOL> shared = False ) as task : <EOL> self . assertRaises ( exception . UcsOperationError , <EOL> self . interface . get_boot_device , <EOL> task ) <EOL> mock_mgmt . get_boot_device . assert_called_once_with ( ) <EOL> @ mock . patch ( '<STR_LIT>' , <EOL> spec_set = True , autospec = True ) <EOL> @ mock . patch ( <EOL> '<STR_LIT>' , <EOL> spec_set = True , autospec = True ) <EOL> def test_set_boot_device ( self , mock_mgmt , mock_helper ) : <EOL> mc_mgmt = mock_mgmt . return_value <EOL> mock_helper . generate_ucsm_handle . return_value = ( True , mock . Mock ( ) ) <EOL> with task_manager . acquire ( self . context , self . node . uuid , <EOL> shared = False ) as task : <EOL> self . interface . set_boot_device ( task , boot_devices . CDROM ) <EOL> mc_mgmt . set_boot_device . assert_called_once_with ( '<STR_LIT>' , False ) <EOL> @ mock . patch ( '<STR_LIT>' , <EOL> spec_set = True , autospec = True ) <EOL> @ mock . patch ( <EOL> '<STR_LIT>' , <EOL> spec_set = True , autospec = True ) <EOL> def test_set_boot_device_fail ( self , mock_mgmt , mock_helper ) : <EOL> mc_mgmt = mock_mgmt . return_value <EOL> mock_helper . generate_ucsm_handle . return_value = ( True , mock . Mock ( ) ) <EOL> side_effect = exception . UcsOperationError ( <EOL> operation = '<STR_LIT>' , <EOL> error = '<STR_LIT>' , <EOL> node = self . node . uuid ) <EOL> mc_mgmt . set_boot_device . side_effect = side_effect <EOL> with task_manager . acquire ( self . context , self . node . uuid , <EOL> shared = False ) as task : <EOL> self . assertRaises ( exception . IronicException , <EOL> self . interface . set_boot_device , <EOL> task , boot_devices . PXE ) <EOL> mc_mgmt . set_boot_device . assert_called_once_with ( <EOL> boot_devices . PXE , False ) <EOL> def test_get_sensors_data ( self ) : <EOL> self . assertRaises ( NotImplementedError , <EOL> self . interface . get_sensors_data , self . task ) </s>
