-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add actor name discovery and some unit tests
With this checking part should be complete.
- Loading branch information
1 parent
ceb0a78
commit 6802b63
Showing
3 changed files
with
119 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...tem_upgrade/common/actors/trackcustommodifications/tests/test_trackcustommodifications.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import pytest | ||
|
||
from leapp.libraries.actor import trackcustommodifications | ||
from leapp.libraries.common.testutils import CurrentActorMocked, produce_mocked | ||
from leapp.libraries.stdlib import api | ||
|
||
|
||
FILES_FROM_RPM = """ | ||
repos/system_upgrade/el8toel9/actors/xorgdrvfact/libraries/xorgdriverlib.py | ||
repos/system_upgrade/el8toel9/actors/anotheractor/actor.py | ||
repos/system_upgrade/el8toel9/files | ||
""" | ||
|
||
FILES_ON_SYSTEM = """ | ||
repos/system_upgrade/el8toel9/actors/xorgdrvfact/libraries/xorgdriverlib.py | ||
repos/system_upgrade/el8toel9/actors/anotheractor/actor.py | ||
repos/system_upgrade/el8toel9/files | ||
/some/unrelated/to/leapp/file | ||
repos/system_upgrade/el8toel9/files/file/that/should/not/be/there | ||
repos/system_upgrade/el8toel9/actors/actor/that/should/not/be/there | ||
""" | ||
|
||
VERIFIED_FILES = """ | ||
.......T. repos/system_upgrade/el8toel9/actors/xorgdrvfact/libraries/xorgdriverlib.py | ||
S.5....T. repos/system_upgrade/el8toel9/actors/anotheractor/actor.py | ||
""" | ||
|
||
@pytest.mark.parametrize( | ||
'file,name', | ||
[('repos/system_upgrade/el8toel9/actors/checkblacklistca/actor.py', 'CheckBlackListCA'), | ||
('repos/system_upgrade/el7toel8/actors/checkmemcached/actor.py', 'CheckMemcached'), | ||
('repos/system_upgrade/el7toel8/actors/checkmemcached/libraries/checkmemcached.py', 'CheckMemcached'), | ||
# not a library and not an actor file | ||
('repos/system_upgrade/el7toel8/models/authselect.py', ''), | ||
] | ||
) | ||
def test_deduce_actor_name_from_file(file, name): | ||
assert trackcustommodifications.deduce_actor_name(file) == name | ||
|
||
|
||
def mocked__run_command(list_of_args, log_message): | ||
if list_of_args == ['rpm', '-ql', 'leapp-upgrade-el7toel8']: | ||
# get source of truth | ||
return FILES_FROM_RPM.strip().split('\n'), None | ||
if list_of_args and list_of_args[0] == 'find': | ||
# listing files in directory | ||
return FILES_ON_SYSTEM.strip().split('\n'), None | ||
if list_of_args == ['rpm', '-V', 'leapp-upgrade-el7toel8']: | ||
# checking authenticity | ||
return VERIFIED_FILES.strip().split('\n'), None | ||
|
||
|
||
def test_check_for_modifications(monkeypatch): | ||
monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(arch='x86_64', src_ver='7.9', dst_ver='8.4')) | ||
monkeypatch.setattr(trackcustommodifications, '_run_command', mocked__run_command) | ||
modified, custom = trackcustommodifications.check_for_modifications() | ||
assert len(modified) == 2 | ||
assert modified[0].filename == 'repos/system_upgrade/el8toel9/actors/xorgdrvfact/libraries/xorgdriverlib.py' | ||
assert modified[0].rpm_checks_str == '.......T.' | ||
assert len(custom) == 3 | ||
assert custom[0].filename == '/some/unrelated/to/leapp/file' | ||
assert custom[0].rpm_checks_str == '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters