Ejemplo n.º 1
0
def test_flawless(monkeypatch, msgs, files, modules):
    _msgs = msgs + [InstalledTargetKernelVersion(version=KERNEL_VERSION)]
    run_mocked = RunMocked()
    monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(msgs=_msgs))
    monkeypatch.setattr(targetinitramfsgenerator, 'run', run_mocked)
    # FIXME
    monkeypatch.setattr(targetinitramfsgenerator, 'copy_dracut_modules',
                        lambda dummy: None)

    targetinitramfsgenerator.process()
    assert run_mocked.called

    # check files
    if files:
        assert '--install' in run_mocked.args
        arg = run_mocked.args[run_mocked.args.index('--install') + 1]
        for f in files:
            assert f in arg
    else:
        assert '--install' not in run_mocked.args

    # check modules
    if modules:
        assert '--add' in run_mocked.args
        arg = run_mocked.args[run_mocked.args.index('--add') + 1]
        for m in modules:
            assert m[0] in arg
    else:
        assert '--add' not in run_mocked.args
Ejemplo n.º 2
0
def test_no_includes(monkeypatch):
    run_mocked = RunMocked()
    monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(msgs=[]))
    monkeypatch.setattr(api, 'current_logger', logger_mocked())
    monkeypatch.setattr(targetinitramfsgenerator, 'run', run_mocked)

    targetinitramfsgenerator.process()
    assert NO_INCLUDE_MSG in api.current_logger.dbgmsg
    assert not run_mocked.called
Ejemplo n.º 3
0
def test_no_kernel_version(monkeypatch, msgs):
    run_mocked = RunMocked()
    monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(msgs=msgs))
    monkeypatch.setattr(targetinitramfsgenerator, 'run', run_mocked)
    # FIXME
    monkeypatch.setattr(targetinitramfsgenerator, 'copy_dracut_modules',
                        lambda dummy: None)

    with pytest.raises(StopActorExecutionError) as e:
        targetinitramfsgenerator.process()
    assert 'Cannot get version of the installed RHEL-8 kernel' in str(e)
    assert not run_mocked.called
Ejemplo n.º 4
0
def test_dracut_fail(monkeypatch, msgs):
    run_mocked = RunMocked(raise_err=True)
    monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(msgs=msgs))
    monkeypatch.setattr(
        api, 'current_actor',
        CurrentActorMocked(
            msgs=msgs +
            [InstalledTargetKernelVersion(version=KERNEL_VERSION)]))
    monkeypatch.setattr(targetinitramfsgenerator, 'run', run_mocked)
    # FIXME
    monkeypatch.setattr(targetinitramfsgenerator, 'copy_dracut_modules',
                        lambda dummy: None)

    with pytest.raises(StopActorExecutionError) as e:
        targetinitramfsgenerator.process()
    assert 'Cannot regenerate dracut image' in str(e)
    assert run_mocked.called
Ejemplo n.º 5
0
 def process(self):
     targetinitramfsgenerator.process()