def test_no_facts(monkeypatch):
    def os_release_mocked(*models):
        yield None

    monkeypatch.setattr(api, "consume", os_release_mocked)
    with pytest.raises(StopActorExecutionError):
        library.check_os_version(SUPPORTED_VERSION)
def test_not_supported_release(monkeypatch):
    monkeypatch.setattr(version, "is_supported_version", lambda: False)
    monkeypatch.setattr(reporting, "create_report", create_report_mocked())

    library.check_os_version()
    assert reporting.create_report.called == 1
    assert 'Unsupported OS' in reporting.create_report.report_fields['title']
    assert 'flags' in reporting.create_report.report_fields
    assert 'inhibitor' in reporting.create_report.report_fields['flags']
def test_not_supported_release(monkeypatch):
    def os_release_mocked(*models):
        yield create_os_release('unsupported', SUPPORTED_VERSION['rhel'][0])

    monkeypatch.setattr(api, "consume", os_release_mocked)
    monkeypatch.setattr(reporting, "report_generic", report_generic_mocked())

    library.check_os_version(SUPPORTED_VERSION)
    assert reporting.report_generic.called == 1
    assert 'Unsupported OS' in reporting.report_generic.report_fields['title']
    assert 'flags' in reporting.report_generic.report_fields
    assert 'inhibitor' in reporting.report_generic.report_fields['flags']
Пример #4
0
def test_not_supported_id(monkeypatch):
    def os_release_mocked(*models):
        yield create_os_release('rhel', '7.7')

    monkeypatch.setattr(api, "consume", os_release_mocked)
    monkeypatch.setattr(reporting, "create_report", create_report_mocked())

    library.check_os_version(SUPPORTED_VERSION)
    assert reporting.create_report.called == 1
    assert 'Unsupported OS version' in reporting.create_report.report_fields[
        'title']
    assert 'flags' in reporting.create_report.report_fields
    assert 'inhibitor' in reporting.create_report.report_fields['flags']
def test_supported_release(monkeypatch):
    def os_mocked_first_release(*models):
        yield create_os_release('rhel', SUPPORTED_VERSION['rhel'][0])

    def os_mocked_second_release(*models):
        yield create_os_release('rhel', SUPPORTED_VERSION['rhel'][1])

    monkeypatch.setattr(api, "consume", os_mocked_first_release)
    monkeypatch.setattr(reporting, "report_generic", report_generic_mocked())

    library.check_os_version(SUPPORTED_VERSION)
    monkeypatch.setattr(api, "consume", os_mocked_second_release)
    library.check_os_version(SUPPORTED_VERSION)
    assert reporting.report_generic.called == 0
def test_invalid_versions(monkeypatch):
    def os_release_mocked(*models):
        yield create_os_release('rhel', '7.6')

    monkeypatch.setattr(api, "consume", os_release_mocked)
    monkeypatch.setattr(reporting, "report_generic", report_generic_mocked())

    with pytest.raises(StopActorExecution):
        library.check_os_version('string')
    with pytest.raises(StopActorExecution):
        library.check_os_version(None)

    library.check_os_version({})
    assert reporting.report_generic.called == 1
    with pytest.raises(StopActorExecutionError):
        library.check_os_version({'rhel': None})
Пример #7
0
 def process(self):
     if not skip_check():
         check_os_version(version.SUPPORTED_VERSION)
Пример #8
0
 def process(self):
     supported_version = {'rhel': ['7.6']}
     if not skip_check():
         check_os_version(supported_version)
Пример #9
0
 def process(self):
     if not skip_check():
         check_os_version()
Пример #10
0
def test_supported_release(monkeypatch):
    monkeypatch.setattr(version, "is_supported_version", lambda: True)
    monkeypatch.setattr(reporting, "create_report", create_report_mocked())

    library.check_os_version()
    assert reporting.create_report.called == 0