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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Thu Feb 17 09:00:00 CET 2011


Revision: 13345
          http://gar.svn.sourceforge.net/gar/?rev=13345&view=rev
Author:   wahwah
Date:     2011-02-17 08:00:00 +0000 (Thu, 17 Feb 2011)

Log Message:
-----------
csw-upload-pkg: A bugfix and unit tests

When there was a 5.10 package in the 5.10 catalog, but no package in th 5.9
catalog, and a 5.9 package was uploaded, csw-upload-pkg would overwrite the
existing 5.10 package with the 5.9 one.

catalog  pkg  inserted  problem?
None     5.9       Yes        No
5.10    5.10       Yes       Yes
5.11    5.10       Yes       Yes

This has been fixed and changed to:

catalog  pkg  inserted  problem?
None     5.9       Yes        No
5.10    5.10        No        No
5.11    5.10        No        No

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/csw_upload_pkg.py
    csw/mgar/gar/v2/lib/python/csw_upload_pkg_test.py

Modified: csw/mgar/gar/v2/lib/python/csw_upload_pkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/csw_upload_pkg.py	2011-02-17 07:59:25 UTC (rev 13344)
+++ csw/mgar/gar/v2/lib/python/csw_upload_pkg.py	2011-02-17 08:00:00 UTC (rev 13345)
@@ -173,8 +173,13 @@
           logging.debug(
               "Catalog %s %s does not contain any version of the %s package.",
               arch, osrel, catalogname)
-        if srv4_in_catalog and not first_cat_osrel_seen:
-          first_cat_osrel_seen = srv4_in_catalog["osrel"]
+        if not first_cat_osrel_seen:
+          if srv4_in_catalog:
+            first_cat_osrel_seen = srv4_in_catalog["osrel"]
+          else:
+            first_cat_osrel_seen = srv4_osrel
+          logging.info("Considering %s the base OS to match",
+                       first_cat_osrel_seen)
         if (not srv4_in_catalog
             or srv4_in_catalog["osrel"] == srv4_osrel
             or srv4_in_catalog["osrel"] == first_cat_osrel_seen):

Modified: csw/mgar/gar/v2/lib/python/csw_upload_pkg_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/csw_upload_pkg_test.py	2011-02-17 07:59:25 UTC (rev 13344)
+++ csw/mgar/gar/v2/lib/python/csw_upload_pkg_test.py	2011-02-17 08:00:00 UTC (rev 13345)
@@ -191,6 +191,27 @@
     )
     self.assertEquals(expected, result)
 
+  def test_MatchSrv4ToCatalogsFirstNotPresent(self):
+    rest_client_mock = self.mox.CreateMock(rest.RestClient)
+    self.mox.StubOutWithMock(rest, "RestClient")
+    rest.RestClient().AndReturn(rest_client_mock)
+    rest_client_mock.Srv4ByCatalogAndCatalogname(
+        'unstable', 'sparc', u'SunOS5.9', 'gdb').AndReturn(None)
+    rest_client_mock.Srv4ByCatalogAndCatalogname(
+        'unstable', 'sparc', u'SunOS5.10', 'gdb').AndReturn(GDB_STRUCT_10)
+    rest_client_mock.Srv4ByCatalogAndCatalogname(
+        'unstable', 'sparc', u'SunOS5.11', 'gdb').AndReturn(GDB_STRUCT_10)
+    self.mox.ReplayAll()
+    su = csw_upload_pkg.Srv4Uploader(None)
+    result = su._MatchSrv4ToCatalogs(
+        "gdb-7.2,REV=2011.01.21-SunOS5.9-sparc-CSW.pkg.gz",
+        "unstable", "sparc", "SunOS5.9",
+        "deadbeef61b53638d7813407fab4765b")
+    expected = (
+        ("unstable", "sparc", "SunOS5.9"),
+    )
+    self.assertEquals(expected, result)
 
+
 if __name__ == '__main__':
   unittest.main()


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