Exemplo n.º 1
0
    def test_is_software_selection_complete(self):
        """Test the is_software_selection_complete function."""
        selection = PackagesSelectionData()
        selection.environment = "e1"

        dnf_manager = Mock(spec=DNFManager)
        dnf_manager.is_environment_valid.return_value = True

        assert is_software_selection_complete(dnf_manager, selection)
        assert is_software_selection_complete(dnf_manager,
                                              selection,
                                              kickstarted=True)

        dnf_manager.is_environment_valid.return_value = False

        assert not is_software_selection_complete(dnf_manager, selection)
        assert not is_software_selection_complete(
            dnf_manager, selection, kickstarted=True)

        selection.environment = ""

        assert not is_software_selection_complete(dnf_manager, selection)
        assert is_software_selection_complete(dnf_manager,
                                              selection,
                                              kickstarted=True)
Exemplo n.º 2
0
    def is_software_selection_complete_test(self):
        """Test the is_software_selection_complete function."""
        selection = PackagesSelectionData()
        selection.environment = "e1"

        dnf_manager = Mock(spec=DNFManager)
        dnf_manager.is_environment_valid.return_value = True

        self.assertTrue(is_software_selection_complete(dnf_manager, selection))
        self.assertTrue(
            is_software_selection_complete(dnf_manager,
                                           selection,
                                           kickstarted=True))

        dnf_manager.is_environment_valid.return_value = False

        self.assertFalse(is_software_selection_complete(
            dnf_manager, selection))
        self.assertFalse(
            is_software_selection_complete(dnf_manager,
                                           selection,
                                           kickstarted=True))

        selection.environment = ""

        self.assertFalse(is_software_selection_complete(
            dnf_manager, selection))
        self.assertTrue(
            is_software_selection_complete(dnf_manager,
                                           selection,
                                           kickstarted=True))
Exemplo n.º 3
0
    def check_selection_test(self, kernel_getter):
        kernel_getter.return_value = None
        dnf_manager = Mock()

        selection = PackagesSelectionData()
        selection.core_group_enabled = False
        selection.environment = "e1"

        selection.packages = ["p1", "p2"]
        selection.excluded_packages = ["p3", "p4"]

        selection.groups = ["g1", "g2"]
        selection.excluded_groups = ["g3", "g4"]

        selection.modules = ["m1", "m2"]
        selection.disabled_modules = ["m3", "m4"]

        task = CheckPackagesSelectionTask(dnf_manager, selection)
        report = task.run()

        dnf_manager.clear_selection.assert_called_once_with()
        dnf_manager.disable_modules.assert_called_once_with(["m3", "m4"])
        dnf_manager.enable_modules.assert_called_once_with(["m1", "m2"])
        dnf_manager.apply_specs.assert_called_once_with(
            ["@e1", "@g1", "@g2", "p1", "p2"],
            ["@core", "@g3", "@g4", "p3", "p4"])
        dnf_manager.resolve_selection.assert_called_once_with()
        self.assertEqual(report.get_messages(), [])
Exemplo n.º 4
0
    def _process_kickstart_packages_selection(self, data):
        """Process the kickstart packages selection."""
        selection = PackagesSelectionData()
        selection.core_group_enabled = not data.packages.nocore
        selection.default_environment_enabled = data.packages.default

        if data.packages.environment is not None:
            selection.environment = data.packages.environment

        selection.packages = data.packages.packageList
        selection.excluded_packages = data.packages.excludedList

        for group in data.packages.groupList:
            selection.groups.append(group.name)

            if group.include == GROUP_ALL:
                selection.groups_package_types[
                    group.name] = GROUP_PACKAGE_TYPES_ALL

            if group.include == GROUP_REQUIRED:
                selection.groups_package_types[
                    group.name] = GROUP_PACKAGE_TYPES_REQUIRED

        for group in data.packages.excludedGroupList:
            selection.excluded_groups.append(group.name)

        self.set_packages_selection(selection)
        self.set_packages_kickstarted(data.packages.seen)
Exemplo n.º 5
0
    def test_apply_selection_data(self):
        """Test the apply_selection_data method."""
        selection = PackagesSelectionData()
        selection.environment = "e1"
        selection.groups = ["g1", "g2", "g3"]

        self.cache.apply_selection_data(selection)
        assert self.cache.environment == "e1"
        assert self.cache.groups == ["g1", "g2", "g3"]
Exemplo n.º 6
0
    def get_selection_data(self) -> PackagesSelectionData:
        """Generate the selection data.

        :return: a packages selection data
        """
        selection = PackagesSelectionData()
        selection.environment = self.environment
        selection.groups = self.groups
        return selection
