extras-repoclosure PackageOwners.py, 1.10, 1.11 PackageOwnersTests.py, 1.5, 1.6

Michael Schwendt (mschwendt) fedora-extras-commits at redhat.com
Fri Aug 17 10:45:58 UTC 2007


Author: mschwendt

Update of /cvs/fedora/extras-repoclosure
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv19345

Modified Files:
	PackageOwners.py PackageOwnersTests.py 
Log Message:
switch to downloading an parsing the pkgdb plain owners output


Index: PackageOwners.py
===================================================================
RCS file: /cvs/fedora/extras-repoclosure/PackageOwners.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- PackageOwners.py	2 Feb 2007 13:26:21 -0000	1.10
+++ PackageOwners.py	17 Aug 2007 10:45:56 -0000	1.11
@@ -23,18 +23,20 @@
 import urllib
 
 class PackageOwners:
-    """interface to Fedora Extras owners/owners.list file"""
+    """interface to Fedora package owners list (and Fedora Extras owners/owners.list file)"""
 
     def __init__(self):
         self.dict = {}
         self.how = 'unknown'
 
 
-    def FromURL(self, retries=3, retrysecs=300, url='http://cvs.fedora.redhat.com/viewcvs/*checkout*/owners/owners.list?root=extras'):
+    def FromURL(self, retries=3, retrysecs=300, url='https://admin.fedoraproject.org/pkgdb/acls/bugzilla?tg_format=plain',domain='fedoraproject.org'):
+        # old url='http://cvs.fedora.redhat.com/viewcvs/*checkout*/owners/owners.list?root=extras'
         self.how = 'url'
         self.url = url
         self.retries = retries
         self.retrysecs = retrysecs
+        self.domain = domain
         return self._refresh()
     
     
@@ -43,6 +45,7 @@
         self.command = command
         self.retries = retries
         self.retrysecs = retrysecs
+        self.domain = ''
         self.workdir = workdir
         self.ownersfile = os.path.join('owners', 'owners.list')
         self.cwdstack = []
@@ -103,6 +106,17 @@
                 continue
             try:
                 (repo,pkgname,summary,emails,qacontact,cc) = line.rstrip().split('|')
+                def fixaddr(a):
+                    # Old Fedora CVS owners.list contains e-mail addresses.
+                    # PkgDb plain output contains usernames only.
+                    if not len(self.domain):
+                        if (a.find('@') < 0):  # unexpected, no addr
+                            raise Exception
+                        return a
+                    if a.find('@') >= 0:  # unexpected, no username
+                        raise Exception
+                    return a+'@'+self.domain
+                
                 addrs = []
                 mailto = '' # primary pkg owner
                 if len(emails):
@@ -112,13 +126,13 @@
                         addrs = addrs[1:]
                     else:
                         mailto = emails
-                if mailto.find('@') < 0:  # owners.list is broken
-                    raise Exception
-                
+                    mailto = fixaddr(mailto)
+
                 ccaddrs = []
                 if len(cc):
                     (ccaddrs) = cc.split(',')
                 addrs += ccaddrs
+                addrs = map(lambda a: fixaddr(a), addrs)
 
                 self.dict[pkgname] = {
                     'mailto' : mailto,


Index: PackageOwnersTests.py
===================================================================
RCS file: /cvs/fedora/extras-repoclosure/PackageOwnersTests.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PackageOwnersTests.py	2 Feb 2007 13:26:21 -0000	1.5
+++ PackageOwnersTests.py	17 Aug 2007 10:45:56 -0000	1.6
@@ -11,7 +11,12 @@
 
 class TestDownloadFromURL(unittest.TestCase):
     def testFromURL(self):
-        po.FromURL(retries=1,retrysecs=1)
+        po.FromURL(retries=1,retrysecs=1,url='https://admin.fedoraproject.org/pkgdb/acls/bugzilla?tg_format=plain',domain='localhost.localdomain')
+
+
+class TestDownloadFromOldURL(unittest.TestCase):
+    def testFromURL(self):
+        po.FromURL(retries=1,retrysecs=1,url='http://cvs.fedora.redhat.com/viewcvs/*checkout*/owners/owners.list?root=extras',domain='')
 
 
 class TestDownloadFromCVS(unittest.TestCase):
@@ -19,7 +24,7 @@
         po.FromCVS(retries=1,retrysecs=1,workdir=os.getcwd())
 
 
-class TestSequenceFunctions(unittest.TestCase):
+class TestSequenceFunctionsOld(unittest.TestCase):
 
     def testowner(self):
         self.assertEqual( po.GetOwner('sylpheed'),
@@ -51,10 +56,46 @@
                           ['fedora-perl-devel-list at redhat.com'] )
 
 
+class TestSequenceFunctions(unittest.TestCase):
+
+    def testowner(self):
+        self.assertEqual( po.GetOwner('sylpheed'),
+                          'mschwendt at localhost.localdomain' )
+
+    def testowners(self):
+        a = po.GetOwners('perl-MailTools')
+        a.sort()
+        b = ['pghmcfc at localhost.localdomain','perl-sig at localhost.localdomain']
+        b.sort()
+        self.assertEqual(a,b)
+    
+    def testownersmultiple(self):
+        po._parse(['Test|testpkg|test desc|owner,co-owner|qa|observer,upstream'])
+        self.assertEqual( po.GetOwner('testpkg'), 'owner at localhost.localdomain')
+
+    def testownersmultiple2(self):
+        a = po.GetOwners('testpkg')
+        a.sort()
+        b = ['owner at localhost.localdomain','co-owner at localhost.localdomain','observer at localhost.localdomain','upstream at localhost.localdomain']
+        b.sort()
+        self.assertEqual(a,b)
+
+    def testwrongpackage(self):
+        self.assertEqual( po.GetOwner('thisPkgDoesNotExist'), '' )
+    
+    def testcc(self):
+        self.assertEqual( po.GetCoOwnerList('perl-MIME-tools'),
+                          ['perl-sig at localhost.localdomain'] )
+
+
 if __name__ == '__main__':
     suite1 = unittest.makeSuite(TestDownloadFromCVS)
-    suite2 = unittest.makeSuite(TestDownloadFromURL)
-    suitemain = unittest.makeSuite(TestSequenceFunctions)
-    
-    alltests = unittest.TestSuite((suite1,suitemain,suite2,suitemain))
+    suite2 = unittest.makeSuite(TestDownloadFromOldURL)
+    suite3 = unittest.makeSuite(TestDownloadFromURL)
+    suitemain1 = unittest.makeSuite(TestSequenceFunctionsOld)
+    suitemain2 = unittest.makeSuite(TestSequenceFunctions)
+
+    alltests = unittest.TestSuite((suite1,suitemain1,
+                                   suite2,suitemain1,
+                                   suite3,suitemain2))
     unittest.TextTestRunner(verbosity=2).run(alltests)




More information about the fedora-extras-commits mailing list