def test_constructor(self): # Test that the new() function works p = Modulemd.Profile.new("testprofile") assert p assert p.props.name == "testprofile" assert p.get_name() == "testprofile" assert p.get_description() is None assert p.get_rpms() == [] # Test that keyword name is accepted p = Modulemd.Profile(name="testprofile") assert p assert p.props.name == "testprofile" assert p.get_name() == "testprofile" assert p.get_description() is None assert p.get_rpms() == [] # Test that we fail without name with self.assertRaises(TypeError) as cm: Modulemd.Profile.new(None) assert "does not allow None as a value" in cm.exception.__str__() with self.expect_signal(): Modulemd.Profile() with self.expect_signal(): Modulemd.Profile(name=None)
def _create_mmd(name, stream, version, rpms=None, profiles=None): rpms = rpms or [] profiles = profiles or {} # profile_name: {pkg_format: [pkg_names]} mmd = Modulemd.Module() mmd.set_mdversion(int(1)) mmd.set_name(str(name)) mmd.set_stream(str(stream)) mmd.set_version(int(version)) sset = Modulemd.SimpleSet() sset.add("LGPLv2") mmd.set_module_licenses(sset) mmd.set_summary(str("Fake module")) mmd.set_description(mmd.peek_summary()) artifacts = Modulemd.SimpleSet() for rpm in rpms: artifacts.add(rpm[:-4]) mmd.set_rpm_artifacts(artifacts) for profile_name in profiles: profile = Modulemd.Profile() profile.set_name(profile_name) profile_rpms = Modulemd.SimpleSet() profile_rpms.set(profiles[profile_name].get("rpms", [])) profile.set_rpms(profile_rpms) mmd.add_profile(profile) return mmd
def add_profiles(self, profiles): for i, values in profiles: name, packages = values profile = Modulemd.Profile(name=name) for package in packages: profile.add_rpm(str(package)) self.mmd.add_profile(profile)
def test_get_name(self): p = Modulemd.Profile(name="testprofile") assert p.get_name() == "testprofile" assert p.props.name == "testprofile" with self.expect_signal(): p.props.name = "notadrill"
def test_get_name(self): p = Modulemd.Profile(name='testprofile') assert p.get_name() == 'testprofile' assert p.props.name == 'testprofile' with self.expect_signal(): p.props.name = 'notadrill'
def test_get_set_description(self): p = Modulemd.Profile(name="testprofile") assert p.get_description() is None p.set_description("foobar") assert p.get_description() == "foobar" p.set_description(None) assert p.get_description() is None
def test_get_set_description(self): p = Modulemd.Profile(name='testprofile') assert p.get_description() is None p.set_description('foobar') assert p.get_description() == 'foobar' p.set_description(None) assert p.get_description() is None
def test_profiles(self): for version in modulestream_versions: stream = Modulemd.ModuleStream.new(version, "sssd") profile = Modulemd.Profile(name="client") profile.add_rpm("sssd-client") stream.add_profile(profile) assert len(stream.get_profile_names()) == 1 assert "client" in stream.get_profile_names() assert "sssd-client" in stream.get_profile("client").get_rpms() stream.clear_profiles() assert len(stream.get_profile_names()) == 0
def test_profiles(self): for version in modulestream_versions: stream = Modulemd.ModuleStream.new(version, 'sssd') profile = Modulemd.Profile(name='client') profile.add_rpm('sssd-client') stream.add_profile(profile) assert len(stream.get_profile_names()) == 1 assert 'client' in stream.get_profile_names() assert 'sssd-client' in stream.get_profile('client').get_rpms() stream.clear_profiles() assert len(stream.get_profile_names()) == 0
def test_rpms(self): p = Modulemd.Profile(name="testprofile") assert p.get_rpms() == [] p.add_rpm("test2") assert p.get_rpms() == ["test2"] p.add_rpm("test3") p.add_rpm("test1") assert p.get_rpms() == ["test1", "test2", "test3"] p.add_rpm("test2") assert p.get_rpms() == ["test1", "test2", "test3"] p.remove_rpm("test1") assert p.get_rpms() == ["test2", "test3"]
def test_rpms(self): p = Modulemd.Profile(name='testprofile') assert p.get_rpms() == [] p.add_rpm('test2') assert p.get_rpms() == ['test2'] p.add_rpm('test3') p.add_rpm('test1') assert p.get_rpms() == ['test1', 'test2', 'test3'] p.add_rpm('test2') assert p.get_rpms() == ['test1', 'test2', 'test3'] p.remove_rpm('test1') assert p.get_rpms() == ['test2', 'test3']
def test_copy(self): p_orig = Modulemd.Profile(name="testprofile") p = p_orig.copy() assert p assert p.props.name == "testprofile" assert p.get_name() == "testprofile" assert p.get_description() is None assert p.get_rpms() == [] p_orig.set_description("Test profile") p.add_rpm("test2") p.add_rpm("test3") p.add_rpm("test1") p = p_orig.copy() assert p assert p.props.name == "testprofile" assert p.get_name() == "testprofile" assert p.get_description() == "Test profile" assert p.get_rpms() == ["test1", "test2", "test3"]
def test_copy(self): p_orig = Modulemd.Profile(name='testprofile') p = p_orig.copy() assert p assert p.props.name == 'testprofile' assert p.get_name() == 'testprofile' assert p.get_description() is None assert p.get_rpms() == [] p_orig.set_description('Test profile') p.add_rpm('test2') p.add_rpm('test3') p.add_rpm('test1') p = p_orig.copy() assert p assert p.props.name == 'testprofile' assert p.get_name() == 'testprofile' assert p.get_description() == 'Test profile' assert p.get_rpms() == ['test1', 'test2', 'test3']
def _create_mmd(name, stream, version, rpms=None, profiles=None): rpms = rpms or [] profiles = profiles or {} # profile_name: {pkg_format: [pkg_names]} mmd = Modulemd.Module() mmd.set_name(str(name)) mmd.set_stream(str(stream)) mmd.set_version(int(version)) licenses = Modulemd.SimpleSet() licenses.add("LGPLv2") mmd.set_module_licenses(licenses) mmd.set_summary(str("Fake module")) mmd.set_description(mmd.get_summary()) for rpm in rpms: mmd.get_rpm_components.add(rpm.rsplit("-", 2)[0], "") mmd.get_rpm_artifacts.add(rpm[:-4]) for profile_name in profiles: profile = Modulemd.Profile() for rpm in profiles[profile_name].get("rpms", []): profile.add_rpm(rpm) profile.set_name(profile_name) mmd.add_profile(profile) return mmd
rpms_with_epoch.append(nevra) rpms = rpms_with_epoch mmd = Modulemd.Module() mmd.set_mdversion(int(1)) mmd.set_name(name) mmd.set_stream(stream) mmd.set_version(int(version)) sset = Modulemd.SimpleSet() sset.add("LGPLv2") mmd.set_module_licenses(sset) mmd.set_summary("Fake module") mmd.set_description(mmd.peek_summary()) artifacts = Modulemd.SimpleSet() for rpm in rpms: artifacts.add(rpm[:-4]) mmd.set_rpm_artifacts(artifacts) for profile_name in profiles: profile = Modulemd.Profile() profile.set_name(profile_name) profile.set_description("Description for profile %s." % profile_name) profile_rpms = Modulemd.SimpleSet() profile_rpms.set(profiles[profile_name]["rpms"]) profile.set_rpms(profile_rpms) mmd.add_profile(profile) Modulemd.dump([mmd], os.path.join(module_dir, "%s.%s.yaml" % (module_id, arch)))