Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfratrik committed Aug 28, 2024
1 parent 002be89 commit 880fe49
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@

import pytest

from leapp.libraries.actor.systemfacts import _get_system_groups, _get_system_users, anyendswith, anyhasprefix, aslist
from leapp.exceptions import StopActorExecutionError
from leapp.libraries.actor.systemfacts import (
_get_system_groups,
_get_system_users,
anyendswith,
anyhasprefix,
aslist,
get_repositories_status
)
from leapp.libraries.common import repofileutils
from leapp.libraries.common.testutils import logger_mocked
from leapp.libraries.stdlib import api
from leapp.snactor.fixture import current_actor_libraries
Expand Down Expand Up @@ -116,3 +125,16 @@ def __init__(self, gr_name, gr_gid, gr_mem):
assert group_name not in api.current_logger().dbgmsg[0]
else:
assert not api.current_logger().dbgmsg


def test_failed_parsed_repofiles(monkeypatch):
def _raise_invalidrepo_error():
raise repofileutils.InvalidRepoDefinition(msg='mocked error',
repofile='/etc/yum.repos.d/mock.repo',
repoid='mocked repoid')

monkeypatch.setattr(repofileutils, 'get_parsed_repofiles', _raise_invalidrepo_error)
monkeypatch.setattr(api, 'current_logger', logger_mocked())

with pytest.raises(StopActorExecutionError):
get_repositories_status()

0 comments on commit 880fe49

Please sign in to comment.