

@mock.patch('bareon.utils.grub.utils.guess_filename')
def test_guess_kernel(self, mock_guess):
    mock_guess.return_value = 'vmlinuz-version'
    self.assertEqual(gu.guess_kernel('/target'), 'vmlinuz-version')
    mock_guess.assert_called_once_with(path='/target/boot', regexp='^vmlinuz.*')
    mock_guess.reset_mock()
    mock_guess.return_value = 'vmlinuz-version'
    self.assertEqual(gu.guess_kernel('/target', '^vmlinuz-version.*'), 'vmlinuz-version')
    mock_guess.assert_called_once_with(path='/target/boot', regexp='^vmlinuz-version.*')
    mock_guess.reset_mock()
    mock_guess.return_value = None
    self.assertRaises(errors.GrubUtilsError, gu.guess_kernel, '/target')

dataset/ETHPy150Open openstack/bareon/bareon/tests/test_grub_utils.py TestGrubUtils.test_guess_kernel/original