def status(self):
        """The status of the spoke."""
        if self._processing_data:
            return _("Processing...")
        if not self._source_is_set:
            return _("Installation source not set up")
        if self._source_has_changed:
            return _("Source changed - please verify")
        if self.errors:
            return _("Error checking software selection")

        return get_software_selection_status(dnf_manager=self._dnf_manager,
                                             selection=self._selection,
                                             kickstarted=self._kickstarted)
Exemple #2
0
    def status(self):
        """The status of the spoke."""
        if self._processing_data:
            return _("Processing...")
        if is_cdn_registration_required(self.payload):
            return _("Red Hat CDN requires registration.")
        if not self._source_is_set:
            return _("Installation source not set up")
        if self._source_has_changed:
            return _("Source changed - please verify")
        if self._errors:
            return _("Error checking software selection")
        if self._warnings:
            return _("Warning checking software selection")

        return get_software_selection_status(dnf_manager=self._dnf_manager,
                                             selection=self._selection,
                                             kickstarted=self._kickstarted)
    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"