Code

fixed bug in Interval serialisation
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 10 Oct 2002 07:18:03 +0000 (07:18 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Thu, 10 Oct 2002 07:18:03 +0000 (07:18 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1334 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/date.py
test/test_db.py

index bdcc965510e879087263284fecbe897c7fe4130f..d279fdff17130c613501dd8d556350cdf9c95d54 100644 (file)
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: date.py,v 1.32 2002-09-23 12:09:29 richard Exp $
+# $Id: date.py,v 1.33 2002-10-10 07:18:02 richard Exp $
 
 __doc__ = """
 Date, time and time interval handling.
@@ -446,7 +446,8 @@ class Interval:
             self.minute, self.second)
 
     def serialise(self):
-        return '%s%4d%02d%02d%02d%02d%02d'%(self.sign, self.year, self.month,
+        sign = self.sign > 0 and '+' or '-'
+        return '%s%04d%02d%02d%02d%02d%02d'%(sign, self.year, self.month,
             self.day, self.hour, self.minute, self.second)
 
 
index 46ecab9238ed0faeb8695df3580c8907c8802f5a..86d3b4f3d5bc211e832cecd15d904f7b0f53f8d6 100644 (file)
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: test_db.py,v 1.59 2002-10-08 07:28:34 richard Exp $ 
+# $Id: test_db.py,v 1.60 2002-10-10 07:18:03 richard Exp $ 
 
 import unittest, os, shutil, time
 
@@ -135,12 +135,22 @@ class anydbmDBTestCase(MyTestCase):
         self.assertEqual(self.db.issue.get('1', "deadline"), None)
 
     def testIntervalChange(self):
-        self.db.issue.create(title="spam", status='1')
-        a = self.db.issue.get('1', "foo")
-        self.db.issue.set('1', foo=date.Interval('-1d'))
-        self.assertNotEqual(self.db.issue.get('1', "foo"), a)
-        self.db.issue.set('1', foo=None)
-        self.assertEqual(self.db.issue.get('1', "foo"), None)
+        nid = self.db.issue.create(title="spam", status='1')
+        self.db.commit()
+        a = self.db.issue.get(nid, "foo")
+        i = date.Interval('-1d')
+        self.db.issue.set(nid, foo=i)
+        self.db.commit()
+        self.assertNotEqual(self.db.issue.get(nid, "foo"), a)
+        self.assertEqual(i, self.db.issue.get(nid, "foo"))
+        j = date.Interval('1y')
+        self.db.issue.set(nid, foo=j)
+        self.db.commit()
+        self.assertNotEqual(self.db.issue.get(nid, "foo"), i)
+        self.assertEqual(j, self.db.issue.get(nid, "foo"))
+        self.db.issue.set(nid, foo=None)
+        self.db.commit()
+        self.assertEqual(self.db.issue.get(nid, "foo"), None)
 
     def testBooleanChange(self):
         userid = self.db.user.create(username='foo', assignable=1)