

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

dataset/ETHPy150Open openstack/bareon/bareon/tests/test_grub_utils.py TestGrubUtils.test_guess_initrd/VarMisuse@53/110 `mock_guess`->`self`