|
15 | 15 | # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
16 | 16 | # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
17 | 17 | # |
18 | | -# $Id: test_db.py,v 1.75 2003-03-10 00:22:21 richard Exp $ |
| 18 | +# $Id: test_db.py,v 1.76 2003-03-10 18:16:42 kedder Exp $ |
19 | 19 |
|
20 | 20 | import unittest, os, shutil, time |
21 | 21 |
|
@@ -633,11 +633,13 @@ def filteringSetup(self): |
633 | 633 | iss = self.db.issue |
634 | 634 | for issue in ( |
635 | 635 | {'title': 'issue one', 'status': '2', |
636 | | - 'foo': date.Interval('1:10')}, |
| 636 | + 'foo': date.Interval('1:10'), |
| 637 | + 'deadline': date.Date('2003-01-01.00:00')}, |
637 | 638 | {'title': 'issue two', 'status': '1', |
638 | | - 'foo': date.Interval('1d')}, |
| 639 | + 'foo': date.Interval('1d'), |
| 640 | + 'deadline': date.Date('2003-02-16.22:50')}, |
639 | 641 | {'title': 'issue three', 'status': '1', |
640 | | - 'nosy': ['1','2']}): |
| 642 | + 'nosy': ['1','2'], 'deadline': date.Date('2003-03-08')}): |
641 | 643 | self.db.issue.create(**issue) |
642 | 644 | self.db.commit() |
643 | 645 | return self.assertEqual, self.db.issue.filter |
@@ -665,14 +667,23 @@ def testFilteringMany(self): |
665 | 667 | ae(filt(None, {'nosy': '2', 'status': '1'}, ('+','id'), (None,None)), |
666 | 668 | ['3']) |
667 | 669 |
|
| 670 | + def testFilteringRange(self): |
| 671 | + ae, filt = self.filteringSetup() |
| 672 | + ae(filt(None, {'deadline': 'from 2003-02-10 to 2003-02-23'}), ['2']) |
| 673 | + ae(filt(None, {'deadline': '2003-02-10; 2003-02-23'}), ['2']) |
| 674 | + ae(filt(None, {'deadline': '; 2003-02-16'}), ['1']) |
| 675 | + # Lets assume people won't invent a time machine, otherwise this test |
| 676 | + # may fail :) |
| 677 | + ae(filt(None, {'deadline': 'from 2003-02-16'}), ['2', '3']) |
| 678 | + ae(filt(None, {'deadline': '2003-02-16'}), ['2', '3']) |
| 679 | + |
668 | 680 | def testFilteringIntervalSort(self): |
669 | 681 | ae, filt = self.filteringSetup() |
670 | 682 | # ascending should sort None, 1:10, 1d |
671 | 683 | ae(filt(None, {}, ('+','foo'), (None,None)), ['3', '1', '2']) |
672 | 684 | # descending should sort 1d, 1:10, None |
673 | 685 | ae(filt(None, {}, ('-','foo'), (None,None)), ['2', '1', '3']) |
674 | 686 |
|
675 | | - |
676 | 687 | # XXX add sorting tests for other types |
677 | 688 | # XXX test auditors and reactors |
678 | 689 |
|
@@ -916,28 +927,28 @@ def suite(): |
916 | 927 |
|
917 | 928 | from roundup import backends |
918 | 929 | p = [] |
919 | | -# if hasattr(backends, 'mysql'): |
920 | | -# from roundup.backends import mysql |
921 | | -# try: |
922 | | -# # Check if we can run mysql tests |
923 | | -# import MySQLdb |
924 | | -# db = mysql.Database(nodbconfig, 'admin') |
925 | | -# db.conn.select_db(config.MYSQL_DBNAME) |
926 | | -# db.sql("SHOW TABLES"); |
927 | | -# tables = db.sql_fetchall() |
928 | | -# if tables: |
929 | | -# # Database should be empty. We don't dare to delete any data |
930 | | -# raise DatabaseError, "(Database %s contains tables)" % config.MYSQL_DBNAME |
931 | | -# db.sql("DROP DATABASE %s" % config.MYSQL_DBNAME) |
932 | | -# db.sql("CREATE DATABASE %s" % config.MYSQL_DBNAME) |
933 | | -# db.close() |
934 | | -# except (MySQLdb.ProgrammingError, DatabaseError), msg: |
935 | | -# print "Warning! Mysql tests will not be performed", msg |
936 | | -# print "See doc/mysql.txt for more details." |
937 | | -# else: |
938 | | -# p.append('mysql') |
939 | | -# l.append(unittest.makeSuite(mysqlDBTestCase, 'test')) |
940 | | -# l.append(unittest.makeSuite(mysqlReadOnlyDBTestCase, 'test')) |
| 930 | + if hasattr(backends, 'mysql'): |
| 931 | + from roundup.backends import mysql |
| 932 | + try: |
| 933 | + # Check if we can run mysql tests |
| 934 | + import MySQLdb |
| 935 | + db = mysql.Database(nodbconfig, 'admin') |
| 936 | + db.conn.select_db(config.MYSQL_DBNAME) |
| 937 | + db.sql("SHOW TABLES"); |
| 938 | + tables = db.sql_fetchall() |
| 939 | + if tables: |
| 940 | + # Database should be empty. We don't dare to delete any data |
| 941 | + raise DatabaseError, "(Database %s contains tables)" % config.MYSQL_DBNAME |
| 942 | + db.sql("DROP DATABASE %s" % config.MYSQL_DBNAME) |
| 943 | + db.sql("CREATE DATABASE %s" % config.MYSQL_DBNAME) |
| 944 | + db.close() |
| 945 | + except (MySQLdb.ProgrammingError, DatabaseError), msg: |
| 946 | + print "Warning! Mysql tests will not be performed", msg |
| 947 | + print "See doc/mysql.txt for more details." |
| 948 | + else: |
| 949 | + p.append('mysql') |
| 950 | + l.append(unittest.makeSuite(mysqlDBTestCase, 'test')) |
| 951 | + l.append(unittest.makeSuite(mysqlReadOnlyDBTestCase, 'test')) |
941 | 952 | #return unittest.TestSuite(l) |
942 | 953 |
|
943 | 954 | if hasattr(backends, 'gadfly'): |
|
0 commit comments