Exemplo n.º 7
0
    def apply_selection_data_test(self):
        """Test the apply_selection_data method."""
        selection = PackagesSelectionData()
        selection.environment = "e1"
        selection.groups = ["g1", "g2", "g3"]

        self.cache.apply_selection_data(selection)
        self.assertEqual(self.cache.environment, "e1")
        self.assertEqual(self.cache.groups, ["g1", "g2", "g3"])
Exemplo n.º 8
0
    def test_apply_selection_data_invalid_groups(self):
        """Test the apply_selection_data method with invalid groups."""
        self.dnf_manager.resolve_group.return_value = False

        selection = PackagesSelectionData()
        selection.environment = "e1"
        selection.groups = ["g1", "g2", "g3"]

        self.cache.apply_selection_data(selection)
        assert self.cache.environment == "e1"
        assert self.cache.groups == []
Exemplo n.º 9
0
    def test_apply_selection_data_invalid_environment(self):
        """Test the apply_selection_data method with an invalid environment."""
        self.dnf_manager.default_environment = ""
        self.dnf_manager.resolve_environment.return_value = False

        selection = PackagesSelectionData()
        selection.environment = "e2"

        self.cache.apply_selection_data(selection)
        assert self.cache.environment == ""
        assert self.cache.groups == []
Exemplo n.º 10
0
    def test_apply_selection_data_default_environment(self):
        """Test the apply_selection_data method with a default environment."""
        self.dnf_manager.default_environment = "e1"
        self.dnf_manager.resolve_environment.return_value = False

        selection = PackagesSelectionData()
        selection.environment = "e2"

        self.cache.apply_selection_data(selection)
        self.assertEqual(self.cache.environment, "e1")
        self.assertEqual(self.cache.groups, [])
Exemplo n.º 11
0
    def test_get_software_selection_status(self):
        """Test the get_software_selection_status function."""
        selection = PackagesSelectionData()
        selection.environment = "e1"

        environment_data = CompsEnvironmentData()
        environment_data.name = "The e1 environment"

        dnf_manager = Mock(spec=DNFManager)
        dnf_manager.is_environment_valid.return_value = True
        dnf_manager.get_environment_data.return_value = environment_data

        status = get_software_selection_status(dnf_manager, selection)
        assert status == "The e1 environment"

        status = get_software_selection_status(dnf_manager,
                                               selection,
                                               kickstarted=True)
        assert status == "The e1 environment"

        dnf_manager.is_environment_valid.return_value = False

        status = get_software_selection_status(dnf_manager, selection)
        assert status == "Selected environment is not valid"

        status = get_software_selection_status(dnf_manager,
                                               selection,
                                               kickstarted=True)
        assert status == "Invalid environment specified in kickstart"

        selection.environment = ""

        status = get_software_selection_status(dnf_manager, selection)
        assert status == "Please confirm software selection"

        status = get_software_selection_status(dnf_manager,
                                               selection,
                                               kickstarted=True)
        assert status == "Custom software selected"
Exemplo n.º 12
0
    def test_get_selection_data(self):
        """Test the get_selection_data method."""
        self.cache.select_environment("e1")
        self.cache.select_group("g1")
        self.cache.select_group("g2")
        self.cache.select_group("g3")

        expected = PackagesSelectionData()
        expected.environment = "e1"
        expected.groups = ["g1", "g2", "g3"]

        data = self.cache.get_selection_data()
        assert compare_data(data, expected)
Exemplo n.º 13
0
    def test_get_installation_specs_environment(self):
        """Test the get_installation_specs function with environment."""
        data = PackagesSelectionData()
        data.environment = "environment-1"

        assert get_installation_specs(data) == (["@environment-1",
                                                 "@core"], [])

        env = "environment-2"
        assert get_installation_specs(
            data, default_environment=env) == (["@environment-1", "@core"], [])

        data.default_environment_enabled = True
        assert get_installation_specs(
            data, default_environment=env) == (["@environment-2", "@core"], [])
Exemplo n.º 14
0
    def get_installation_specs_environment_test(self):
        """Test the get_installation_specs function with environment."""
        data = PackagesSelectionData()
        data.environment = "environment-1"

        self.assertEqual(get_installation_specs(data),
                         (["@environment-1", "@core"], []))

        env = "environment-2"
        self.assertEqual(get_installation_specs(data, default_environment=env),
                         (["@environment-1", "@core"], []))

        data.default_environment_enabled = True
        self.assertEqual(get_installation_specs(data, default_environment=env),
                         (["@environment-2", "@core"], []))