コード例 #1
0
    def test_handleReleaseWithExistingRelease(self):
        # Test that handleRelease() can add a file release to an
        # existing ProductRelease.
        ztm = self.layer.txn

        # verify that a 2.1.6 release of evolution exists without any
        # files attached.
        evo = getUtility(IProductSet).getByName('evolution')
        trunk = evo.getSeries('trunk')
        release = trunk.getRelease('2.1.6')
        self.assertNotEqual(release, None)
        self.assertEqual(release.files.count(), 0)
        ztm.abort()

        logging.basicConfig(level=logging.CRITICAL)
        prf = ProductReleaseFinder(ztm, logging.getLogger())
        file_path, file_name = self.create_tarball('evolution-2.1.6.tar.gz')
        file_names = prf.getReleaseFileNames('evolution')
        prf.handleRelease('evolution', 'trunk', file_path, file_names)

        # verify that we now have files attached to the release:
        evo = getUtility(IProductSet).getByName('evolution')
        trunk = evo.getSeries('trunk')
        release = trunk.getRelease('2.1.6')
        self.assertEqual(release.files.count(), 1)
コード例 #2
0
    def test_handleRelease(self):
        ztm = self.layer.txn
        logging.basicConfig(level=logging.CRITICAL)
        prf = ProductReleaseFinder(ztm, logging.getLogger())
        alt_file_name = 'evolution-42.0.orig.tar.bz2'
        file_path, file_name = self.create_tarball(
            'evolution-42.0.orig.tar.gz')
        file_names = set()
        prf.handleRelease('evolution', 'trunk', file_path, file_names)
        self.assertTrue(file_name in file_names)
        self.assertFalse(alt_file_name in file_names)

        # check to see that the release has been created
        evo = getUtility(IProductSet).getByName('evolution')
        trunk = evo.getSeries('trunk')
        release = trunk.getRelease('42.0')
        self.assertNotEqual(release, None)
        self.assertEqual(release.files.count(), 1)
        fileinfo = release.files[0]
        self.assertEqual(fileinfo.filetype, UpstreamFileType.CODETARBALL)
        self.assertEqual(fileinfo.libraryfile.filename, file_name)

        # verify that the fileinfo object is sane
        self.failUnless(verifyObject(IProductReleaseFile, fileinfo))
        for field in getFields(IProductReleaseFile).values():
            # XXX: BradCrittenden 2008-09-04 bug=264829:
            # Several interfaces have uploaded files as `Bytes` attributes but
            # then the values get converted to LibraryFileAlias objects.  The
            # Bytes._validate() method then fails.  As a work-around the
            # validate test is being disabled here for those fields.
            from zope.schema import Bytes
            if isinstance(field, Bytes):
                continue
            bound = field.bind(fileinfo)
            bound.validate(bound.get(fileinfo))
コード例 #3
0
 def test_handleReleaseTwice_multiple_series(self):
     # Series can have overlaping release file globs, but versions
     # are unique to a project. A file is uploaded to a release only
     # once, regardless of which series wants the upload.
     ztm = self.layer.txn
     logging.basicConfig(level=logging.CRITICAL)
     prf = ProductReleaseFinder(ztm, logging.getLogger())
     file_path, file_name = self.create_tarball('evolution-1.2.3.tar.gz')
     file_names = prf.getReleaseFileNames('evolution')
     prf.handleRelease('evolution', 'trunk', file_path, file_names)
     file_path, file_name = self.create_tarball('evolution-1.2.3.tar.gz')
     prf.handleRelease('evolution', '1.0', file_path, file_names)
     product = getUtility(IProductSet).getByName('evolution')
     release = product.getMilestone('1.2.3').product_release
     self.assertEqual(release.files.count(), 1)
コード例 #4
0
 def test_handleReleaseTwice(self):
     # Test that handleRelease() handles the case where a tarball
     # has already been attached to the ProductRelease.  We do this
     # by calling handleRelease() twice.
     ztm = self.layer.txn
     logging.basicConfig(level=logging.CRITICAL)
     prf = ProductReleaseFinder(ztm, logging.getLogger())
     file_path, file_name = self.create_tarball('evolution-42.0.tar.gz')
     file_names = prf.getReleaseFileNames('evolution')
     prf.handleRelease('evolution', 'trunk', file_path, file_names)
     prf.handleRelease('evolution', 'trunk', file_path, file_names)
     evo = getUtility(IProductSet).getByName('evolution')
     trunk = evo.getSeries('trunk')
     release = trunk.getRelease('42.0')
     self.assertEqual(release.files.count(), 1)
コード例 #5
0
 def test_handleRelease_alternate_verstion(self):
     """Verify that tar.gz and tar.bz2 versions are both uploaded."""
     ztm = self.layer.txn
     logging.basicConfig(level=logging.CRITICAL)
     prf = ProductReleaseFinder(ztm, logging.getLogger())
     file_path, file_name = self.create_tarball('evolution-45.0.tar.gz')
     alt_file_path, alt_file_name = self.create_tarball(
         'evolution-45.0.tar.bz2')
     file_names = prf.getReleaseFileNames('evolution')
     prf.handleRelease('evolution', 'trunk', file_path, file_names)
     prf.handleRelease('evolution', 'trunk', alt_file_path, file_names)
     evo = getUtility(IProductSet).getByName('evolution')
     trunk = evo.getSeries('trunk')
     release = trunk.getRelease('45.0')
     release_filenames = [file_info.libraryfile.filename
                          for file_info in release.files]
     self.assertEqual(len(release_filenames), 2)
     self.assertTrue(file_name in release_filenames)
     self.assertTrue(alt_file_name in release_filenames)
コード例 #6
0
    def test_handleReleaseUnableToParseVersion(self):
        # Test that handleRelease() handles the case where a version can't be
        # parsed from the url given.
        ztm = self.layer.txn
        output = StringIO()
        logger = logging.getLogger()
        logger.setLevel(logging.INFO)
        logger.addHandler(logging.StreamHandler(output))
        prf = ProductReleaseFinder(ztm, logger)

        # create a release tarball
        fp = open(os.path.join(
            self.release_root, 'evolution-42.0.tar.gz'), 'w')
        fp.write('foo')
        fp.close()

        url = self.release_url + '/evolution420.tar.gz'
        file_names = prf.getReleaseFileNames('evolution')
        prf.handleRelease('evolution', 'trunk', url, file_names)
        self.assertEqual(
            "Unable to parse version from %s\n" % url, output.getvalue())