Skip to content

Commit 2bebd3a

Browse files
author
Richard Jones
committed
Fix some tests.
1 parent 8b91ae7 commit 2bebd3a

File tree

5 files changed

+36
-9
lines changed

5 files changed

+36
-9
lines changed

doc/upgrading.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ accordingly. Note that there is information about upgrade procedures in the
1111
Migrating from 0.6 to 0.7
1212
=========================
1313

14+
0.7.0 Typed columns in MySQL backend
15+
------------------------------------
16+
17+
The MySQL (and Postgresql for that matter) backend now creates tables with
18+
appropriate column datatypes (not just varchar).
19+
20+
Your database will be automatically migrated to use the new schemas, but
21+
it will take time. It's probably a good idea to make sure you do this as
22+
part of the upgrade when users are not expected to be using the system.
23+
24+
1425
0.7.0 Permission setup
1526
----------------------
1627

@@ -51,13 +62,16 @@ add::
5162
p = db.security.getPermission('View', cl)
5263
db.security.addPermissionToRole('User', p)
5364

65+
5466
0.7.0 New "actor" property
5567
--------------------------
5668

5769
Roundup's database has a new per-item property "actor" which reflects the
5870
user performing the last "actvitiy". See the classic template for ways to
5971
integrate this new property into your interface.
6072

73+
The property will be automatically added to your existing database.
74+
6175

6276
0.7.0 Extending the cgi interface
6377
---------------------------------

roundup/backends/rdbms_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.85 2004-03-24 03:07:52 richard Exp $
1+
# $Id: rdbms_common.py,v 1.86 2004-03-24 04:57:25 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -607,7 +607,7 @@ def clear(self):
607607

608608
hyperdb_to_sql_value = {
609609
hyperdb.String : str,
610-
hyperdb.Date : lambda x: x.formal(sep=' ', sec='%f'),
610+
hyperdb.Date : lambda x: x.formal(sep=' ', sec='%.3f'),
611611
hyperdb.Link : int,
612612
hyperdb.Interval : lambda x: x.serialise(),
613613
hyperdb.Password : str,

roundup/date.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: date.py,v 1.62 2004-03-24 03:07:51 richard Exp $
18+
# $Id: date.py,v 1.63 2004-03-24 04:57:25 richard Exp $
1919

2020
"""Date, time and time interval handling.
2121
"""
@@ -300,16 +300,20 @@ def dateDelta(self, other):
300300
d = diff/(24*60*60)
301301
return Interval((0, 0, d, H, M, S), sign=sign)
302302

303-
def __cmp__(self, other):
303+
def __cmp__(self, other, int_seconds=0):
304304
"""Compare this date to another date."""
305305
if other is None:
306306
return 1
307-
for attr in ('year', 'month', 'day', 'hour', 'minute', 'second'):
307+
for attr in ('year', 'month', 'day', 'hour', 'minute'):
308308
if not hasattr(other, attr):
309309
return 1
310310
r = cmp(getattr(self, attr), getattr(other, attr))
311311
if r: return r
312-
return 0
312+
if not hasattr(other, 'second'):
313+
return 1
314+
if int_seconds:
315+
return cmp(int(self.second), int(other.second))
316+
return cmp(self.second, other.second)
313317

314318
def __str__(self):
315319
"""Return this date as a string in the yyyy-mm-dd.hh:mm:ss format."""
@@ -334,7 +338,7 @@ def pretty(self, format='%d %B %Y'):
334338
return str
335339

336340
def __repr__(self):
337-
return '<Date %s>'%self.__str__()
341+
return '<Date %s>'%self.formal(sec='%f')
338342

339343
def local(self, offset):
340344
""" Return this date as yyyy-mm-dd.hh:mm:ss in a local time zone.

test/db_test_base.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: db_test_base.py,v 1.19 2004-03-22 07:45:40 richard Exp $
18+
# $Id: db_test_base.py,v 1.20 2004-03-24 04:57:25 richard Exp $
1919

2020
import unittest, os, shutil, errno, imp, sys, time, pprint
2121

@@ -939,6 +939,7 @@ def testImportExport(self):
939939
# compare with snapshot of the database
940940
for cn, items in orig.items():
941941
klass = self.db.classes[cn]
942+
propdefs = klass.getprops(1)
942943
# ensure retired items are retired :)
943944
l = items.keys(); l.sort()
944945
m = klass.list(); m.sort()
@@ -949,7 +950,13 @@ def testImportExport(self):
949950
if isinstance(value, type([])):
950951
value.sort()
951952
l.sort()
952-
ae(l, value)
953+
try:
954+
ae(l, value)
955+
except AssertionError:
956+
if not isinstance(propdefs[name], Date):
957+
raise
958+
# don't get hung up on rounding errors
959+
assert not l.__cmp__(value, int_seconds=1)
953960

954961
# make sure the retired items are actually imported
955962
ae(self.db.user.get('4', 'username'), 'blop')

test/test_actions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ def setUp(self):
158158
ActionTestCase.setUp(self)
159159
self.action = EditItemAction(self.client)
160160
self.now = Date('.')
161+
# round off for testing
162+
self.now.seconds = int(self.now.seconds)
161163

162164
def testLastUserActivity(self):
163165
self.assertEqual(self.action.lastUserActivity(), None)

0 commit comments

Comments
 (0)