Skip to content

Commit

Permalink
Change inhibitor to use StopError instead StopErrorExecution
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre José Possebom Silveira authored and pirat89 committed Mar 27, 2019
1 parent 75e9f56 commit a3c4c77
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from collections import namedtuple

from leapp.exceptions import StopActorExecutionError
from leapp.exceptions import StopActorExecution
from leapp.libraries.common import reporting
from leapp.libraries.stdlib import api
from leapp.models import InstalledRedHatSignedRPM, RpmTransactionTasks, RepositoriesSetupTasks
Expand Down Expand Up @@ -143,11 +143,11 @@ def scan_events(path):
""" Scan JSON file containing PES events """
try:
events = parse_file(path)
except (ValueError, KeyError) as error:
except (ValueError, KeyError):
title = 'Missing/Invalid PES data file ({})'.format(path)
summary = 'Read documentation at: https://access.redhat.com/articles/3664871 for more information ' \
'about how to retrieve the files'
reporting.report_generic(title=title, summary=summary, severity='high', flags=['inhibitor'])
raise StopActorExecutionError(message=title, details={'hint': summary, 'details': str(error)})
raise StopActorExecution()

process_events(filter_events(events))
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from leapp.exceptions import StopActorExecutionError
from leapp.exceptions import StopActorExecution
from leapp.libraries.actor import library
from leapp.libraries.actor.library import (Event,
parse_action,
Expand Down Expand Up @@ -219,14 +219,14 @@ def consume_message_mocked(*models):
assert isinstance(api.produce.model_instances[1], RepositoriesSetupTasks)
assert api.produce.model_instances[1].to_enable == ['mapped']

with pytest.raises(StopActorExecutionError):
with pytest.raises(StopActorExecution):
scan_events('files/tests/sample02.json')
assert reporting.report_generic.called == 1
assert 'inhibitor' in reporting.report_generic.report_fields['flags']

reporting.report_generic.called = 0
reporting.report_generic.model_instances = []
with pytest.raises(StopActorExecutionError):
with pytest.raises(StopActorExecution):
scan_events('files/tests/sample03.json')
assert reporting.report_generic.called == 1
assert 'inhibitor' in reporting.report_generic.report_fields['flags']
Expand All @@ -237,7 +237,7 @@ def file_not_exists(_filepath):
return False
monkeypatch.setattr('os.path.isfile', file_not_exists)
monkeypatch.setattr(reporting, 'report_generic', report_generic_mocked())
with pytest.raises(StopActorExecutionError):
with pytest.raises(StopActorExecution):
scan_events('/etc/leapp/pes-data.json')
assert reporting.report_generic.called == 1
assert 'inhibitor' in reporting.report_generic.report_fields['flags']
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import csv
import os

from leapp.exceptions import StopActorExecutionError
from leapp.exceptions import StopActorExecution
from leapp.libraries.common import reporting
from leapp.libraries.stdlib import api
from leapp.models import RepositoriesMap, RepositoryMap
Expand All @@ -12,7 +12,7 @@ def inhibit_upgrade(title):
summary = 'Read documentation at: https://access.redhat.com/articles/3664871 for more information ' \
'about how to retrieve the files'
reporting.report_generic(title=title, summary=summary, severity='high', flags=['inhibitor'])
raise StopActorExecutionError(message=title, details={'details': summary})
raise StopActorExecution()


def scan_repositories(path):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from leapp.exceptions import StopActorExecutionError
from leapp.exceptions import StopActorExecution
from leapp.libraries.actor.library import scan_repositories
from leapp.libraries.common import reporting
from leapp.libraries.stdlib import api
Expand Down Expand Up @@ -47,7 +47,7 @@ def file_not_exists(_filepath):
return False
monkeypatch.setattr('os.path.isfile', file_not_exists)
monkeypatch.setattr(reporting, 'report_generic', report_generic_mocked())
with pytest.raises(StopActorExecutionError):
with pytest.raises(StopActorExecution):
scan_repositories('/etc/leapp/files/repomap.csv')
assert reporting.report_generic.called == 1
assert 'inhibitor' in reporting.report_generic.report_fields['flags']
Expand All @@ -56,7 +56,7 @@ def file_not_exists(_filepath):

def test_scan_empty_file(monkeypatch):
monkeypatch.setattr(reporting, 'report_generic', report_generic_mocked())
with pytest.raises(StopActorExecutionError):
with pytest.raises(StopActorExecution):
scan_repositories('files/tests/sample02.csv')
assert reporting.report_generic.called == 1
assert 'inhibitor' in reporting.report_generic.report_fields['flags']
Expand All @@ -65,7 +65,7 @@ def test_scan_empty_file(monkeypatch):

def test_scan_invalid_file_txt(monkeypatch):
monkeypatch.setattr(reporting, 'report_generic', report_generic_mocked())
with pytest.raises(StopActorExecutionError):
with pytest.raises(StopActorExecution):
scan_repositories('files/tests/sample03.csv')
assert reporting.report_generic.called == 1
assert 'inhibitor' in reporting.report_generic.report_fields['flags']
Expand All @@ -74,7 +74,7 @@ def test_scan_invalid_file_txt(monkeypatch):

def test_scan_invalid_file_csv(monkeypatch):
monkeypatch.setattr(reporting, 'report_generic', report_generic_mocked())
with pytest.raises(StopActorExecutionError):
with pytest.raises(StopActorExecution):
scan_repositories('files/tests/sample04.csv')
assert reporting.report_generic.called == 1
assert 'inhibitor' in reporting.report_generic.report_fields['flags']
Expand Down

0 comments on commit a3c4c77

Please sign in to comment.