def test_pes_data_not_found(monkeypatch):
    def read_or_fetch_mocked(filename, directory="/etc/leapp/files", service=None, allow_empty=False):
        fetch._raise_error('pes-data.json', 'epic fail!')

    monkeypatch.setattr(fetch, 'read_or_fetch', read_or_fetch_mocked)
    monkeypatch.setattr(reporting, 'create_report', create_report_mocked())
    monkeypatch.setattr(api, 'current_actor', CurrentActorMocked())
    with pytest.raises(StopActorExecutionError):
        get_events('/etc/leapp', 'pes-data.json')
Beispiel #2
0
def test_pes_data_not_found(monkeypatch):
    def file_not_exists(_filepath):
        return False

    monkeypatch.setattr(os.path, 'isfile', file_not_exists)
    monkeypatch.setattr(reporting, 'create_report', create_report_mocked())
    with pytest.raises(StopActorExecution):
        get_events('/etc/leapp/pes-data.json')
    assert reporting.create_report.called == 1
    assert 'inhibitor' in reporting.create_report.report_fields['flags']
Beispiel #3
0
def test_get_events(monkeypatch):
    monkeypatch.setattr(reporting, 'create_report', create_report_mocked())

    with pytest.raises(StopActorExecution):
        get_events(os.path.join(CUR_DIR, 'files/sample02.json'))
    assert reporting.create_report.called == 1
    assert 'inhibitor' in reporting.create_report.report_fields['flags']

    reporting.create_report.called = 0
    reporting.create_report.model_instances = []
    with pytest.raises(StopActorExecution):
        get_events(os.path.join(CUR_DIR, 'files/sample03.json'))
    assert reporting.create_report.called == 1
    assert 'inhibitor' in reporting.create_report.report_fields['flags']
def test_get_events(monkeypatch):
    """
    Verifies that the actor gracefully handles errors raised when unable to load events from a file
    and inhibits the upgrade in such case.
    """
    monkeypatch.setattr(reporting, 'create_report', create_report_mocked())
    monkeypatch.setattr(api, 'current_actor', CurrentActorMocked())

    with pytest.raises(StopActorExecution):
        get_events(os.path.join(CUR_DIR, 'files'), 'sample02.json')
    assert reporting.create_report.called == 1
    assert 'inhibitor' in reporting.create_report.report_fields['flags']

    reporting.create_report.called = 0
    reporting.create_report.model_instances = []
    with pytest.raises(StopActorExecution):
        get_events(os.path.join(CUR_DIR, 'files'), 'sample03.json')
    assert reporting.create_report.called == 1
    assert 'inhibitor' in reporting.create_report.report_fields['flags']