Пример #1
0
    def test_rpm_with_arch(self):
        """Ensure that an RPM with a non 386 arch gets handled correctly."""
        update = self.db.query(Update).one()
        md = UpdateInfoMetadata(update.release,
                                update.request,
                                self.db,
                                self.temprepo,
                                close_shelf=False)
        # Set the arch to aarch64
        fake_rpms = [{
            'nvr': 'TurboGears-1.0.2.2-2.fc17',
            'buildtime': 1178868422,
            'arch': 'aarch64',
            'id': 62330,
            'size': 761742,
            'build_id': 6475,
            'name': 'TurboGears',
            'epoch': None,
            'version': '1.0.2.2',
            'release': '2.fc17',
            'buildroot_id': 1883,
            'payloadhash': '6787febe92434a9be2a8f309d0e2014e'
        }]

        with mock.patch.object(md, 'get_rpms',
                               mock.MagicMock(return_value=fake_rpms)):
            md.add_update(update)

        md.shelf.close()
        col = md.uinfo.updates[0].collections[0]
        self.assertEqual(len(col.packages), 1)
        pkg = col.packages[0]
        self.assertEquals(pkg.src, (
            'https://download.fedoraproject.org/pub/fedora/linux/updates/17/aarch64/T/'
            'TurboGears-1.0.2.2-2.fc17.aarch64.rpm'))
Пример #2
0
    def test_rpm_with_epoch(self):
        """Ensure that an RPM with an Epoch gets handled correctly."""
        update = self.db.query(Update).one()
        md = UpdateInfoMetadata(update.release,
                                update.request,
                                self.db,
                                self.temprepo,
                                close_shelf=False)
        # We'll fake the return of get_rpms so we can inject an epoch of 42.
        fake_rpms = [{
            'nvr': 'TurboGears-1.0.2.2-2.fc17',
            'buildtime': 1178868422,
            'arch': 'src',
            'id': 62330,
            'size': 761742,
            'build_id': 6475,
            'name': 'TurboGears',
            'epoch': 42,
            'version': '1.0.2.2',
            'release': '2.fc17',
            'buildroot_id': 1883,
            'payloadhash': '6787febe92434a9be2a8f309d0e2014e'
        }]

        with mock.patch.object(md, 'get_rpms',
                               mock.MagicMock(return_value=fake_rpms)):
            md.add_update(update)

        md.shelf.close()
        col = md.uinfo.updates[0].collections[0]
        self.assertEqual(len(col.packages), 1)
        pkg = col.packages[0]
        self.assertEqual(pkg.epoch, '42')
Пример #3
0
    def test_build_not_in_builds(self):
        """
        Test correct behavior when a build in update.builds isn't found in self.builds() and
        koji.getBuild() is called instead.
        """
        update = self.db.query(Update).one()
        now = datetime(year=2018, month=2, day=8, hour=12, minute=41, second=4)
        update.date_pushed = now
        update.date_modified = now
        md = UpdateInfoMetadata(update.release, update.request, self.db, self.temprepo,
                                close_shelf=False)

        md.add_update(update)

        md.shelf.close()

        assert len(md.uinfo.updates) == 1
        assert md.uinfo.updates[0].title == update.title
        assert md.uinfo.updates[0].release == update.release.long_name
        assert md.uinfo.updates[0].status == update.status.value
        assert md.uinfo.updates[0].updated_date == update.date_modified
        assert md.uinfo.updates[0].fromstr == config.get('bodhi_email')
        assert md.uinfo.updates[0].rights == config.get('updateinfo_rights')
        assert md.uinfo.updates[0].description == update.notes
        assert md.uinfo.updates[0].id == update.alias
        assert md.uinfo.updates[0].severity == 'Moderate'
        assert len(md.uinfo.updates[0].references) == 1
        bug = md.uinfo.updates[0].references[0]
        assert bug.href == update.bugs[0].url
        assert bug.id == '12345'
        assert bug.type == 'bugzilla'
        assert len(md.uinfo.updates[0].collections) == 1
        col = md.uinfo.updates[0].collections[0]
        assert col.name == update.release.long_name
        assert col.shortname == update.release.name
        assert len(col.packages) == 2
        pkg = col.packages[0]
        assert pkg.epoch == '0'
        # It's a little goofy, but the DevBuildsys is going to return TurboGears rpms when its
        # listBuildRPMs() method is called, so let's just roll with it.
        assert pkg.name == 'TurboGears'
        assert pkg.src == \
            ('https://download.fedoraproject.org/pub/fedora/linux/updates/17/SRPMS/T/'
             'TurboGears-1.0.2.2-2.fc17.src.rpm')
        assert pkg.version == '1.0.2.2'
        assert not pkg.reboot_suggested
        assert pkg.arch == 'src'
        assert pkg.filename == 'TurboGears-1.0.2.2-2.fc17.src.rpm'
        pkg = col.packages[1]
        assert pkg.epoch == '0'
        assert pkg.name == 'TurboGears'
        assert pkg.src == \
            ('https://download.fedoraproject.org/pub/fedora/linux/updates/17/i386/T/'
             'TurboGears-1.0.2.2-2.fc17.noarch.rpm')
        assert pkg.version == '1.0.2.2'
        assert not pkg.reboot_suggested
        assert pkg.arch == 'noarch'
        assert pkg.filename == 'TurboGears-1.0.2.2-2.fc17.noarch.rpm'
