def test_non_ibmz_arch(monkeypatch):
    monkeypatch.setattr(api, 'current_actor',
                        CurrentActorMocked(architecture.ARCH_X86_64))
    monkeypatch.setattr(reporting, "create_report",
                        testutils.create_report_mocked())
    cpu.process()
    assert not reporting.create_report.called
def test_ibmz_arch_missing_cpuinfo(monkeypatch):
    monkeypatch.setattr(api, 'current_actor',
                        CurrentActorMocked(architecture.ARCH_S390X))
    monkeypatch.setattr(reporting, "create_report",
                        testutils.create_report_mocked())
    monkeypatch.setattr(api, 'consume', lambda x: iter([]))
    with pytest.raises(StopActorExecutionError):
        cpu.process()
    assert not reporting.create_report.called
def test_ibmz_cpu_is_empty(monkeypatch, caplog):
    monkeypatch.setattr(api, 'current_actor',
                        CurrentActorMocked(architecture.ARCH_S390X))
    monkeypatch.setattr(reporting, "create_report",
                        testutils.create_report_mocked())
    monkeypatch.setattr(api, 'consume',
                        lambda x: iter([CPUInfo(machine_type=None)]))
    with caplog.at_level(logging.DEBUG):
        cpu.process()
    assert 'The machine (CPU) type is empty.' in caplog.text
def test_ibmz_cpu_supported(monkeypatch):
    monkeypatch.setattr(api, 'current_actor',
                        CurrentActorMocked(architecture.ARCH_S390X))
    monkeypatch.setattr(reporting, "create_report",
                        testutils.create_report_mocked())
    for sup_arch in cpu.SUPPORTED_MACHINE_TYPES:
        monkeypatch.setattr(api, 'consume',
                            lambda x: iter([CPUInfo(machine_type=sup_arch)]))
        cpu.process()
        assert not reporting.create_report.called
def test_ibmz_cpu_unsupported(monkeypatch):
    title_msg = 'The processor is not supported by the target system.'
    monkeypatch.setattr(api, 'current_actor',
                        CurrentActorMocked(architecture.ARCH_S390X))
    monkeypatch.setattr(api, 'consume',
                        lambda x: iter([CPUInfo(machine_type=666)]))
    monkeypatch.setattr(reporting, "create_report",
                        testutils.create_report_mocked())
    cpu.process()
    assert reporting.create_report.called
    assert title_msg == reporting.create_report.report_fields['title']
    assert reporting.Flags.INHIBITOR in reporting.create_report.report_fields[
        'flags']
Exemplo n.º 6
0
def test_machine_type(monkeypatch):
    # cpuinfo doesn't contain a machine field
    mocked_cpuinfo = mocked_get_cpuinfo('cpuinfo_x86_64')
    monkeypatch.setattr(cpu, '_get_cpuinfo', mocked_cpuinfo)
    monkeypatch.setattr(api, 'produce', testutils.produce_mocked())
    cpu.process()
    assert api.produce.called == 1
    assert CPUInfo() == api.produce.model_instances[0]

    # cpuinfo contains a machine field
    api.produce.called = 0
    api.produce.model_instances = []
    mocked_cpuinfo.filename = 'cpuinfo_s390x'
    cpu.process()
    assert api.produce.called == 1
    assert CPUInfo(machine_type=2827) == api.produce.model_instances[0]
Exemplo n.º 7
0
 def process(self):
     cpu.process()