Пример #1
0
    def test_environment_name(self):
        # dnf.comps.Environment.name
        libcomps_environment = libcomps.Environment("id", "name",
                                                    "description")
        environment = dnf.comps.Environment(iobj=libcomps_environment,
                                            langs=None,
                                            group_factory=None)

        self.assertHasAttr(environment, "name")
        self.assertHasType(environment.name, str)
Пример #2
0
    def test_environment_ui_description(self):
        # dnf.comps.Environment.ui_description
        libcomps_environment = libcomps.Environment("id", "name",
                                                    "description")
        langs = MockLangs()
        environment = dnf.comps.Environment(iobj=libcomps_environment,
                                            langs=langs,
                                            group_factory=None)

        self.assertHasAttr(environment, "ui_description")
        self.assertHasType(environment.ui_description, str)
Пример #3
0
    def pkg_env_to_libcomps(self):
        """
        Convert PackageEnvironment object to libcomps Environment object.

        Returns:
            group: libcomps.Environment object

        """
        env = libcomps.Environment()

        env.id = getattr(self, PULP_ENVIRONMENT_ATTRS.ID)
        env.name = getattr(self, PULP_ENVIRONMENT_ATTRS.NAME)
        env.desc = getattr(self, PULP_ENVIRONMENT_ATTRS.DESCRIPTION)
        env.display_order = getattr(self, PULP_ENVIRONMENT_ATTRS.DISPLAY_ORDER)
        env.group_ids = list_to_idlist(getattr(self, PULP_ENVIRONMENT_ATTRS.GROUP_IDS))
        env.option_ids = list_to_idlist(getattr(self, PULP_ENVIRONMENT_ATTRS.OPTION_IDS))
        env.desc_by_lang = dict_to_strdict(getattr(self, PULP_ENVIRONMENT_ATTRS.DESC_BY_LANG))
        env.name_by_lang = dict_to_strdict(getattr(self, PULP_ENVIRONMENT_ATTRS.NAME_BY_LANG))

        return env
Пример #4
0
def pkg_env_to_libcomps(obj):
    """
    Convert PackageEnvironment object to libcomps Environment object.

    Args:
        obj(Pulp2PackageEnvironment): Pulp2PackageEnvironment

    Returns:
        group: libcomps.Environment object

    """
    env = libcomps.Environment()

    env.id = obj.package_environment_id
    env.name = obj.name
    env.desc = obj.description
    env.display_order = obj.display_order
    env.group_ids = list_to_idlist(_packages_to_grplist(obj.group_ids))
    result = _packages_to_optionlist(obj.option_ids)
    env.option_ids = list_to_idlist(result)
    env.desc_by_lang = dict_to_strdict(obj.desc_by_lang)
    env.name_by_lang = dict_to_strdict(obj.name_by_lang)

    return env
Пример #5
0
 def test_environment_init(self):
     libcomps_environment = libcomps.Environment("id", "name",
                                                 "description")
     _ = dnf.comps.Environment(iobj=libcomps_environment,
                               langs=None,
                               group_factory=None)