Пример #4
0
    def test_date_pushed_none(self):
        """The metadata should use utcnow() if an update's date_pushed is None."""
        update = self.db.query(Update).one()
        update.date_pushed = None
        md = UpdateInfoMetadata(update.release, update.request, self.db, self.temprepo,
                                close_shelf=False)

        md.add_update(update)

        md.shelf.close()
        self.assertEqual(len(md.uinfo.updates), 1)
        self.assertTrue(abs((datetime.utcnow() - md.uinfo.updates[0].issued_date).seconds) < 2)
Пример #5
0
    def test_date_pushed_none(self):
        """The metadata should use date_submitted if an update's date_pushed is None."""
        update = self.db.query(Update).one()
        update.date_pushed = None
        md = UpdateInfoMetadata(update.release,
                                update.request,
                                self.db,
                                self.temprepo,
                                close_shelf=False)
        md.add_update(update)
        md.shelf.close()

        assert len(md.uinfo.updates) == 1
        assert md.uinfo.updates[0].issued_date == update.date_submitted
Пример #6
0
    def test_date_pushed_none(self):
        """The metadata should use utcnow() if an update's date_pushed is None."""
        test_start_time = datetime.utcnow()
        # The UpdateRecord's updated_date attribute strips microseconds, so let's force them to 0
        # so our assertions at the end of this test will pass.
        test_start_time = test_start_time - timedelta(microseconds=test_start_time.microsecond)
        update = self.db.query(Update).one()
        update.date_pushed = None
        md = UpdateInfoMetadata(update.release, update.request, self.db, self.temprepo,
                                close_shelf=False)

        md.add_update(update)

        md.shelf.close()
        assert len(md.uinfo.updates) == 1
        assert test_start_time <= md.uinfo.updates[0].issued_date <= datetime.utcnow()
Пример #7
0
    def test_build_not_in_builds(self):
        """
        Test correct behavior when a build in update.builds isn't found in self.builds() and
        koji.getBuild() is called instead.
        """
        update = self.db.query(Update).one()
        now = datetime(year=2018, month=2, day=8, hour=12, minute=41, second=4)
        update.date_pushed = now
        update.date_modified = now
        md = UpdateInfoMetadata(update.release,
                                update.request,
                                self.db,
                                self.temprepo,
                                close_shelf=False)

        md.add_update(update)

        md.shelf.close()

        self.assertEqual(len(md.uinfo.updates), 1)
        self.assertEquals(md.uinfo.updates[0].title, update.title)
        self.assertEquals(md.uinfo.updates[0].release,
                          update.release.long_name)
        self.assertEquals(md.uinfo.updates[0].status, update.status.value)
        self.assertEquals(md.uinfo.updates[0].updated_date,
                          update.date_modified)
        self.assertEquals(md.uinfo.updates[0].fromstr,
                          config.get('bodhi_email'))
        self.assertEquals(md.uinfo.updates[0].rights,
                          config.get('updateinfo_rights'))
        self.assertEquals(md.uinfo.updates[0].description, update.notes)
        self.assertEquals(md.uinfo.updates[0].id, update.alias)
        self.assertEquals(md.uinfo.updates[0].severity, 'Moderate')
        self.assertEqual(len(md.uinfo.updates[0].references), 2)
        bug = md.uinfo.updates[0].references[0]
        self.assertEquals(bug.href, update.bugs[0].url)
        self.assertEquals(bug.id, '12345')
        self.assertEquals(bug.type, 'bugzilla')
        cve = md.uinfo.updates[0].references[1]
        self.assertEquals(cve.type, 'cve')
        self.assertEquals(cve.href, update.cves[0].url)
        self.assertEquals(cve.id, update.cves[0].cve_id)
        self.assertEqual(len(md.uinfo.updates[0].collections), 1)
        col = md.uinfo.updates[0].collections[0]
        self.assertEquals(col.name, update.release.long_name)
        self.assertEquals(col.shortname, update.release.name)
        self.assertEqual(len(col.packages), 2)
        pkg = col.packages[0]
        self.assertEquals(pkg.epoch, '0')
        # It's a little goofy, but the DevBuildsys is going to return TurboGears rpms when its
        # listBuildRPMs() method is called, so let's just roll with it.
        self.assertEquals(pkg.name, 'TurboGears')
        self.assertEquals(pkg.src, (
            'https://download.fedoraproject.org/pub/fedora/linux/updates/17/SRPMS/T/'
            'TurboGears-1.0.2.2-2.fc17.src.rpm'))
        self.assertEquals(pkg.version, '1.0.2.2')
        self.assertFalse(pkg.reboot_suggested)
        self.assertEquals(pkg.arch, 'src')
        self.assertEquals(pkg.filename, 'TurboGears-1.0.2.2-2.fc17.src.rpm')
        pkg = col.packages[1]
        self.assertEquals(pkg.epoch, '0')
        self.assertEquals(pkg.name, 'TurboGears')
        self.assertEquals(pkg.src, (
            'https://download.fedoraproject.org/pub/fedora/linux/updates/17/i386/T/'
            'TurboGears-1.0.2.2-2.fc17.noarch.rpm'))
        self.assertEquals(pkg.version, '1.0.2.2')
        self.assertFalse(pkg.reboot_suggested)
        self.assertEquals(pkg.arch, 'noarch')
        self.assertEquals(pkg.filename, 'TurboGears-1.0.2.2-2.fc17.noarch.rpm')