[csw-devel] SF.net SVN: gar:[13057] csw/mgar/gar/v2/lib/python

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Jan 23 08:59:35 CET 2011


Revision: 13057
          http://gar.svn.sourceforge.net/gar/?rev=13057&view=rev
Author:   wahwah
Date:     2011-01-23 07:59:35 +0000 (Sun, 23 Jan 2011)

Log Message:
-----------
pkgdb: Disallow duplicate catalognames in catalogs

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/checkpkg_lib.py
    csw/mgar/gar/v2/lib/python/package_stats_test.py

Modified: csw/mgar/gar/v2/lib/python/checkpkg_lib.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_lib.py	2011-01-23 07:59:06 UTC (rev 13056)
+++ csw/mgar/gar/v2/lib/python/checkpkg_lib.py	2011-01-23 07:59:35 UTC (rev 13057)
@@ -961,8 +961,19 @@
                   m.Srv4FileInCatalog.q.arch==sqo_arch,
                   m.Srv4FileInCatalog.q.catrel==sqo_catrel,
                   m.Srv4FileInCatalog.q.srv4file!=sqo_srv4))
-    if len(list(res)):
+    if res.count():
       raise CatalogDatabaseError(
+          "There already is a package with that catalogname: %s" % pkginst)
+    res = m.Srv4FileStats.select(
+            m.Srv4FileStats.q.catalogname==sqo_srv4.catalogname
+            ).throughTo.in_catalogs.filter(
+                sqlobject.AND(
+                  m.Srv4FileInCatalog.q.osrel==sqo_osrel,
+                  m.Srv4FileInCatalog.q.arch==sqo_arch,
+                  m.Srv4FileInCatalog.q.catrel==sqo_catrel,
+                  m.Srv4FileInCatalog.q.srv4file!=sqo_srv4))
+    if res.count():
+      raise CatalogDatabaseError(
           "There already is a package with that pkgname: %s" % pkginst)
     # Checking for presence of the same srv4 already in the catalog.
     res = m.Srv4FileInCatalog.select(

Modified: csw/mgar/gar/v2/lib/python/package_stats_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_stats_test.py	2011-01-23 07:59:06 UTC (rev 13056)
+++ csw/mgar/gar/v2/lib/python/package_stats_test.py	2011-01-23 07:59:35 UTC (rev 13057)
@@ -360,6 +360,7 @@
     self.dbc.InitialDataImport()
     neon_stats2 = copy.deepcopy(neon_stats[0])
     neon_stats2["basic_stats"]["md5_sum"] = "another pkg"
+    neon_stats2["basic_stats"]["catalogname"] = "another_pkg"
     # md5_sum is different
     # pkgname stays the same on purpose
     sqo_pkg1 = self.TestPackageStats.ImportPkg(neon_stats[0])
@@ -372,6 +373,23 @@
             c.AddSrv4ToCatalog,
             sqo_pkg2, *args)
 
+  def testDuplicateCatalognameThrowsError(self):
+    self.dbc.InitialDataImport()
+    neon_stats2 = copy.deepcopy(neon_stats[0])
+    neon_stats2["basic_stats"]["md5_sum"] = "another pkg"
+    neon_stats2["basic_stats"]["pkgname"] = "CSWanother-pkg"
+    # md5_sum is different
+    # pkgname stays the same on purpose
+    sqo_pkg1 = self.TestPackageStats.ImportPkg(neon_stats[0])
+    sqo_pkg2 = self.TestPackageStats.ImportPkg(neon_stats2)
+    c = self.TestCatalog()
+    args = ('SunOS5.9', 'i386', 'unstable')
+    c.AddSrv4ToCatalog(sqo_pkg1, *args)
+    self.assertRaises(
+            checkpkg_lib.CatalogDatabaseError,
+            c.AddSrv4ToCatalog,
+            sqo_pkg2, *args)
+
   def testDuplicatePkginstDoesNotThrowErrorIfDifferentCatalog(self):
     self.dbc.InitialDataImport()
     neon_stats2 = copy.deepcopy(neon_stats[0])


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list