

@mock.patch('bareon.utils.grub.os.path.isfile')
def test_guess_grub_install(self, mock_isfile):
    side_effect_values = {
        '/target/sbin/grub-install': True,
        '/target/sbin/grub2-install': False,
        '/target/usr/sbin/grub-install': False,
        '/target/usr/sbin/grub2-install': False,
    }

    def side_effect(key):
        return side_effect_values[key]
    mock_isfile.side_effect = side_effect
    self.assertEqual(gu.guess_grub_install('/target'), '/sbin/grub-install')
    side_effect_values = {
        '/target/sbin/grub-install': False,
        '/target/sbin/grub2-install': True,
        '/target/usr/sbin/grub-install': False,
        '/target/usr/sbin/grub2-install': False,
    }
    self.assertEqual(gu.guess_grub_install('/target'), '/sbin/grub2-install')
    side_effect_values = {
        '/target/sbin/grub-install': False,
        '/target/sbin/grub2-install': False,
        '/target/usr/sbin/grub-install': True,
        '/target/usr/sbin/grub2-install': False,
    }
    self.assertEqual(gu.guess_grub_install('/target'), '/usr/sbin/grub-install')
    side_effect_values = {
        '/target/sbin/grub-install': False,
        '/target/sbin/grub2-install': False,
        '/target/usr/sbin/grub-install': False,
        '/target/usr/sbin/grub2-install': True,
    }
    self.assertEqual(gu.guess_grub_install('/target'), '/usr/sbin/grub2-install')

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