def test_scaninstalledkernel(monkeypatch, is_rt, exp_version, stdouts):
    result = []
    old_kver = '0.1.2-3.rt4.5.el7.x86_64' if is_rt else 'kernel-0.1.2-3.el7.x86_64'
    monkeypatch.setattr(api, 'current_actor',
                        CurrentActorMocked(kernel=old_kver))
    monkeypatch.setattr(api, 'produce', result.append)
    monkeypatch.setattr(scankernel, 'run', MockedRun(stdouts))
    scankernel.process()
    assert len(result) == 1 and result[0].version == exp_version
def test_scaninstalledkernel_missing(monkeypatch):
    result = []
    old_kver = '0.1.2-3.rt4.5.el7.x86_64'
    monkeypatch.setattr(api, 'current_actor',
                        CurrentActorMocked(kernel=old_kver))
    monkeypatch.setattr(api, 'current_logger', logger_mocked())
    monkeypatch.setattr(api, 'produce', result.append)
    monkeypatch.setattr(scankernel, 'run', MockedRun({}))
    scankernel.process()
    assert api.current_logger.warnmsg
    assert api.current_logger.errmsg
    assert not result
def test_scaninstalledkernel_missing_rt(monkeypatch):
    result = []
    old_kver = '0.1.2-3.rt4.5.el7.x86_64'
    stdouts = {'kernel': [TARGET_KERNEL], 'kernel-rt': [OLD_RT_KERNEL]}
    monkeypatch.setattr(api, 'current_actor',
                        CurrentActorMocked(kernel=old_kver))
    monkeypatch.setattr(api, 'current_logger', logger_mocked())
    monkeypatch.setattr(api, 'produce', result.append)
    monkeypatch.setattr(scankernel, 'run', MockedRun(stdouts))
    scankernel.process()
    assert api.current_logger.warnmsg
    assert len(result) == 1 and result[0].version == TARGET_KERNEL_VERSION
Example #4
0
 def process(self):
     scankernel.process()
def test_scaninstalledkernel_missing(monkeypatch):
    result = []
    monkeypatch.setattr(stdlib, 'run', mocked_run_without_target_kernel)
    monkeypatch.setattr(api, 'produce', result.append)
    scankernel.process()
    assert not result
def test_scaninstalledkernel(monkeypatch):
    result = []
    monkeypatch.setattr(stdlib, 'run', mocked_run_with_target_kernel)
    monkeypatch.setattr(api, 'produce', result.append)
    scankernel.process()
    assert result and result[0].version == TARGET_KERNEL_VERSION