From a6f3287cc01cd1511f954d8d7e3631c077390ad7 Mon Sep 17 00:00:00 2001 From: richard Date: Wed, 24 Mar 2004 04:57:25 +0000 Subject: [PATCH] Fix some tests. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2170 57a73879-2fb5-44c3-a270-3262357dd7e2 --- doc/upgrading.txt | 14 ++++++++++++++ roundup/backends/rdbms_common.py | 4 ++-- roundup/date.py | 14 +++++++++----- test/db_test_base.py | 11 +++++++++-- test/test_actions.py | 2 ++ 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/doc/upgrading.txt b/doc/upgrading.txt index b53a457..33b381c 100644 --- a/doc/upgrading.txt +++ b/doc/upgrading.txt @@ -11,6 +11,17 @@ accordingly. Note that there is information about upgrade procedures in the Migrating from 0.6 to 0.7 ========================= +0.7.0 Typed columns in MySQL backend +------------------------------------ + +The MySQL (and Postgresql for that matter) backend now creates tables with +appropriate column datatypes (not just varchar). + +Your database will be automatically migrated to use the new schemas, but +it will take time. It's probably a good idea to make sure you do this as +part of the upgrade when users are not expected to be using the system. + + 0.7.0 Permission setup ---------------------- @@ -51,6 +62,7 @@ add:: p = db.security.getPermission('View', cl) db.security.addPermissionToRole('User', p) + 0.7.0 New "actor" property -------------------------- @@ -58,6 +70,8 @@ Roundup's database has a new per-item property "actor" which reflects the user performing the last "actvitiy". See the classic template for ways to integrate this new property into your interface. +The property will be automatically added to your existing database. + 0.7.0 Extending the cgi interface --------------------------------- diff --git a/roundup/backends/rdbms_common.py b/roundup/backends/rdbms_common.py index 07b0257..435b99c 100644 --- a/roundup/backends/rdbms_common.py +++ b/roundup/backends/rdbms_common.py @@ -1,4 +1,4 @@ -# $Id: rdbms_common.py,v 1.85 2004-03-24 03:07:52 richard Exp $ +# $Id: rdbms_common.py,v 1.86 2004-03-24 04:57:25 richard Exp $ ''' Relational database (SQL) backend common code. Basics: @@ -607,7 +607,7 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database): hyperdb_to_sql_value = { hyperdb.String : str, - hyperdb.Date : lambda x: x.formal(sep=' ', sec='%f'), + hyperdb.Date : lambda x: x.formal(sep=' ', sec='%.3f'), hyperdb.Link : int, hyperdb.Interval : lambda x: x.serialise(), hyperdb.Password : str, diff --git a/roundup/date.py b/roundup/date.py index 6b9a807..a8d6ef3 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.62 2004-03-24 03:07:51 richard Exp $ +# $Id: date.py,v 1.63 2004-03-24 04:57:25 richard Exp $ """Date, time and time interval handling. """ @@ -300,16 +300,20 @@ class Date: d = diff/(24*60*60) return Interval((0, 0, d, H, M, S), sign=sign) - def __cmp__(self, other): + def __cmp__(self, other, int_seconds=0): """Compare this date to another date.""" if other is None: return 1 - for attr in ('year', 'month', 'day', 'hour', 'minute', 'second'): + for attr in ('year', 'month', 'day', 'hour', 'minute'): if not hasattr(other, attr): return 1 r = cmp(getattr(self, attr), getattr(other, attr)) if r: return r - return 0 + if not hasattr(other, 'second'): + return 1 + if int_seconds: + return cmp(int(self.second), int(other.second)) + return cmp(self.second, other.second) def __str__(self): """Return this date as a string in the yyyy-mm-dd.hh:mm:ss format.""" @@ -334,7 +338,7 @@ class Date: return str def __repr__(self): - return ''%self.__str__() + return ''%self.formal(sec='%f') def local(self, offset): """ Return this date as yyyy-mm-dd.hh:mm:ss in a local time zone. diff --git a/test/db_test_base.py b/test/db_test_base.py index 3acc05b..14a9e38 100644 --- a/test/db_test_base.py +++ b/test/db_test_base.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: db_test_base.py,v 1.19 2004-03-22 07:45:40 richard Exp $ +# $Id: db_test_base.py,v 1.20 2004-03-24 04:57:25 richard Exp $ import unittest, os, shutil, errno, imp, sys, time, pprint @@ -939,6 +939,7 @@ class DBTest(MyTestCase): # compare with snapshot of the database for cn, items in orig.items(): klass = self.db.classes[cn] + propdefs = klass.getprops(1) # ensure retired items are retired :) l = items.keys(); l.sort() m = klass.list(); m.sort() @@ -949,7 +950,13 @@ class DBTest(MyTestCase): if isinstance(value, type([])): value.sort() l.sort() - ae(l, value) + try: + ae(l, value) + except AssertionError: + if not isinstance(propdefs[name], Date): + raise + # don't get hung up on rounding errors + assert not l.__cmp__(value, int_seconds=1) # make sure the retired items are actually imported ae(self.db.user.get('4', 'username'), 'blop') diff --git a/test/test_actions.py b/test/test_actions.py index 2e33429..2a0c2f8 100755 --- a/test/test_actions.py +++ b/test/test_actions.py @@ -158,6 +158,8 @@ class CollisionDetectionTestCase(ActionTestCase): ActionTestCase.setUp(self) self.action = EditItemAction(self.client) self.now = Date('.') + # round off for testing + self.now.seconds = int(self.now.seconds) def testLastUserActivity(self): self.assertEqual(self.action.lastUserActivity(), None) -- 2.30.2