Skip to content

Commit

Permalink
Add test to check if failed run correctly raised StopActorExecutionError
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfratrik committed Mar 12, 2024
1 parent 9447456 commit ed5473d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def process():
details={
'details': 'Failed to execute `udevadm info -e` command.',
'error': str(err)
}
}
)
api.produce(UdevAdmInfoData(db=out))
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
import os

import pytest

from leapp.exceptions import StopActorExecutionError
from leapp.libraries.actor import udevadminfo
from leapp.libraries.common import testutils
from leapp.libraries.stdlib import api, run
from leapp.libraries.stdlib import api, CalledProcessError
from leapp.models import UdevAdmInfoData

CUR_DIR = os.path.dirname(os.path.abspath(__file__))


def _raise_call_error(*args):
raise CalledProcessError(
message='A Leapp Command Error occurred.',
command=args,
result={'signal': None, 'exit_code': 1, 'pid': 0, 'stdout': 'fake', 'stderr': 'fake'}
)


def test_failed_run(monkeypatch):
monkeypatch.setattr(api, 'produce', testutils.produce_mocked())
monkeypatch.setattr(udevadminfo, 'run', _raise_call_error)

with pytest.raises(StopActorExecutionError):
udevadminfo.process()


def test_udevadminfo(monkeypatch):

with open(os.path.join(CUR_DIR, 'files', 'udevadm_database'), 'r') as fp:
Expand Down

0 comments on commit ed5473d

Please sign in to comment.