Example #1
0
 def test_dump(self):
     mmd = modulemd.ModuleMetadata()
     mmd.mdversion = 0
     mmd.name = "test"
     mmd.version = "1.23"
     mmd.release = "4"
     mmd.summary = "A test module"
     mmd.description = "This module is a part of the modulemd test suite."
     mmd.add_module_license("MIT")
     mmd.add_content_license("GPL+")
     mmd.add_content_license("GPLv3")
     mmd.add_buildrequires("example", "84-84")
     mmd.add_requires("modulemd", "42-42")
     mmd.community = "http://www.example.com/community"
     mmd.documentation = "http://www.example.com/documentation"
     mmd.tracker = "http://www.example.com/tracker"
     mmd.xmd = {"userid": "userdata"}
     mmd.profiles = {
         "default": modulemd.ModuleProfile(),
         "minimal": modulemd.ModuleProfile()
     }
     mmd.profiles["default"].rpms = set(["alfa", "alfa-subpackage"])
     mmd.profiles["minimal"].rpms = set(["alfa"])
     mmd.profiles[
         "minimal"].description = "Minimal profile installing only the alfa package."
     mmd.components = modulemd.ModuleComponents()
     mmd.components.rpms = modulemd.ModuleRPMs()
     mmd.components.rpms.dependencies = True
     mmd.components.rpms.add_api("alfa")
     mmd.components.rpms.add_api("alfa-extras")
     mmd.components.rpms.add_package("alfa", rationale="alfa rationale")
     mmd.components.rpms.add_package("bravo",
                                     rationale="bravo rationale",
                                     arches=["charlie", "delta"],
                                     multilib=["echo"],
                                     commit="foxtrot",
                                     repository="golf",
                                     cache="hotel")
     mmd.components.rpms.add_filter("filter_1")
     mmd.components.rpms.add_filter("filter_2")
     mmd.dump("tests/dump.yaml")
     self.test_load(filename="tests/dump.yaml")
Example #2
0
 def setUpClass(cls):
     cls.mmd = modulemd.ModuleMetadata()
     cls.mmd.name = "test"
     cls.mmd.version = "42"
     cls.mmd.release = "1"
     cls.mmd.summary = "A test module"
     cls.mmd.description = "It's only used for testing purposes."
     cls.mmd.module_licenses = set(["MIT"])
     cls.mmd.content_licenses = set(["ISC"])
     cls.mmd.buildrequires = {"builddepenency": "123-456"}
     cls.mmd.requires = {"dependency": "1.00-1"}
     cls.mmd.community = "http://www.example.com/community"
     cls.mmd.documentation = "http://www.example.com/documentation"
     cls.mmd.tracker = "http://www.example.com/tracker"
     cls.mmd.xmd = {"key": "value"}
     cls.mmd.profiles = {"default": modulemd.ModuleProfile()}
     cls.mmd.profiles["default"].rpms = set(["prof", "ile"])
     cls.mmd.profiles["default"].description = "Default set of packages"
     cls.mmd.components = modulemd.ModuleComponents()
     cls.mmd.components.rpms = modulemd.ModuleRPMs()
     cls.mmd.components.rpms.dependencies = True
     cls.mmd.components.rpms.api = set(["api"])
     cls.mmd.components.rpms.packages = {"rpm": {"rationale": ""}}
     cls.mmd.components.rpms.filter = set(["filter_1", "filter_2"])
Example #3
0
 def test_validate_profiles7(self):
     self.mmd.profiles = {"foo": modulemd.ModuleProfile()}
     self.mmd.profiles["foo"]._description = 1
     self.assertRaises(TypeError, self.mmd.validate)
Example #4
0
 def test_validate_profiles5(self):
     self.mmd.profiles = {"foo": modulemd.ModuleProfile()}
     self.mmd.profiles["foo"]._rpms = set([1, 2, 3])
     self.assertRaises(TypeError, self.mmd.validate)
Example #5
0
 def test_validate_profiles2(self):
     self.mmd.profiles = {1: modulemd.ModuleProfile()}
     self.assertRaises(TypeError, self.mmd.validate)
            ]
        else:
            noarch_rpms = []

        rpms = sorted(set(rpms) | set(noarch_rpms))

        # HACK: force epoch to make test data compatible with libmodulemd >= 1.4.0
        rpms_with_epoch = []
        for i in rpms:
            n, v, ra = i.rsplit("-", 2)
            nevra = "%s-0:%s-%s" % (n, v, ra)
            rpms_with_epoch.append(nevra)
        rpms = rpms_with_epoch

        mmd = modulemd.ModuleMetadata()
        mmd.name = name
        mmd.stream = stream
        mmd.version = int(version)
        mmd.add_module_license("LGPLv2")
        mmd.summary = "Fake module"
        mmd.description = mmd.summary
        for rpm in rpms:
            mmd.components.add_rpm(rpm.rsplit("-", 2)[0], "")
            mmd.artifacts.add_rpm(rpm[:-4])
        for profile_name in profiles:
            profile = modulemd.ModuleProfile()
            profile.rpms.update(profiles[profile_name]["rpms"])
            mmd.profiles[profile_name] = profile

        mmd.dump(os.path.join(module_dir, "%s.%s.yaml" % (module_id, arch)))