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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Sun Jan 9 22:35:33 CET 2011


Revision: 12476
          http://gar.svn.sourceforge.net/gar/?rev=12476&view=rev
Author:   wahwah
Date:     2011-01-09 21:35:32 +0000 (Sun, 09 Jan 2011)

Log Message:
-----------
checkpkg: Reset state of checkpkg manager

Not very important for current scenarios, but in case checkpkg manager
is run twice, it should reset its state.

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

Property Changed:
----------------
    csw/mgar/gar/v2/lib/python/models_test.py

Modified: csw/mgar/gar/v2/lib/python/checkpkg_lib.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_lib.py	2011-01-09 21:34:59 UTC (rev 12475)
+++ csw/mgar/gar/v2/lib/python/checkpkg_lib.py	2011-01-09 21:35:32 UTC (rev 12476)
@@ -136,15 +136,18 @@
     self.debug = debug
     self.name = name
     self.sqo_pkgs_list = sqo_pkgs_list
-    self.errors = []
-    self.individual_checks = []
-    self.set_checks = []
-    self.packages = []
     self.osrel = osrel
     self.arch = arch
     self.catrel = catrel
     self.show_progress = show_progress
+    self._ResetState()
 
+  def _ResetState(self):
+    self.errors = []
+    self.individual_checks = []
+    self.set_checks = []
+    self.packages = []
+
   def GetProgressBar(self):
     if self.show_progress and not self.debug:
       return progressbar.ProgressBar()
@@ -215,7 +218,7 @@
 
     Returns a tuple of an exit code and a report.
     """
-    # packages_data = self.GetPackageStatsList()
+    self._ResetState()
     assert self.sqo_pkgs_list, "The list of packages must not be empty."
     db_stat_objs_by_pkgname = {}
     for pkg in self.sqo_pkgs_list:

Modified: csw/mgar/gar/v2/lib/python/checkpkg_lib_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_lib_test.py	2011-01-09 21:34:59 UTC (rev 12475)
+++ csw/mgar/gar/v2/lib/python/checkpkg_lib_test.py	2011-01-09 21:35:32 UTC (rev 12476)
@@ -350,7 +350,22 @@
     # Verifying that there are some reported error tags.
     self.assertTrue(list(models.CheckpkgErrorTag.select()))
 
+  def testReRunCheckpkg(self):
+    """Error tags should not accumulate."""
+    self.dbc.InitialDataImport()
+    sqo_pkg = package_stats.PackageStats.SaveStats(neon_stats[0], True)
+    cm = checkpkg_lib.CheckpkgManager2(
+        "testname", [sqo_pkg], "SunOS5.9", "sparc", "unstable",
+        show_progress=False)
+    before_count = models.CheckpkgErrorTag.selectBy(srv4_file=sqo_pkg).count()
+    cm.Run()
+    first_run_count = models.CheckpkgErrorTag.selectBy(srv4_file=sqo_pkg).count()
+    cm.Run()
+    second_run_count = models.CheckpkgErrorTag.selectBy(srv4_file=sqo_pkg).count()
+    self.assertEquals(0, before_count)
+    self.assertEquals(first_run_count, second_run_count)
 
+
 class IndividualCheckInterfaceUnitTest(mox.MoxTestBase):
 
   def testNeededFile(self):

Modified: csw/mgar/gar/v2/lib/python/models_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/models_test.py	2011-01-09 21:34:59 UTC (rev 12475)
+++ csw/mgar/gar/v2/lib/python/models_test.py	2011-01-09 21:35:32 UTC (rev 12476)
@@ -1,5 +1,11 @@
+#!/usr/bin/env python2.6
+
 import unittest
+import mox
+import test_base
 import models
+import sqlobject
+import datetime
 
 class CheckpkgErrorTagUnitTest(unittest.TestCase):
 
@@ -28,6 +34,52 @@
     self.assertEquals(t1, t2)
 
 
+class Srv4FileStatsUnitTest(test_base.SqlObjectTestMixin, mox.MoxTestBase):
+
+  def setUp(self):
+    super(Srv4FileStatsUnitTest, self).setUp()
+    self.dbc.InitialDataImport()
+    self.sqo_arch = models.Architecture.selectBy(id=1).getOne()
+    self.sqo_osrel = models.OsRelease.selectBy(id=1).getOne()
+    self.sqo_catrel = models.CatalogRelease.selectBy(id=1).getOne()
+    self.pkginst = models.Pkginst(pkgname="CSWfoo")
+    self.maintainer = models.Maintainer(
+        email='joe at example.com',
+        full_name='Joe Bloggs')
+    self.p = models.Srv4FileStats(
+        arch=self.sqo_arch,
+        basename="foo.pkg",
+        catalogname="foo",
+        data_obj=None,
+        filename_arch=self.sqo_arch,
+        latest=True,
+        maintainer=self.maintainer,
+        md5_sum="not a real one",
+        size=1L,
+        mtime=datetime.datetime.now(),
+        os_rel=self.sqo_osrel,
+        pkginst=self.pkginst,
+        registered=True,
+        use_to_generate_catalogs=True,
+        rev="2011.01.01",
+        stats_version=0,
+        version_string="1.0,REV=2011.01.01",
+    )
+
+  def testRemoveCheckpkgResults(self):
+    error_tag = models.CheckpkgErrorTag(
+        tag_name="foo",
+        tag_info="foo_info",
+        srv4_file=self.p,
+        os_rel=self.sqo_osrel,
+        arch=self.sqo_arch,
+        catrel=self.sqo_catrel,
+    )
+    self.assertEqual(1, models.CheckpkgErrorTag.select().count())
+    self.p.RemoveCheckpkgResults(self.sqo_osrel, self.sqo_arch, self.sqo_catrel)
+    self.assertEqual(0, models.CheckpkgErrorTag.select().count())
+
+
 if __name__ == '__main__':
   unittest.main()
 


Property changes on: csw/mgar/gar/v2/lib/python/models_test.py
___________________________________________________________________
Added: svn:executable
   + *


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