def test_parse_NVRA(self): """Test the parse_NVRA method""" self.assertRaises(AttributeError, koji.parse_NVRA, None) self.assertRaises(AttributeError, koji.parse_NVRA, 1) self.assertRaises(AttributeError, koji.parse_NVRA, {}) self.assertRaises(AttributeError, koji.parse_NVRA, []) self.assertRaises(koji.GenericError, koji.parse_NVRA, "") self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo") self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo-1") self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo-1-") self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo--1") self.assertRaises(koji.GenericError, koji.parse_NVRA, "--1") self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo-1-1") self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo-1-1.") self.assertRaises(koji.GenericError, koji.parse_NVRA, "foo-1.-1") ret = koji.parse_NVRA("foo-1-2.i386") self.assertEqual(ret['name'], "foo") self.assertEqual(ret['version'], "1") self.assertEqual(ret['release'], "2") self.assertEqual(ret['epoch'], "") self.assertEqual(ret['arch'], "i386") self.assertEqual(ret['src'], False) ret = koji.parse_NVRA("12:foo-1-2.src") self.assertEqual(ret['name'], "foo") self.assertEqual(ret['version'], "1") self.assertEqual(ret['release'], "2") self.assertEqual(ret['epoch'], "12") self.assertEqual(ret['arch'], "src") self.assertEqual(ret['src'], True)
def assemble_srpm_url(self, base_url, srpm_filename, sign_key=None): """Assemble the URL used to fetch an SRPM file :param base_url: str, Koji root base URL with the given build artifacts :param srpm_filename: str, name of the SRPM file :param sign_key: str, key used to sign the SRPM, as listed in the signing intent :return: list, strings with URLs pointing to SRPM files """ srpm_info = koji.parse_NVRA(srpm_filename) if sign_key: srpm_path = self.pathinfo.signed(srpm_info, sign_key) else: srpm_path = self.pathinfo.rpm(srpm_info) return '/'.join([base_url, srpm_path])
def parsePkg(pkg): pkg = pkg.strip() if koji.check_NVRA(pkg): pkg = koji.parse_NVRA(pkg) return Package(**pkg)