Exemplo n.º 1
0
    def _get_environment_data(self, env) -> CompsEnvironmentData:
        """Get the environment data.

        :param env: a DNF representation of the environment
        :return: an instance of CompsEnvironmentData
        """
        data = CompsEnvironmentData()
        data.id = env.id or ""
        data.name = env.ui_name or ""
        data.description = env.ui_description or ""

        optional = {i.name for i in env.option_ids}
        default = {i.name for i in env.option_ids if i.default}

        for grp in self._base.comps.groups:

            if grp.id in optional:
                data.optional_groups.append(grp.id)

            if grp.visible:
                data.visible_groups.append(grp.id)

            if grp.id in default:
                data.default_groups.append(grp.id)

        return data
    def test_get_environment_data(self):
        """Test the get_environment_data method."""
        self._add_environment("e1")

        expected = CompsEnvironmentData()
        expected.id = "e1"
        expected.name = "The 'e1' environment"
        expected.description = "This is the 'e1' environment."

        data = self.dnf_manager.get_environment_data("e1")
        assert isinstance(data, CompsEnvironmentData)
        assert compare_data(data, expected)