def test_get_cmd_line_grub_cfg_not_present(
     self, mock_os_path_exists, mock_logger_setup
 ):
     mock_os_path_exists.return_value = False
     with self._caplog.at_level(logging.ERROR):
         with raises(DistMigrationKernelRebootException):
             _get_cmdline(Defaults.get_grub_config_file())
예제 #2
0
 def test_get_cmd_line_grub_cfg_not_present(
     self, mock_os_path_exists, mock_info, mock_error
 ):
     mock_os_path_exists.return_value = False
     with raises(DistMigrationKernelRebootException):
         _get_cmdline(Defaults.get_grub_config_file())
         assert mock_info.called
         assert mock_error.called
예제 #3
0
 def test_get_cmd_line_linuxefi(self, mock_path_exists, mock_logger_setup):
     mock_path_exists.return_value = True
     with open('../data/fake_grub_linuxefi.cfg') as fake_grub:
         fake_grub_data = fake_grub.read()
     with patch('builtins.open', create=True) as mock_open:
         mock_open.return_value = MagicMock(spec=io.IOBase)
         file_handle = mock_open.return_value.__enter__.return_value
         file_handle.read.return_value = fake_grub_data
         grub_cmd_content = \
             'root=UUID=ec7aaf92-30ea-4c07-991a-4700177ce1b8 ' + \
             'splash root=UUID=ec7aaf92-30ea-4c07-991a-4700177ce1b8 rw'
         result = _get_cmdline(
             os.path.basename(Defaults.get_target_kernel()))
         mock_open.assert_called_once_with(
             '/system-root/boot/grub2/grub.cfg')
         assert result == grub_cmd_content