Package bodhi :: Package tests :: Module test_metadata
[hide private]
[frames] | no frames]

Source Code for Module bodhi.tests.test_metadata

 1  # $Id: test_metadata.py,v 1.1 2006/12/31 09:10:25 lmacken Exp $ 
 2   
 3  import turbogears 
 4  from turbogears import testutil, database, config 
 5  turbogears.update_config(configfile='dev.cfg', modulename='bodhi.config') 
 6  database.set_db_uri("sqlite:///:memory:") 
 7   
 8  import shutil 
 9  import tempfile 
10   
11  from os.path import join, exists 
12  from bodhi.util import mkmetadatadir, get_nvr 
13  from bodhi.model import (Release, Package, PackageUpdate, Bugzilla, CVE, 
14                           PackageBuild) 
15  from bodhi.buildsys import get_session 
16  from bodhi.metadata import ExtendedMetadata 
17  from yum.update_md import UpdateMetadata 
18   
19   
20 -class TestExtendedMetadata(testutil.DBTest):
21
22 - def test_extended_metadata(self):
23 # grab the name of a build in updates-testing, and create it in our db 24 koji = get_session() 25 builds = koji.listTagged('dist-fc7-updates-testing', latest=True) 26 27 # Create all of the necessary database entries 28 release = Release(name='fc7', long_name='Fedora 7', id_prefix='FEDORA', 29 dist_tag='dist-fc7') 30 package = Package(name=builds[0]['package_name']) 31 build = PackageBuild(nvr=builds[0]['nvr'], package=package) 32 update = PackageUpdate(title=builds[0]['nvr'], 33 release=release, 34 submitter=builds[0]['owner_name'], 35 status='testing', 36 notes='foobar', 37 type='bugfix') 38 update.addPackageBuild(build) 39 bug = Bugzilla(bz_id=1) 40 update.addBugzilla(bug) 41 cve = CVE(cve_id="CVE-2007-0000") 42 update.addCVE(cve) 43 update.assign_id() 44 print update 45 46 ## Initialize our temporary repo 47 temprepo = join(tempfile.mkdtemp('bodhi'), 'f7-updates-testing') 48 print "Inserting updateinfo into temprepo: %s" % temprepo 49 mkmetadatadir(join(temprepo, 'i386')) 50 repodata = join(temprepo, 'i386', 'repodata') 51 assert exists(join(repodata, 'repomd.xml')) 52 53 ## Generate the XML 54 md = ExtendedMetadata(temprepo) 55 56 ## Insert the updateinfo.xml into the repository 57 md.insert_updateinfo() 58 updateinfo = join(repodata, 'updateinfo.xml.gz') 59 assert exists(updateinfo) 60 61 ## Read an verify the updateinfo.xml.gz 62 uinfo = UpdateMetadata() 63 uinfo.add(updateinfo) 64 notice = uinfo.get_notice(('mutt', '1.5.14', '1.fc7')) 65 assert not notice 66 notice = uinfo.get_notice(get_nvr(update.title)) 67 assert notice 68 assert notice['status'] == update.status 69 assert notice['updated'] == update.date_modified 70 assert notice['from'] == str(config.get('release_team_address')) 71 assert notice['description'] == update.notes 72 assert notice['issued'] == 'None' 73 assert notice['update_id'] == update.update_id 74 cve = notice['references'][0] 75 assert cve['type'] == 'cve' 76 assert cve['href'] == update.cves[0].get_url() 77 assert cve['id'] == update.cves[0].cve_id 78 bug = notice['references'][1] 79 assert bug['href'] == update.bugs[0].get_url() 80 assert bug['id'] == '1' 81 assert bug['type'] == 'bugzilla' 82 83 # FC6's yum update metadata parser doesn't know about some stuff 84 from yum import __version__ 85 if __version__ != '3.0.6': 86 assert notice['title'] == update.title 87 assert notice['release'] == update.release.long_name 88 assert cve['title'] == None 89 assert bug['title'] == 'None' 90 91 ## Clean up 92 shutil.rmtree(temprepo)
93