annotate test/test_postgresql.py @ 6941:bd2c3b2010c3

issue2551232 - modify in-reply-to threading when multiple matches if an email is missing an issue designator, in-reply-to threading is attempted. In this change if in-reply-to threading matches multiple issues, fall back to matching on subject. It used to just arbitrairly choose the first matching issue.
author John Rouillard <rouilj@ieee.org>
date Thu, 08 Sep 2022 18:49:46 -0400
parents 9ff091537f43
children 521d98231e5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
1 #
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
2 # Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/)
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
3 # This module is free software, and you may redistribute it and/or modify
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
4 # under the same terms as Python, so long as this copyright message and
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
5 # disclaimer are retained in their original form.
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
6 #
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
7 # IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
8 # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
9 # OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
10 # POSSIBILITY OF SUCH DAMAGE.
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
11 #
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
12 # BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
17
2075
b1704ba7be41 make mysql / postgresql work again. beginnings of otk/session store in rdbmses
Richard Jones <richard@users.sourceforge.net>
parents: 1920
diff changeset
18 import unittest
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
19
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
20 import pytest
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
21 from roundup.hyperdb import DatabaseError
5215
917e45d9ba08 test_postgress isn't properly skipping tests when database is not
John Rouillard <rouilj@ieee.org>
parents: 5118
diff changeset
22 from roundup.backends import get_backend, have_backend
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
23
5388
d26921b851c3 Python 3 preparation: make relative imports explicit.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5319
diff changeset
24 from .db_test_base import DBTest, ROTest, config, SchemaTest, ClassicInitTest
d26921b851c3 Python 3 preparation: make relative imports explicit.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5319
diff changeset
25 from .db_test_base import ConcurrentDBTest, HTMLItemTest, FilterCacheTest
d26921b851c3 Python 3 preparation: make relative imports explicit.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5319
diff changeset
26 from .db_test_base import ClassicInitBase, setupTracker, SpecialActionTest
5601
fcbeff272828 Integrate REST tests into db framework
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5388
diff changeset
27 from .rest_common import TestCase as RestTestCase
1906
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
28
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
29 if not have_backend('postgresql'):
5109
43a1f7fe39f5 Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents: 5105
diff changeset
30 # FIX: workaround for a bug in pytest.mark.skip():
43a1f7fe39f5 Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents: 5105
diff changeset
31 # https://github.com/pytest-dev/pytest/issues/568
43a1f7fe39f5 Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents: 5105
diff changeset
32 from .pytest_patcher import mark_class
43a1f7fe39f5 Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents: 5105
diff changeset
33 skip_postgresql = mark_class(pytest.mark.skip(
43a1f7fe39f5 Improved work-around for pytest markers bug
John Kristensen <john@jerrykan.com>
parents: 5105
diff changeset
34 reason='Skipping PostgreSQL tests: backend not available'))
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
35 else:
5215
917e45d9ba08 test_postgress isn't properly skipping tests when database is not
John Rouillard <rouilj@ieee.org>
parents: 5118
diff changeset
36 try:
5751
5cb6e6b594b0 issue2551040: New release of psycopg2 drops support for psycopg1
John Rouillard <rouilj@ieee.org>
parents: 5601
diff changeset
37 from roundup.backends.back_postgresql import psycopg2, db_command
5215
917e45d9ba08 test_postgress isn't properly skipping tests when database is not
John Rouillard <rouilj@ieee.org>
parents: 5118
diff changeset
38 db_command(config, 'select 1')
917e45d9ba08 test_postgress isn't properly skipping tests when database is not
John Rouillard <rouilj@ieee.org>
parents: 5118
diff changeset
39 skip_postgresql = lambda func, *args, **kwargs: func
917e45d9ba08 test_postgress isn't properly skipping tests when database is not
John Rouillard <rouilj@ieee.org>
parents: 5118
diff changeset
40 except( DatabaseError ) as msg:
917e45d9ba08 test_postgress isn't properly skipping tests when database is not
John Rouillard <rouilj@ieee.org>
parents: 5118
diff changeset
41 from .pytest_patcher import mark_class
917e45d9ba08 test_postgress isn't properly skipping tests when database is not
John Rouillard <rouilj@ieee.org>
parents: 5118
diff changeset
42 skip_postgresql = mark_class(pytest.mark.skip(
917e45d9ba08 test_postgress isn't properly skipping tests when database is not
John Rouillard <rouilj@ieee.org>
parents: 5118
diff changeset
43 reason='Skipping PostgreSQL tests: database not available'))
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
44
5215
917e45d9ba08 test_postgress isn't properly skipping tests when database is not
John Rouillard <rouilj@ieee.org>
parents: 5118
diff changeset
45 @skip_postgresql
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
46 class postgresqlOpener:
2856
adec352e2ce0 don't try to import all backends in backends.__init__ unless we *want* to
Richard Jones <richard@users.sourceforge.net>
parents: 2682
diff changeset
47 if have_backend('postgresql'):
adec352e2ce0 don't try to import all backends in backends.__init__ unless we *want* to
Richard Jones <richard@users.sourceforge.net>
parents: 2682
diff changeset
48 module = get_backend('postgresql')
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
49
6622
2a3bd715bbeb Cleanup db on start.
John Rouillard <rouilj@ieee.org>
parents: 6605
diff changeset
50 def setup_class(cls):
2a3bd715bbeb Cleanup db on start.
John Rouillard <rouilj@ieee.org>
parents: 6605
diff changeset
51 # nuke the db once for the class. Handles the case
2a3bd715bbeb Cleanup db on start.
John Rouillard <rouilj@ieee.org>
parents: 6605
diff changeset
52 # where an aborted test run (^C during setUp for example)
2a3bd715bbeb Cleanup db on start.
John Rouillard <rouilj@ieee.org>
parents: 6605
diff changeset
53 # leaves the database in an unusable, partly configured state.
2a3bd715bbeb Cleanup db on start.
John Rouillard <rouilj@ieee.org>
parents: 6605
diff changeset
54 try:
2a3bd715bbeb Cleanup db on start.
John Rouillard <rouilj@ieee.org>
parents: 6605
diff changeset
55 cls.nuke_database(cls)
2a3bd715bbeb Cleanup db on start.
John Rouillard <rouilj@ieee.org>
parents: 6605
diff changeset
56 except:
2a3bd715bbeb Cleanup db on start.
John Rouillard <rouilj@ieee.org>
parents: 6605
diff changeset
57 # ignore failure to nuke the database.
2a3bd715bbeb Cleanup db on start.
John Rouillard <rouilj@ieee.org>
parents: 6605
diff changeset
58 pass
2a3bd715bbeb Cleanup db on start.
John Rouillard <rouilj@ieee.org>
parents: 6605
diff changeset
59
1906
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
60 def setUp(self):
2075
b1704ba7be41 make mysql / postgresql work again. beginnings of otk/session store in rdbmses
Richard Jones <richard@users.sourceforge.net>
parents: 1920
diff changeset
61 pass
1906
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
62
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
63 def tearDown(self):
1920
f9316d2cd5ba Fixed retirement of items in rdbms imports [SF#841355]
Richard Jones <richard@users.sourceforge.net>
parents: 1906
diff changeset
64 self.nuke_database()
f9316d2cd5ba Fixed retirement of items in rdbms imports [SF#841355]
Richard Jones <richard@users.sourceforge.net>
parents: 1906
diff changeset
65
f9316d2cd5ba Fixed retirement of items in rdbms imports [SF#841355]
Richard Jones <richard@users.sourceforge.net>
parents: 1906
diff changeset
66 def nuke_database(self):
2075
b1704ba7be41 make mysql / postgresql work again. beginnings of otk/session store in rdbmses
Richard Jones <richard@users.sourceforge.net>
parents: 1920
diff changeset
67 # clear out the database - easiest way is to nuke and re-create it
2856
adec352e2ce0 don't try to import all backends in backends.__init__ unless we *want* to
Richard Jones <richard@users.sourceforge.net>
parents: 2682
diff changeset
68 self.module.db_nuke(config)
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
69
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
70
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
71 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
72 class postgresqlDBTest(postgresqlOpener, DBTest, unittest.TestCase):
1906
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
73 def setUp(self):
6915
9ff091537f43 postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents: 6806
diff changeset
74 # set for manual integration testing of 'native-fts'
9ff091537f43 postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents: 6806
diff changeset
75 # It is unset in tearDown so it doesn't leak into other tests.
9ff091537f43 postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents: 6806
diff changeset
76 # FIXME extract test methods in DBTest that hit the indexer
9ff091537f43 postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents: 6806
diff changeset
77 # into a new class (DBTestIndexer). Add DBTestIndexer
9ff091537f43 postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents: 6806
diff changeset
78 # to this class.
9ff091537f43 postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents: 6806
diff changeset
79 # Then create a new class in this file:
9ff091537f43 postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents: 6806
diff changeset
80 # postgresqlDBTestIndexerNative_FTS
9ff091537f43 postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents: 6806
diff changeset
81 # that imports from DBestIndexer to test native-fts.
9ff091537f43 postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents: 6806
diff changeset
82 # config['INDEXER'] = 'native-fts'
1906
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
83 postgresqlOpener.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
84 DBTest.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
85
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
86 def tearDown(self):
6915
9ff091537f43 postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents: 6806
diff changeset
87 # clean up config to prevent leak if native-fts is tested
9ff091537f43 postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents: 6806
diff changeset
88 config['INDEXER'] = ''
1906
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
89 DBTest.tearDown(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
90 postgresqlOpener.tearDown(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
91
6599
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
92 def testUpgrade_6_to_7(self):
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
93
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
94 # load the database
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
95 self.db.issue.create(title="flebble frooz")
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
96 self.db.commit()
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
97
6806
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
98 if self.db.database_schema['version'] > 7:
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
99 # make testUpgrades run the downgrade code only.
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
100 if hasattr(self, "downgrade_only"):
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
101 # we are being called by an earlier test
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
102 self.testUpgrade_7_to_8()
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
103 self.assertEqual(self.db.database_schema['version'], 7)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
104 else:
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
105 # we are being called directly
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
106 self.downgrade_only = True
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
107 self.testUpgrade_7_to_8()
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
108 self.assertEqual(self.db.database_schema['version'], 7)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
109 del(self.downgrade_only)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
110 elif self.db.database_schema['version'] != 7:
6599
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
111 self.skipTest("This test only runs for database version 7")
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
112
6604
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
113 # remove __fts table/index; shrink length of __words._words
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
114 # trying to insert a long word in __words._words should fail.
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
115 # trying to select from __fts should fail
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
116 # looking for the index should fail
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
117 # run post-init
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
118 # tests should succeed.
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
119
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
120 self.db.sql("drop table __fts") # also drops __fts_idx
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
121 self.db.sql("alter table __words ALTER column _word type varchar(10)")
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
122 self.db.commit()
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
123
6599
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
124 self.db.database_schema['version'] = 6
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
125
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
126 long_string = "a" * (self.db.indexer.maxlength + 5)
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
127 with self.assertRaises(psycopg2.DataError) as ctx:
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
128 # DataError : value too long for type character varying(10)
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
129 self.db.sql("insert into __words VALUES('%s',1)" % long_string)
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
130
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
131 self.assertIn("varying(10)", ctx.exception.args[0])
6604
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
132 self.db.rollback() # clear cursor error so db.sql can be used again
6599
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
133
6604
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
134 with self.assertRaises(psycopg2.errors.UndefinedTable) as ctx:
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
135 self.db.sql("select * from _fts")
6599
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
136 self.db.rollback()
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
137
6605
3f13ddd98e5c Replace does_index_exist with db.sql_index_exists.
John Rouillard <rouilj@ieee.org>
parents: 6604
diff changeset
138 self.assertFalse(self.db.sql_index_exists('__fts', '__fts_idx'))
6604
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
139
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
140 if hasattr(self, "downgrade_only"):
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
141 return
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
142
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
143 # test upgrade path
6599
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
144 self.db.post_init()
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
145
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
146 # This insert with text of expected column size should succeed
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
147 self.db.sql("insert into __words VALUES('%s',1)" % long_string)
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
148
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
149 # verify it fails at one more than the expected column size
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
150 too_long_string = "a" * (self.db.indexer.maxlength + 6)
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
151 with self.assertRaises(psycopg2.DataError) as ctx:
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
152 self.db.sql("insert into __words VALUES('%s',1)" % too_long_string)
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
153
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
154 # clean db handle
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
155 self.db.rollback()
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
156
6605
3f13ddd98e5c Replace does_index_exist with db.sql_index_exists.
John Rouillard <rouilj@ieee.org>
parents: 6604
diff changeset
157 self.assertTrue(self.db.sql_index_exists('__fts', '__fts_idx'))
6604
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
158
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
159 self.db.sql("select * from __fts")
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
160
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
161 self.assertEqual(self.db.database_schema['version'],
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
162 self.db.current_db_version)
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
163
6806
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
164 def testUpgrade_7_to_8(self):
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
165 """ change _time fields in BasicDatabases to double """
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
166 # load the database
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
167 self.db.issue.create(title="flebble frooz")
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
168 self.db.commit()
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
169
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
170 if self.db.database_schema['version'] != 8:
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
171 self.skipTest("This test only runs for database version 8")
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
172
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
173 # change otk and session db's _time value to their original types
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
174 sql = "alter table sessions alter column session_time type REAL;"
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
175 self.db.sql(sql)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
176 sql = "alter table otks alter column otk_time type REAL;"
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
177 self.db.sql(sql)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
178
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
179 # verify they truncate long ints.
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
180 test_double = 1658718284.7616878
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
181 for tablename in ['otk', 'session']:
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
182 self.db.sql(
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
183 'insert into %(name)ss(%(name)s_key, %(name)s_time, %(name)s_value) '
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
184 "values ('foo', %(double)s, 'value');"%{'name': tablename,
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
185 'double': test_double}
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
186 )
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
187
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
188 self.db.cursor.execute('select %(name)s_time from %(name)ss '
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
189 "where %(name)s_key = 'foo'"%{'name': tablename})
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
190
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
191 self.assertNotAlmostEqual(self.db.cursor.fetchone()[0],
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
192 test_double, -1)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
193
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
194 # cleanup or else the inserts after the upgrade will not
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
195 # work.
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
196 self.db.sql("delete from %(name)ss where %(name)s_key='foo'"%{
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
197 'name': tablename} )
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
198
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
199 self.db.database_schema['version'] = 7
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
200
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
201 if hasattr(self,"downgrade_only"):
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
202 return
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
203
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
204 # test upgrade altering row
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
205 self.db.post_init()
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
206
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
207 # verify they keep all signifcant digits before the decimal point
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
208 for tablename in ['otk', 'session']:
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
209 self.db.sql(
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
210 'insert into %(name)ss(%(name)s_key, %(name)s_time, %(name)s_value) '
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
211 "values ('foo', %(double)s, 'value');"%{'name': tablename,
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
212 'double': test_double}
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
213 )
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
214
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
215 self.db.cursor.execute('select %(name)s_time from %(name)ss '
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
216 "where %(name)s_key = 'foo'"%{'name': tablename})
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
217
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
218 self.assertAlmostEqual(self.db.cursor.fetchone()[0],
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
219 test_double, -1)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
220
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
221 self.assertEqual(self.db.database_schema['version'], 8)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
222
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
223 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
224 class postgresqlROTest(postgresqlOpener, ROTest, unittest.TestCase):
1906
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
225 def setUp(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
226 postgresqlOpener.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
227 ROTest.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
228
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
229 def tearDown(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
230 ROTest.tearDown(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
231 postgresqlOpener.tearDown(self)
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
232
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
233
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
234 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
235 class postgresqlConcurrencyTest(postgresqlOpener, ConcurrentDBTest,
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
236 unittest.TestCase):
4448
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
237 backend = 'postgresql'
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
238 def setUp(self):
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
239 postgresqlOpener.setUp(self)
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
240 ConcurrentDBTest.setUp(self)
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
241
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
242 def tearDown(self):
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
243 ConcurrentDBTest.tearDown(self)
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
244 postgresqlOpener.tearDown(self)
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
245
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
246
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
247 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
248 class postgresqlJournalTest(postgresqlOpener, ClassicInitBase,
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
249 unittest.TestCase):
4887
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
250 backend = 'postgresql'
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
251 def setUp(self):
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
252 postgresqlOpener.setUp(self)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
253 ClassicInitBase.setUp(self)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
254 self.tracker = setupTracker(self.dirname, self.backend)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
255 db = self.tracker.open('admin')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
256 self.id = db.issue.create(title='initial value')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
257 db.commit()
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
258 db.close()
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
259
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
260 def tearDown(self):
5118
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
261 try:
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
262 self.db1.close()
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
263 self.db2.close()
5751
5cb6e6b594b0 issue2551040: New release of psycopg2 drops support for psycopg1
John Rouillard <rouilj@ieee.org>
parents: 5601
diff changeset
264 except psycopg2.InterfaceError as exc:
5118
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
265 if 'connection already closed' in str(exc): pass
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
266 else: raise
4887
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
267 ClassicInitBase.tearDown(self)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
268 postgresqlOpener.tearDown(self)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
269
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
270 def _test_journal(self, expected_journal):
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
271 id = self.id
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
272 db1 = self.db1 = self.tracker.open('admin')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
273 db2 = self.db2 = self.tracker.open('admin')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
274
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
275 t1 = db1.issue.get(id, 'title')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
276 t2 = db2.issue.get(id, 'title')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
277
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
278 db1.issue.set (id, title='t1')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
279 db1.commit()
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
280 db1.close()
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
281
5118
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
282 # Test testConcurrentRepeatableRead is expected to raise
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
283 # an error when the db2.issue.set() call is executed.
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
284 try:
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
285 db2.issue.set (id, title='t2')
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
286 db2.commit()
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
287 finally:
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
288 # Make sure that the db2 connection is closed, even when
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
289 # an error is raised.
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
290 db2.close()
4887
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
291 self.db = self.tracker.open('admin')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
292 journal = self.db.getjournal('issue', id)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
293 for n, line in enumerate(journal):
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
294 self.assertEqual(line[4], expected_journal[n])
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
295
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
296 def testConcurrentReadCommitted(self):
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
297 expected_journal = [
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
298 {}, {'title': 'initial value'}, {'title': 'initial value'}
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
299 ]
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
300 self._test_journal(expected_journal)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
301
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
302 def testConcurrentRepeatableRead(self):
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
303 self.tracker.config.RDBMS_ISOLATION_LEVEL='repeatable read'
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
304 exc = self.module.TransactionRollbackError
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
305 self.assertRaises(exc, self._test_journal, [])
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
306
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
307
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
308 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
309 class postgresqlHTMLItemTest(postgresqlOpener, HTMLItemTest,
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
310 unittest.TestCase):
4878
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
311 backend = 'postgresql'
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
312 def setUp(self):
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
313 postgresqlOpener.setUp(self)
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
314 HTMLItemTest.setUp(self)
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
315
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
316 def tearDown(self):
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
317 HTMLItemTest.tearDown(self)
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
318 postgresqlOpener.tearDown(self)
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
319
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
320
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
321 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
322 class postgresqlFilterCacheTest(postgresqlOpener, FilterCacheTest,
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
323 unittest.TestCase):
4472
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
324 backend = 'postgresql'
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
325 def setUp(self):
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
326 postgresqlOpener.setUp(self)
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
327 FilterCacheTest.setUp(self)
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
328
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
329 def tearDown(self):
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
330 FilterCacheTest.tearDown(self)
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
331 postgresqlOpener.tearDown(self)
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
332
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
333
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
334 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
335 class postgresqlSchemaTest(postgresqlOpener, SchemaTest, unittest.TestCase):
1906
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
336 def setUp(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
337 postgresqlOpener.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
338 SchemaTest.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
339
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
340 def tearDown(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
341 SchemaTest.tearDown(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
342 postgresqlOpener.tearDown(self)
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
343
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
344
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
345 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
346 class postgresqlClassicInitTest(postgresqlOpener, ClassicInitTest,
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
347 unittest.TestCase):
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
348 backend = 'postgresql'
1906
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
349 def setUp(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
350 postgresqlOpener.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
351 ClassicInitTest.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
352
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
353 def tearDown(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
354 ClassicInitTest.tearDown(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
355 postgresqlOpener.tearDown(self)
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
356
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
357
5388
d26921b851c3 Python 3 preparation: make relative imports explicit.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5319
diff changeset
358 from .session_common import SessionTest
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
359 @skip_postgresql
5319
62de601bdf6f Fix commits although a Reject exception is raised
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5310
diff changeset
360 class postgresqlSessionTest(postgresqlOpener, SessionTest, unittest.TestCase):
6805
09d9c646ca89 Put in missing s2b needed for session list test.
John Rouillard <rouilj@ieee.org>
parents: 6622
diff changeset
361 s2b = lambda x,y : y
09d9c646ca89 Put in missing s2b needed for session list test.
John Rouillard <rouilj@ieee.org>
parents: 6622
diff changeset
362
2082
c091cacdc505 Finished implementation of session and one-time-key stores for RDBMS backends.
Richard Jones <richard@users.sourceforge.net>
parents: 2075
diff changeset
363 def setUp(self):
c091cacdc505 Finished implementation of session and one-time-key stores for RDBMS backends.
Richard Jones <richard@users.sourceforge.net>
parents: 2075
diff changeset
364 postgresqlOpener.setUp(self)
5319
62de601bdf6f Fix commits although a Reject exception is raised
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5310
diff changeset
365 SessionTest.setUp(self)
2082
c091cacdc505 Finished implementation of session and one-time-key stores for RDBMS backends.
Richard Jones <richard@users.sourceforge.net>
parents: 2075
diff changeset
366 def tearDown(self):
5319
62de601bdf6f Fix commits although a Reject exception is raised
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5310
diff changeset
367 SessionTest.tearDown(self)
2082
c091cacdc505 Finished implementation of session and one-time-key stores for RDBMS backends.
Richard Jones <richard@users.sourceforge.net>
parents: 2075
diff changeset
368 postgresqlOpener.tearDown(self)
c091cacdc505 Finished implementation of session and one-time-key stores for RDBMS backends.
Richard Jones <richard@users.sourceforge.net>
parents: 2075
diff changeset
369
5310
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
370 @skip_postgresql
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
371 class postgresqlSpecialActionTestCase(postgresqlOpener, SpecialActionTest,
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
372 unittest.TestCase):
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
373 backend = 'postgresql'
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
374 def setUp(self):
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
375 postgresqlOpener.setUp(self)
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
376 SpecialActionTest.setUp(self)
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
377
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
378 def tearDown(self):
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
379 SpecialActionTest.tearDown(self)
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
380 postgresqlOpener.tearDown(self)
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
381
5601
fcbeff272828 Integrate REST tests into db framework
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5388
diff changeset
382 @skip_postgresql
fcbeff272828 Integrate REST tests into db framework
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5388
diff changeset
383 class postgresqlRestTest (RestTestCase, unittest.TestCase):
fcbeff272828 Integrate REST tests into db framework
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5388
diff changeset
384 backend = 'postgresql'
fcbeff272828 Integrate REST tests into db framework
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5388
diff changeset
385
2682
93c58a68061b rdbms settings are now common for all backends.
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2358
diff changeset
386 # vim: set et sts=4 sw=4 :

Roundup Issue Tracker: http://roundup-tracker.org/