def test_resolve(self, kernel_getter, req_getter1, req_getter2, req_getter3, req_getter4): """Test the successful ResolvePackagesTask task.""" kernel_getter.return_value = None req_getter1.return_value = [ Requirement.for_group("r1"), Requirement.for_group("r2") ] req_getter2.return_value = [Requirement.for_group("r3")] req_getter3.return_value = [ Requirement.for_package("r4"), Requirement.for_package("r5") ] req_getter4.return_value = [Requirement.for_package("r6")] selection = PackagesSelectionData() selection.excluded_groups = ["r3"] selection.excluded_packages = ["r6"] dnf_manager = Mock() dnf_manager.default_environment = None task = ResolvePackagesTask(dnf_manager, selection) task.run() dnf_manager.clear_selection.assert_called_once_with() dnf_manager.disable_modules.assert_called_once_with([]) dnf_manager.enable_modules.assert_called_once_with([]) dnf_manager.apply_specs.assert_called_once_with( ["@core", "@r1", "@r2", "r4", "r5"], ["@r3", "r6"]) dnf_manager.resolve_selection.assert_called_once_with()
def add_requirements_test(self): """Check that multiple requirements can be added at once.""" reqs = PayloadRequirements() self.assertTrue(reqs.empty) # add a package, group & unknown requirement type req_list = [] req_list.append(Requirement.for_package("foo-package", reason="foo package needed")) req_list.append(Requirement.for_group("bar-group", reason="bar group needed")) unknown_req = Requirement() unknown_req.name = "baz-unknown" unknown_req.reson = "unknown reason for installation" unknown_req.type = "baz-unknown-type" req_list.append(unknown_req) # add the requrements list and check it is processed correctly reqs.add_requirements(req_list) self.assertFalse(reqs.empty) # package self.assertEqual(len(reqs.packages), 1) self.assertEqual(reqs.packages[0].id, "foo-package") self.assertEqual(len(reqs.packages[0].reasons), 1) self.assertEqual(reqs.packages[0].reasons[0], "foo package needed") self.assertTrue(reqs.packages[0].strong) # group self.assertEqual(len(reqs.groups), 1) self.assertEqual(reqs.groups[0].id, "bar-group") self.assertEqual(len(reqs.groups[0].reasons), 1) self.assertEqual(reqs.groups[0].reasons[0], "bar group needed") self.assertTrue(reqs.groups[0].strong)
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)) ]
def test_group_requirement(self): requirement = Requirement.for_group("group-name", "reason") self.assertEqual(requirement.type, "group") self.assertEqual(requirement.name, "group-name") self.assertEqual(requirement.reason, "reason")
def test_group_requirement(self): requirement = Requirement.for_group("group-name", "reason") assert requirement.type == "group" assert requirement.name == "group-name" assert requirement.reason == "reason"