def test_associate_package(self): pack = ContentPackage() pack.setNVREA('name1', 'version1', 'release1', 'epoch1', 'arch1') pack.unique_id = 1 pack.a_pkg = rhn_rpm.RPM_Package(None) pack.a_pkg.checksum = 'checksum1' pack.a_pkg.checksum_type = 'c_type1' pack.a_pkg.header = {'epoch': 'epoch1'} pack.checksums[1] = 'checksum1' mocked_backend = Mock() self.reposync.SQLBackend = Mock(return_value=mocked_backend) rs = self._create_mocked_reposync() rs._importer_run = Mock() rs.channel_label = 'Label1' rs.channel = {'id': 'channel1', 'org_id': 1} package = { 'name': 'name1', 'version': 'version1', 'release': 'release1', 'epoch': 'epoch1', 'arch': 'arch1', 'checksum': 'checksum1', 'checksum_type': 'c_type1', 'org_id': 1, 'channels': [{ 'label': 'Label1', 'id': 'channel1' }] } refpack = importLib.IncompletePackage().populate(package) ipack = rs.associate_package(pack) self.assertEqual(ipack, refpack)
def package_from_stream(stream, packaging): if packaging == 'deb': from uyuni.common import rhn_deb a_pkg = rhn_deb.DEB_Package(stream) elif packaging == 'rpm': from uyuni.common import rhn_rpm a_pkg = rhn_rpm.RPM_Package(stream) elif packaging == 'mpm': from uyuni.common import rhn_mpm a_pkg = rhn_mpm.MPM_Package(stream) else: a_pkg = None return a_pkg