[csw-devel] SF.net SVN: gar:[11971] csw/mgar/gar/v2/lib/python
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Thu Dec 16 17:19:16 CET 2010
Revision: 11971
http://gar.svn.sourceforge.net/gar/?rev=11971&view=rev
Author: wahwah
Date: 2010-12-16 16:19:16 +0000 (Thu, 16 Dec 2010)
Log Message:
-----------
checkpkg: Better error message for system files
This error message should be more helpful. It mentions shared and private db
setups, and says what commands to run to import system files to the database.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/database.py
Added Paths:
-----------
csw/mgar/gar/v2/lib/python/database_test.py
Modified: csw/mgar/gar/v2/lib/python/database.py
===================================================================
--- csw/mgar/gar/v2/lib/python/database.py 2010-12-16 15:33:35 UTC (rev 11970)
+++ csw/mgar/gar/v2/lib/python/database.py 2010-12-16 16:19:16 UTC (rev 11971)
@@ -111,17 +111,21 @@
logging.debug("VerifyContents(%s, %s): %s", sqo_osrel, sqo_arch, system_pkgs)
if system_pkgs < 10:
raise DatabaseError(
- "Your database does not have information about "
- "system files for %s %s. "
- "If you don't have a central database, "
+ "Checkpkg can't find system files for %s %s in the cache database. "
+ "These are files such as /usr/lib/libc.so.1. "
+ "Private DB setup: "
"you can only check packages built for the same Solaris version "
"you're running on this machine. "
"For instance, you can't check a SunOS5.9 package on SunOS5.10. "
- "OpenCSW maintainers: "
+ "Shared DB setup (e.g. OpenCSW maintainers): "
"If you have one home directory on multiple hosts, make sure you "
- "run checkpkg on the host you intended to. "
+ "run checkpkg on the host you intended to. "
+ "To fix, go to a %s %s host and execute: pkgdb system-files-to-file; "
+ "pkgdb import-system-file install-contents-%s-%s.pickle; "
"See http://wiki.opencsw.org/checkpkg for more information."
- % (sqo_osrel.short_name, sqo_arch.name))
+ % (sqo_osrel.short_name, sqo_arch.name,
+ sqo_arch.name, sqo_osrel.short_name,
+ sqo_osrel.short_name, sqo_arch.name))
class CheckpkgDatabaseMixin(object):
Added: csw/mgar/gar/v2/lib/python/database_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/database_test.py (rev 0)
+++ csw/mgar/gar/v2/lib/python/database_test.py 2010-12-16 16:19:16 UTC (rev 11971)
@@ -0,0 +1,41 @@
+#!/usr/bin/env python2.6
+
+import unittest
+import database
+import mox
+import models
+
+
+class DatabaseManagerUnitTest(mox.MoxTestBase):
+
+ def testNoSystemFiles(self):
+ # This test shows that stubbing out sqlite classes is quite laborious.
+ saved_s = database.m.Srv4FileStats
+ srv4_file_stats_mock_factory = self.mox.CreateMockAnything()
+ database.m.Srv4FileStats = srv4_file_stats_mock_factory
+ q_mock = self.mox.CreateMockAnything()
+ q_mock.use_to_generate_catalogs = self.mox.CreateMockAnything()
+ database.m.Srv4FileStats.q = q_mock
+ # We would prefer to use self.mox.CreateMock(models.OsRelease). The
+ # reason why it doesn't work, is that mox tries to inspect the class, and
+ # sqlobject overrides the __get__ method of that class, where it tries to
+ # verify that a connection to a database exists. In our tests we don't
+ # have a connection, and sqlobject throws an exception.
+ osrel_mock = self.mox.CreateMockAnything()
+ arch_mock = self.mox.CreateMockAnything()
+ osrel_mock.short_name = 'AlienOS5.3'
+ arch_mock.name = 'amd65'
+ dm = database.DatabaseManager()
+ result_mock = self.mox.CreateMockAnything()
+ srv4_file_stats_mock_factory.select(0).AndReturn(result_mock)
+ # This is where we return the number of system files (0)
+ result_mock.count().AndReturn(0)
+ self.mox.ReplayAll()
+ self.assertRaises(
+ database.DatabaseError,
+ dm.VerifyContents, osrel_mock, arch_mock)
+ database.m.Srv4FileStats = saved_s
+
+
+if __name__ == '__main__':
+ unittest.main()
Property changes on: csw/mgar/gar/v2/lib/python/database_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