Skip to content

Commit bcc7090

Browse files
author
Richard Jones
committed
add some Range testing, all of which currently fails
1 parent 7eb673e commit bcc7090

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

test/db_test_base.py

Lines changed: 15 additions & 4 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.92 2007-10-26 06:52:26 richard Exp $
18+
# $Id: db_test_base.py,v 1.93 2007-12-20 01:01:49 richard Exp $
1919

2020
import unittest, os, shutil, errno, imp, sys, time, pprint, sets, base64, os.path
2121

@@ -1184,15 +1184,26 @@ def testFilteringRangeTwoSyntaxes(self):
11841184
ae(filt(None, {'deadline': '2003-02-16;'}), ['1', '3', '4'])
11851185

11861186
def testFilteringRangeYearMonthDay(self):
1187-
ae, filt = self.filteringSetup()
11881187
ae(filt(None, {'deadline': '2002'}), [])
11891188
ae(filt(None, {'deadline': '2003'}), ['1', '2', '3'])
11901189
ae(filt(None, {'deadline': '2004'}), ['4'])
1191-
ae(filt(None, {'deadline': '2003-02'}), ['1', '3'])
1192-
ae(filt(None, {'deadline': '2003-03'}), [])
11931190
ae(filt(None, {'deadline': '2003-02-16'}), ['1'])
11941191
ae(filt(None, {'deadline': '2003-02-17'}), [])
11951192

1193+
def testFilteringRangeMonths(self):
1194+
ae, filt = self.filteringSetup()
1195+
for month in range(1, 5): #13):
1196+
print 'MONTH', month
1197+
for n in range(1, month+1):
1198+
i = self.db.issue.create(title='%d.%d'%(month, n),
1199+
deadline=date.Date('2004-%02d-%02d.00:00'%(month, n)))
1200+
print 'CREATE', i, self.db.issue.get(i, 'deadline')
1201+
self.db.commit()
1202+
1203+
for month in range(1, 13):
1204+
r = filt(None, dict(deadline='2004-%02d'%month))
1205+
assert len(r) == month, 'month %d != length %d'%(month, len(r))
1206+
11961207
def testFilteringRangeInterval(self):
11971208
ae, filt = self.filteringSetup()
11981209
ae(filt(None, {'foo': 'from 0:50 to 2:00'}), ['1'])

test/test_dates.py

Lines changed: 17 additions & 1 deletion
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: test_dates.py,v 1.41 2007-03-12 17:53:38 schlatterbeck Exp $
18+
# $Id: test_dates.py,v 1.42 2007-12-20 01:01:49 richard Exp $
1919
from __future__ import nested_scopes
2020

2121
import unittest
@@ -466,9 +466,25 @@ def testTZ(self):
466466
date = Date(date, tz)
467467
ae(str(date), '2006-01-01.11:00:00')
468468

469+
class RangeTestCase(unittest.TestCase):
470+
def testRange(self):
471+
ae = self.assertEqual
472+
r = Range('2006', Date)
473+
ae(str(r.from_value), '2006-01-01.00:00:00')
474+
ae(str(r.to_value), '2006-12-31.23:59:59')
475+
# XXX this is probably in the calendar module
476+
days = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
477+
for i in range(1, 13):
478+
print i
479+
r = Range('2006-%02d'%i, Date)
480+
ae(str(r.from_value), '2006-%02d-01.00:00:00'%i)
481+
ae(str(r.to_value), '2006-%02d-%02d.23:59:59'%(i, days[i-1]))
482+
483+
469484
def test_suite():
470485
suite = unittest.TestSuite()
471486
suite.addTest(unittest.makeSuite(DateTestCase))
487+
suite.addTest(unittest.makeSuite(RangeTestCase))
472488
try:
473489
import pytz
474490
except ImportError:

0 commit comments

Comments
 (0)