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

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Wed Dec 15 00:21:55 CET 2010


Revision: 11937
          http://gar.svn.sourceforge.net/gar/?rev=11937&view=rev
Author:   wahwah
Date:     2010-12-14 23:21:55 +0000 (Tue, 14 Dec 2010)

Log Message:
-----------
checkpkg: A bugfix for package mtime

Also a unit test for the CswSrv4File class.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/package.py
    csw/mgar/gar/v2/lib/python/package_test.py

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

Modified: csw/mgar/gar/v2/lib/python/package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package.py	2010-12-14 23:21:06 UTC (rev 11936)
+++ csw/mgar/gar/v2/lib/python/package.py	2010-12-14 23:21:55 UTC (rev 11937)
@@ -135,9 +135,11 @@
     return self.stat
 
   def GetMtime(self):
-    s = self._Stat()
-    t = time.gmtime(s.st_mtime)
-    self.mtime = datetime.datetime(*t[:6])
+    if not self.mtime:
+      s = self._Stat()
+      t = time.gmtime(s.st_mtime)
+      self.mtime = datetime.datetime(*t[:6])
+    return self.mtime
 
   def GetSize(self):
     s = self._Stat()

Modified: csw/mgar/gar/v2/lib/python/package_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_test.py	2010-12-14 23:21:06 UTC (rev 11936)
+++ csw/mgar/gar/v2/lib/python/package_test.py	2010-12-14 23:21:55 UTC (rev 11937)
@@ -1,6 +1,25 @@
 #!/usr/bin/env python2.6
 
 import unittest
+import package
+import mox
+import os
+import posix
+import datetime
 
+class CswSrv4FileUnitTest(mox.MoxTestBase):
+
+  def testGetMtime(self):
+    p = package.CswSrv4File("/fake/path")
+    self.mox.StubOutWithMock(os, 'stat')
+    stat_result_mock = self.mox.CreateMock(posix.stat_result)
+    stat_result_mock.st_mtime = 1292318507.0
+    os.stat("/fake/path").AndReturn(stat_result_mock)
+    self.mox.ReplayAll()
+    self.assertEquals(
+        datetime.datetime(2010, 12, 14, 9, 21, 47),
+        p.GetMtime())
+
+
 if __name__ == '__main__':
   unittest.main()


Property changes on: csw/mgar/gar/v2/lib/python/package_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