summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5c022fd)
raw | patch | inline | side by side (parent: 5c022fd)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 10 Mar 2003 00:22:52 +0000 (00:22 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 10 Mar 2003 00:22:52 +0000 (00:22 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1581 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/backends/back_anydbm.py | patch | blob | history | |
roundup/date.py | patch | blob | history | |
test/test_dates.py | patch | blob | history | |
test/test_db.py | patch | blob | history |
index 417e3d25a3a8abda04a0e2924930793671a072bd..2607654ea55e48a652e4036ab52bfaf7abf310e3 100644 (file)
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-#$Id: back_anydbm.py,v 1.110 2003-03-08 20:41:45 kedder Exp $
+#$Id: back_anydbm.py,v 1.111 2003-03-10 00:22:20 richard Exp $
'''
This module defines a backend that saves the hyperdatabase in a database
chosen by anydbm. It is guaranteed to always be available in python
# Compare contents of multilink property if lenghts is
# equal
r = cmp ('.'.join(av), '.'.join(bv))
- if dir == '+':
- return r
- elif dir == '-':
- return -r
- elif isinstance(propclass, Number) or isinstance(propclass, Boolean):
+ if r:
+ if dir == '+':
+ return r
+ else:
+ return -r
+
+ else:
+ # all other types just compare
if dir == '+':
r = cmp(av, bv)
elif dir == '-':
r = cmp(bv, av)
+ if r != 0: return r
# end for dir, prop in sort, group:
# if all else fails, compare the ids
diff --git a/roundup/date.py b/roundup/date.py
index 3e6559ff0bad626efeee0264823ee649d33b00ef..c214cd1350e050c457bfe3546533dadd1c0c4cec 100644 (file)
--- a/roundup/date.py
+++ b/roundup/date.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: date.py,v 1.46 2003-03-08 20:41:45 kedder Exp $
+# $Id: date.py,v 1.47 2003-03-10 00:22:20 richard Exp $
__doc__ = """
Date, time and time interval handling.
def __cmp__(self, other):
"""Compare this interval to another interval."""
if other is None:
+ # we are always larger than None
return 1
for attr in 'sign year month day hour minute second'.split():
- if not hasattr(other, attr):
- return 1
r = cmp(getattr(self, attr), getattr(other, attr))
if r:
return r
diff --git a/test/test_dates.py b/test/test_dates.py
index 2223e3e940bc9c2e44663b38410114b2978cbebf..fc0c9bdfc0988f3ee6e4e02f49a70267ce22e4d4 100644 (file)
--- a/test/test_dates.py
+++ b/test/test_dates.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: test_dates.py,v 1.19 2003-03-06 06:12:30 richard Exp $
+# $Id: test_dates.py,v 1.20 2003-03-10 00:22:21 richard Exp $
import unittest, time
-from roundup.date import Date, Interval, fixTimeOverflow
+from roundup.date import Date, Interval, Range, fixTimeOverflow
class DateTestCase(unittest.TestCase):
def testDateInterval(self):
l = [i1, i2]; l.sort()
ae(l, [i1, i2])
+ i1 = Interval("1:20")
+ i2 = Interval("2d")
+ i3 = Interval("3:30")
+ l = [i1, i2, i3]; l.sort()
+ ae(l, [i1, i3, i2])
def suite():
return unittest.makeSuite(DateTestCase, 'test')
diff --git a/test/test_db.py b/test/test_db.py
index 7af06e75241ceb0780fbf95a6736721e0f52e59f..a8f35c207ca7a150980353345576ddc38311f9b8 100644 (file)
--- a/test/test_db.py
+++ b/test/test_db.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: test_db.py,v 1.74 2003-03-06 06:03:51 richard Exp $
+# $Id: test_db.py,v 1.75 2003-03-10 00:22:21 richard Exp $
import unittest, os, shutil, time
self.db.user.create(**user)
iss = self.db.issue
for issue in (
- {'title': 'issue one', 'status': '2'},
- {'title': 'issue two', 'status': '1'},
- {'title': 'issue three', 'status': '1', 'nosy': ['1','2']}):
+ {'title': 'issue one', 'status': '2',
+ 'foo': date.Interval('1:10')},
+ {'title': 'issue two', 'status': '1',
+ 'foo': date.Interval('1d')},
+ {'title': 'issue three', 'status': '1',
+ 'nosy': ['1','2']}):
self.db.issue.create(**issue)
self.db.commit()
return self.assertEqual, self.db.issue.filter
ae(filt(None, {'nosy': '2', 'status': '1'}, ('+','id'), (None,None)),
['3'])
+ def testFilteringIntervalSort(self):
+ ae, filt = self.filteringSetup()
+ # ascending should sort None, 1:10, 1d
+ ae(filt(None, {}, ('+','foo'), (None,None)), ['3', '1', '2'])
+ # descending should sort 1d, 1:10, None
+ ae(filt(None, {}, ('-','foo'), (None,None)), ['2', '1', '3'])
+
-# TODO test auditors and reactors
+# XXX add sorting tests for other types
+# XXX test auditors and reactors
class anydbmReadOnlyDBTestCase(MyTestCase):
def setUp(self):