def test_created_modules(monkeypatch): monkeypatch.setattr(api, 'get_actor_folder_path', _files_get_folder_path) path = os.path.abspath(api.get_actor_folder_path('dracut')) required_modules = ['sys-upgrade', 'sys-upgrade-redhat'] for mod in modscan._create_dracut_modules(): index = required_modules.index(mod.name) # Ensures that this actor only includes known modules assert index != -1 required_modules.pop(index) # Ensures that the path is valid assert mod.module_path assert mod.module_path == os.path.abspath(mod.module_path) # Ensure it's a directory assert os.path.isdir(mod.module_path) # Ensure it's located within the actors files path assert mod.module_path.startswith(path) # Ensure the directory name ends with the module name assert os.path.basename(mod.module_path).endswith(mod.name) assert not re.sub(r'^(85|90){}$'.format(mod.name), '', os.path.basename(mod.module_path)) assert not required_modules
def test_created_modules(monkeypatch): monkeypatch.setattr(api, 'get_actor_folder_path', _files_get_folder_path) path = os.path.abspath(api.get_actor_folder_path('dracut')) required_modules = {'sys-upgrade', 'sys-upgrade-redhat'} # _old is for deprecated stuff, _new is ... # we want to test that the new and original solution produce 'equivalent' output produced_required_modules_old = set() produced_required_modules_new = set() def check_module(mod): # Ensures that this actor only includes known modules assert mod.name in required_modules # Ensures that the path is valid assert mod.module_path assert mod.module_path == os.path.abspath(mod.module_path) # Ensure it's a directory assert os.path.isdir(mod.module_path) # Ensure it's located within the actors files path assert mod.module_path.startswith(path) # Ensure the directory name ends with the module name assert os.path.basename(mod.module_path).endswith(mod.name) assert not re.sub(r'^(85|90){}$'.format(mod.name), '', os.path.basename(mod.module_path)) for msg in modscan._create_dracut_modules(): if isinstance(msg, UpgradeDracutModule): produced_required_modules_old.add(msg.name) check_module(msg) else: for mod in msg.include_dracut_modules: produced_required_modules_new.add(mod.name) check_module(mod) # ensure that old and new solution produce equivalent (expected) output assert produced_required_modules_new == produced_required_modules_old == required_modules