def populate(db): user = User(name=u'guest') db.add(user) anonymous = User(name=u'anonymous') db.add(anonymous) provenpackager = Group(name=u'provenpackager') db.add(provenpackager) packager = Group(name=u'packager') db.add(packager) db.flush() user.groups.append(packager) release = Release( name=u'F17', long_name=u'Fedora 17', id_prefix=u'FEDORA', version=u'17', dist_tag=u'f17', stable_tag=u'f17-updates', testing_tag=u'f17-updates-testing', candidate_tag=u'f17-updates-candidate', pending_testing_tag=u'f17-updates-testing-pending', pending_stable_tag=u'f17-updates-pending', override_tag=u'f17-override', branch=u'f17') db.add(release) pkg = Package(name=u'bodhi') db.add(pkg) user.packages.append(pkg) build = Build(nvr=u'bodhi-2.0-1.fc17', release=release, package=pkg) db.add(build) testcase = TestCase(name=u'Wat') db.add(testcase) pkg.test_cases.append(testcase) update = Update( title=u'bodhi-2.0-1.fc17', builds=[build], user=user, request=UpdateRequest.testing, notes=u'Useful details!', release=release, date_submitted=datetime(1984, 11, 02), requirements=u'rpmlint', stable_karma=3, unstable_karma=-3, ) update.type = UpdateType.bugfix bug = Bug(bug_id=12345) db.add(bug) update.bugs.append(bug) cve = CVE(cve_id=u"CVE-1985-0110") db.add(cve) update.cves.append(cve) comment = Comment(karma=1, text=u"wow. amaze.") db.add(comment) comment.user = user update.comments.append(comment) update.karma = 1 comment = Comment(karma=0, text=u"srsly. pretty good.", anonymous=True) comment.user = anonymous db.add(comment) update.comments.append(comment) with mock.patch(target='uuid.uuid4', return_value='wat'): update.assign_alias() db.add(update) expiration_date = datetime.utcnow() expiration_date = expiration_date + timedelta(days=1) override = BuildrootOverride(build=build, submitter=user, notes=u'blah blah blah', expiration_date=expiration_date) db.add(override) db.flush()
def test_metadata_updating_with_old_testing_security(self): update = self.db.query(Update).one() update.request = None update.type = UpdateType.security update.status = UpdateStatus.testing update.date_pushed = datetime.utcnow() DevBuildsys.__tagged__[update.title] = ["f17-updates-testing"] # Generate the XML md = ExtendedMetadata(update.release, UpdateRequest.testing, self.db, self.temprepo) # Insert the updateinfo.xml into the repository md.insert_updateinfo() md.cache_repodata() updateinfo = self._verify_updateinfo(self.repodata) # Read an verify the updateinfo.xml.gz uinfo = createrepo_c.UpdateInfo(updateinfo) notice = self.get_notice(uinfo, update.title) self.assertIsNotNone(notice) # Create a new non-security update for the same package newbuild = "bodhi-2.0-2.fc17" pkg = self.db.query(Package).filter_by(name=u"bodhi").one() build = Build(nvr=newbuild, package=pkg) self.db.add(build) self.db.flush() newupdate = Update( title=newbuild, type=UpdateType.enhancement, status=UpdateStatus.testing, request=None, release=update.release, builds=[build], notes=u"x", ) newupdate.assign_alias() self.db.add(newupdate) self.db.flush() # Untag the old security build del (DevBuildsys.__tagged__[update.title]) DevBuildsys.__untag__.append(update.title) DevBuildsys.__tagged__[newupdate.title] = [newupdate.release.testing_tag] buildrpms = DevBuildsys.__rpms__[0].copy() buildrpms["nvr"] = "bodhi-2.0-2.fc17" buildrpms["release"] = "2.fc17" DevBuildsys.__rpms__.append(buildrpms) del (DevBuildsys.__rpms__[0]) # Re-initialize our temporary repo shutil.rmtree(self.temprepo) os.mkdir(self.temprepo) mkmetadatadir(join(self.temprepo, "f17-updates-testing", "i386")) md = ExtendedMetadata(update.release, UpdateRequest.testing, self.db, self.temprepo) md.insert_updateinfo() updateinfo = self._verify_updateinfo(self.repodata) # Read an verify the updateinfo.xml.gz uinfo = createrepo_c.UpdateInfo(updateinfo) self.assertEquals(len(uinfo.updates), 1) notice = self.get_notice(uinfo, "bodhi-2.0-1.fc17") self.assertIsNone(notice) notice = self.get_notice(uinfo, "bodhi-2.0-2.fc17") self.assertIsNotNone(notice)
def test_metadata_updating_with_old_testing_security(self): update = self.db.query(Update).one() update.request = None update.type = UpdateType.security update.status = UpdateStatus.testing update.date_pushed = datetime.utcnow() DevBuildsys.__tagged__[update.title] = ['f17-updates-testing'] # Generate the XML md = ExtendedMetadata(update.release, UpdateRequest.testing, self.db, self.temprepo) # Insert the updateinfo.xml into the repository md.insert_updateinfo() md.cache_repodata() updateinfo = self._verify_updateinfo(self.repodata) # Read an verify the updateinfo.xml.gz uinfo = createrepo_c.UpdateInfo(updateinfo) notice = self.get_notice(uinfo, update.title) self.assertIsNotNone(notice) # Create a new non-security update for the same package newbuild = 'bodhi-2.0-2.fc17' pkg = self.db.query(Package).filter_by(name=u'bodhi').one() build = Build(nvr=newbuild, package=pkg) self.db.add(build) self.db.flush() newupdate = Update(title=newbuild, type=UpdateType.enhancement, status=UpdateStatus.testing, request=None, release=update.release, builds=[build], notes=u'x') newupdate.assign_alias() self.db.add(newupdate) self.db.flush() # Untag the old security build del (DevBuildsys.__tagged__[update.title]) DevBuildsys.__untag__.append(update.title) DevBuildsys.__tagged__[newupdate.title] = [ newupdate.release.testing_tag ] buildrpms = DevBuildsys.__rpms__[0].copy() buildrpms['nvr'] = 'bodhi-2.0-2.fc17' buildrpms['release'] = '2.fc17' DevBuildsys.__rpms__.append(buildrpms) del (DevBuildsys.__rpms__[0]) # Re-initialize our temporary repo shutil.rmtree(self.temprepo) os.mkdir(self.temprepo) mkmetadatadir(join(self.temprepo, 'f17-updates-testing', 'i386')) md = ExtendedMetadata(update.release, UpdateRequest.testing, self.db, self.temprepo) md.insert_updateinfo() updateinfo = self._verify_updateinfo(self.repodata) # Read an verify the updateinfo.xml.gz uinfo = createrepo_c.UpdateInfo(updateinfo) self.assertEquals(len(uinfo.updates), 1) notice = self.get_notice(uinfo, 'bodhi-2.0-1.fc17') self.assertIsNone(notice) notice = self.get_notice(uinfo, 'bodhi-2.0-2.fc17') self.assertIsNotNone(notice)
def populate(db): user = User(name=u'guest') db.add(user) anonymous = User(name=u'anonymous') db.add(anonymous) provenpackager = Group(name=u'provenpackager') db.add(provenpackager) packager = Group(name=u'packager') db.add(packager) db.flush() user.groups.append(packager) release = Release(name=u'F17', long_name=u'Fedora 17', id_prefix=u'FEDORA', version=u'17', dist_tag=u'f17', stable_tag=u'f17-updates', testing_tag=u'f17-updates-testing', candidate_tag=u'f17-updates-candidate', pending_testing_tag=u'f17-updates-testing-pending', pending_stable_tag=u'f17-updates-pending', override_tag=u'f17-override', branch=u'f17') db.add(release) pkg = Package(name=u'bodhi') db.add(pkg) user.packages.append(pkg) build = Build(nvr=u'bodhi-2.0-1.fc17', release=release, package=pkg) db.add(build) testcase = TestCase(name=u'Wat') db.add(testcase) pkg.test_cases.append(testcase) update = Update( title=u'bodhi-2.0-1.fc17', builds=[build], user=user, request=UpdateRequest.testing, notes=u'Useful details!', release=release, date_submitted=datetime(1984, 11, 02), requirements=u'rpmlint', stable_karma=3, unstable_karma=-3, ) update.type = UpdateType.bugfix bug = Bug(bug_id=12345) db.add(bug) update.bugs.append(bug) cve = CVE(cve_id=u"CVE-1985-0110") db.add(cve) update.cves.append(cve) comment = Comment(karma=1, text=u"wow. amaze.") db.add(comment) comment.user = user update.comments.append(comment) update.karma = 1 comment = Comment(karma=0, text=u"srsly. pretty good.", anonymous=True) comment.user = anonymous db.add(comment) update.comments.append(comment) with mock.patch(target='uuid.uuid4', return_value='wat'): update.assign_alias() db.add(update) expiration_date = datetime.utcnow() expiration_date = expiration_date + timedelta(days=1) override = BuildrootOverride(build=build, submitter=user, notes=u'blah blah blah', expiration_date=expiration_date) db.add(override) db.flush()
def test_metadata_updating_with_old_stable_security(self): update = self.db.query(Update).one() update.request = None update.type = UpdateType.security update.status = UpdateStatus.stable update.date_pushed = datetime.utcnow() DevBuildsys.__tagged__[update.title] = ['f17-updates'] repo = join(self.tempdir, 'f17-updates') mkmetadatadir(join(repo, 'f17-updates', 'i386')) self.repodata = join(repo, 'f17-updates', 'i386', 'repodata') # Generate the XML md = ExtendedMetadata(update.release, UpdateRequest.stable, self.db, repo) # Insert the updateinfo.xml into the repository md.insert_updateinfo() md.cache_repodata() updateinfo = self._verify_updateinfo(self.repodata) # Read an verify the updateinfo.xml.gz uinfo = createrepo_c.UpdateInfo(updateinfo) notice = self.get_notice(uinfo, update.title) self.assertIsNotNone(notice) # Create a new non-security update for the same package newbuild = 'bodhi-2.0-2.fc17' pkg = self.db.query(Package).filter_by(name=u'bodhi').one() build = Build(nvr=newbuild, package=pkg) self.db.add(build) self.db.flush() newupdate = Update(title=newbuild, type=UpdateType.enhancement, status=UpdateStatus.stable, request=None, release=update.release, builds=[build], notes=u'x') newupdate.assign_alias() self.db.add(newupdate) self.db.flush() # Untag the old security build DevBuildsys.__untag__.append(update.title) DevBuildsys.__tagged__[newupdate.title] = [newupdate.release.stable_tag] buildrpms = DevBuildsys.__rpms__[0].copy() buildrpms['nvr'] = 'bodhi-2.0-2.fc17' buildrpms['release'] = '2.fc17' DevBuildsys.__rpms__.append(buildrpms) # Re-initialize our temporary repo shutil.rmtree(repo) os.mkdir(repo) mkmetadatadir(join(repo, 'f17-updates', 'i386')) md = ExtendedMetadata(update.release, UpdateRequest.stable, self.db, repo) md.insert_updateinfo() updateinfo = self._verify_updateinfo(self.repodata) # Read an verify the updateinfo.xml.gz uinfo = createrepo_c.UpdateInfo(updateinfo) self.assertEquals(len(uinfo.updates), 2) notice = self.get_notice(uinfo, 'bodhi-2.0-1.fc17') self.assertIsNotNone(notice) notice = self.get_notice(uinfo, 'bodhi-2.0-2.fc17') self.assertIsNotNone(notice)