From 6da7b2e96902d5f6f5f5b3d448133d4560007150 Mon Sep 17 00:00:00 2001 From: richard Date: Thu, 10 Oct 2002 07:18:03 +0000 Subject: [PATCH] fixed bug in Interval serialisation git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1334 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/date.py | 5 +++-- test/test_db.py | 24 +++++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/roundup/date.py b/roundup/date.py index bdcc965..d279fdf 100644 --- a/roundup/date.py +++ b/roundup/date.py @@ -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) diff --git a/test/test_db.py b/test/test_db.py index 46ecab9..86d3b4f 100644 --- a/test/test_db.py +++ b/test/test_db.py @@ -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) -- 2.30.2