def test_detect_virtualized_platform(self): """Test the function detect_virtualized_platform.""" with patch('pyanaconda.core.util.execWithCapture') as execute: execute.side_effect = OSError assert util.detect_virtualized_platform() is None with patch('pyanaconda.core.util.execWithCapture') as execute: execute.return_value = "none" assert util.detect_virtualized_platform() is None with patch('pyanaconda.core.util.execWithCapture') as execute: execute.return_value = "vmware" assert util.detect_virtualized_platform() == "vmware"
def detect_virtualized_platform_test(self): """Test the function detect_virtualized_platform.""" with patch('pyanaconda.core.util.execWithCapture') as execute: execute.side_effect = IOError self.assertEqual(util.detect_virtualized_platform(), None) with patch('pyanaconda.core.util.execWithCapture') as execute: execute.return_value = "none" self.assertEqual(util.detect_virtualized_platform(), None) with patch('pyanaconda.core.util.execWithCapture') as execute: execute.return_value = "vmware" self.assertEqual(util.detect_virtualized_platform(), "vmware")
def collect_platform_requirements(dnf_base): """Collect the requirements for the current platform. :param dnf_base: a DNF base :return: a list of requirements """ # Detect the current platform. platform = detect_virtualized_platform() if not platform: return [] # Get all available groups. available_groups = [g.id for g in dnf_base.comps.groups_iter()] # Add a platform specific group. group = "platform-" + platform.lower() if group not in available_groups: log.warning("Platform group %s not available.", group) return [] return [ Requirement.for_group( group_name=group, reason="Required for the {} platform.".format(platform)) ]
def collect_platform_requirements(dnf_manager): """Collect the requirements for the current platform. :param dnf_manager: a DNF manager :return: a list of requirements """ # Detect the current platform. platform = detect_virtualized_platform() if not platform: return [] # Add a platform specific group. group = "platform-" + platform.lower() if group not in dnf_manager.groups: log.warning("Platform group %s not available.", group) return [] return [ Requirement.for_group( group_name=group, reason="Required for the {} platform.".format(platform)) ]