annotate test/test_postgresql.py @ 6825:b04e44db7d8d

Modify unique token to use url safe characters. Looks like the merge of the methods I chose cause url unsafe / to be emitted sometimes. This causes poe post to fail as the url includes the key and the / messes up the rest route url parsing code.
author John Rouillard <rouilj@ieee.org>
date Sun, 07 Aug 2022 03:33:35 -0400
parents bdd28b244839
children 9ff091537f43
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):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
74 postgresqlOpener.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
75 DBTest.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
76
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
77 def tearDown(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
78 DBTest.tearDown(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
79 postgresqlOpener.tearDown(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
80
6599
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
81 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
82
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
83 # load the database
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
84 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
85 self.db.commit()
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
86
6806
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
87 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
88 # 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
89 if hasattr(self, "downgrade_only"):
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
90 # 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
91 self.testUpgrade_7_to_8()
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
92 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
93 else:
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
94 # we are being called directly
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
95 self.downgrade_only = True
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
96 self.testUpgrade_7_to_8()
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
97 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
98 del(self.downgrade_only)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
99 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
100 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
101
6604
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
102 # 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
103 # 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
104 # 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
105 # 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
106 # run post-init
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
107 # tests should succeed.
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
108
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
109 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
110 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
111 self.db.commit()
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
112
6599
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
113 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
114
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
115 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
116 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
117 # 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
118 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
119
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
120 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
121 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
122
6604
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
123 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
124 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
125 self.db.rollback()
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
126
6605
3f13ddd98e5c Replace does_index_exist with db.sql_index_exists.
John Rouillard <rouilj@ieee.org>
parents: 6604
diff changeset
127 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
128
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
129 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
130 return
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
131
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
132 # test upgrade path
6599
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
133 self.db.post_init()
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
134
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
135 # 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
136 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
137
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
138 # 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
139 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
140 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
141 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
142
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
143 # clean db handle
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
144 self.db.rollback()
39189dd94f2c issue2551189 - increase size of words in full text index.
John Rouillard <rouilj@ieee.org>
parents: 5751
diff changeset
145
6605
3f13ddd98e5c Replace does_index_exist with db.sql_index_exists.
John Rouillard <rouilj@ieee.org>
parents: 6604
diff changeset
146 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
147
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
148 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
149
0d99ae7c8de6 Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents: 6599
diff changeset
150 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
151 self.db.current_db_version)
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
152
6806
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
153 def testUpgrade_7_to_8(self):
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
154 """ 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
155 # load the database
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
156 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
157 self.db.commit()
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
158
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
159 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
160 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
161
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
162 # 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
163 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
164 self.db.sql(sql)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
165 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
166 self.db.sql(sql)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
167
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
168 # verify they truncate long ints.
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
169 test_double = 1658718284.7616878
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
170 for tablename in ['otk', 'session']:
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
171 self.db.sql(
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
172 '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
173 "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
174 'double': test_double}
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
175 )
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
176
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
177 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
178 "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
179
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
180 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
181 test_double, -1)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
182
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
183 # 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
184 # work.
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
185 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
186 'name': tablename} )
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.database_schema['version'] = 7
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
189
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
190 if hasattr(self,"downgrade_only"):
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
191 return
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
192
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
193 # test upgrade altering row
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
194 self.db.post_init()
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
195
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
196 # 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
197 for tablename in ['otk', 'session']:
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
198 self.db.sql(
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
199 '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
200 "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
201 'double': test_double}
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
202 )
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 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
205 "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
206
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
207 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
208 test_double, -1)
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
209
bdd28b244839 - issue2551223 - fix timestamp truncation in mysql and postgresql
John Rouillard <rouilj@ieee.org>
parents: 6805
diff changeset
210 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
211
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
212 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
213 class postgresqlROTest(postgresqlOpener, ROTest, unittest.TestCase):
1906
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
214 def setUp(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
215 postgresqlOpener.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
216 ROTest.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
217
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
218 def tearDown(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
219 ROTest.tearDown(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
220 postgresqlOpener.tearDown(self)
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
221
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
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 postgresqlConcurrencyTest(postgresqlOpener, ConcurrentDBTest,
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
225 unittest.TestCase):
4448
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
226 backend = 'postgresql'
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
227 def setUp(self):
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
228 postgresqlOpener.setUp(self)
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
229 ConcurrentDBTest.setUp(self)
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
230
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
231 def tearDown(self):
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
232 ConcurrentDBTest.tearDown(self)
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
233 postgresqlOpener.tearDown(self)
2784c239e6c8 clear the cache on commit for rdbms backends:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 3685
diff changeset
234
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
235
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
236 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
237 class postgresqlJournalTest(postgresqlOpener, ClassicInitBase,
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
238 unittest.TestCase):
4887
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
239 backend = 'postgresql'
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
240 def setUp(self):
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
241 postgresqlOpener.setUp(self)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
242 ClassicInitBase.setUp(self)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
243 self.tracker = setupTracker(self.dirname, self.backend)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
244 db = self.tracker.open('admin')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
245 self.id = db.issue.create(title='initial value')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
246 db.commit()
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
247 db.close()
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
248
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
249 def tearDown(self):
5118
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
250 try:
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
251 self.db1.close()
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
252 self.db2.close()
5751
5cb6e6b594b0 issue2551040: New release of psycopg2 drops support for psycopg1
John Rouillard <rouilj@ieee.org>
parents: 5601
diff changeset
253 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
254 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
255 else: raise
4887
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
256 ClassicInitBase.tearDown(self)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
257 postgresqlOpener.tearDown(self)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
258
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
259 def _test_journal(self, expected_journal):
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
260 id = self.id
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
261 db1 = self.db1 = self.tracker.open('admin')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
262 db2 = self.db2 = self.tracker.open('admin')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
263
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
264 t1 = db1.issue.get(id, 'title')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
265 t2 = db2.issue.get(id, 'title')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
266
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
267 db1.issue.set (id, title='t1')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
268 db1.commit()
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
269 db1.close()
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
270
5118
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
271 # 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
272 # 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
273 try:
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
274 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
275 db2.commit()
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
276 finally:
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
277 # 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
278 # an error is raised.
57452bc6d989 issue2550853 - better error handling and cleanup on some postgres
John Rouillard <rouilj@ieee.org>
parents: 5109
diff changeset
279 db2.close()
4887
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
280 self.db = self.tracker.open('admin')
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
281 journal = self.db.getjournal('issue', id)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
282 for n, line in enumerate(journal):
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
283 self.assertEqual(line[4], expected_journal[n])
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
284
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
285 def testConcurrentReadCommitted(self):
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
286 expected_journal = [
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
287 {}, {'title': 'initial value'}, {'title': 'initial value'}
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
288 ]
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
289 self._test_journal(expected_journal)
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
290
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
291 def testConcurrentRepeatableRead(self):
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
292 self.tracker.config.RDBMS_ISOLATION_LEVEL='repeatable read'
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
293 exc = self.module.TransactionRollbackError
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
294 self.assertRaises(exc, self._test_journal, [])
05c857e5dbed New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4878
diff changeset
295
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
296
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
297 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
298 class postgresqlHTMLItemTest(postgresqlOpener, HTMLItemTest,
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
299 unittest.TestCase):
4878
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
300 backend = 'postgresql'
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
301 def setUp(self):
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
302 postgresqlOpener.setUp(self)
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
303 HTMLItemTest.setUp(self)
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
304
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
305 def tearDown(self):
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
306 HTMLItemTest.tearDown(self)
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
307 postgresqlOpener.tearDown(self)
f6e76a03b502 HTML* classes for cgi are now all new-style
Ralf Schlatterbeck <rsc@runtux.com>
parents: 4570
diff changeset
308
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
309
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
310 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
311 class postgresqlFilterCacheTest(postgresqlOpener, FilterCacheTest,
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
312 unittest.TestCase):
4472
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
313 backend = 'postgresql'
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
314 def setUp(self):
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
315 postgresqlOpener.setUp(self)
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
316 FilterCacheTest.setUp(self)
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
317
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
318 def tearDown(self):
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
319 FilterCacheTest.tearDown(self)
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
320 postgresqlOpener.tearDown(self)
34dce76bb202 Multilink fixes and optimizations:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents: 4448
diff changeset
321
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
322
5036
380d8d8b30a3 Replace existing run_tests.py script with a pytest script
John Kristensen <john@jerrykan.com>
parents: 5033
diff changeset
323 @skip_postgresql
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
324 class postgresqlSchemaTest(postgresqlOpener, SchemaTest, unittest.TestCase):
1906
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
325 def setUp(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
326 postgresqlOpener.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
327 SchemaTest.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
328
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
329 def tearDown(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
330 SchemaTest.tearDown(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
331 postgresqlOpener.tearDown(self)
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
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 postgresqlClassicInitTest(postgresqlOpener, ClassicInitTest,
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
336 unittest.TestCase):
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
337 backend = 'postgresql'
1906
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
338 def setUp(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
339 postgresqlOpener.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
340 ClassicInitTest.setUp(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
341
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
342 def tearDown(self):
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
343 ClassicInitTest.tearDown(self)
f255363e6d97 PostgreSQL backend lands.
Richard Jones <richard@users.sourceforge.net>
parents: 1877
diff changeset
344 postgresqlOpener.tearDown(self)
1873
f63aa57386b0 Backend improvements.
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
345
5033
63c79c0992ae Update tests to work with py.test
John Kristensen <john@jerrykan.com>
parents: 4887
diff changeset
346
5388
d26921b851c3 Python 3 preparation: make relative imports explicit.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5319
diff changeset
347 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
348 @skip_postgresql
5319
62de601bdf6f Fix commits although a Reject exception is raised
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5310
diff changeset
349 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
350 s2b = lambda x,y : y
09d9c646ca89 Put in missing s2b needed for session list test.
John Rouillard <rouilj@ieee.org>
parents: 6622
diff changeset
351
2082
c091cacdc505 Finished implementation of session and one-time-key stores for RDBMS backends.
Richard Jones <richard@users.sourceforge.net>
parents: 2075
diff changeset
352 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
353 postgresqlOpener.setUp(self)
5319
62de601bdf6f Fix commits although a Reject exception is raised
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5310
diff changeset
354 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
355 def tearDown(self):
5319
62de601bdf6f Fix commits although a Reject exception is raised
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5310
diff changeset
356 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
357 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
358
5310
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
359 @skip_postgresql
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
360 class postgresqlSpecialActionTestCase(postgresqlOpener, SpecialActionTest,
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
361 unittest.TestCase):
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
362 backend = 'postgresql'
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
363 def setUp(self):
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
364 postgresqlOpener.setUp(self)
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
365 SpecialActionTest.setUp(self)
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
366
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
367 def tearDown(self):
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
368 SpecialActionTest.tearDown(self)
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
369 postgresqlOpener.tearDown(self)
efb34cbdba7c Add (currently failing) test for atomic actions
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5248
diff changeset
370
5601
fcbeff272828 Integrate REST tests into db framework
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5388
diff changeset
371 @skip_postgresql
fcbeff272828 Integrate REST tests into db framework
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5388
diff changeset
372 class postgresqlRestTest (RestTestCase, unittest.TestCase):
fcbeff272828 Integrate REST tests into db framework
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5388
diff changeset
373 backend = 'postgresql'
fcbeff272828 Integrate REST tests into db framework
Ralf Schlatterbeck <rsc@runtux.com>
parents: 5388
diff changeset
374
2682
93c58a68061b rdbms settings are now common for all backends.
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2358
diff changeset
375 # vim: set et sts=4 sw=4 :

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