comparison test/test_postgresql.py @ 6599:39189dd94f2c

issue2551189 - increase size of words in full text index. Increased indexed word maxlength to 50 DB migration code is written and tests work. Restructured some tests to allow for code reuse. Docs. If this passes CI without errors 2551189 should be done. However, testing on my system generates errors. Encoding (indexer unicode russian unicode string invalid) and collation errors (utf8_bin not valid) when running under python2. No issues with python3 and I haven't changed code that should cause these since the last successful build in CI. So if this fails in CI we will have more checkins.
author John Rouillard <rouilj@ieee.org>
date Wed, 26 Jan 2022 15:04:09 -0500
parents 5cb6e6b594b0
children 0d99ae7c8de6
comparison
equal deleted inserted replaced
6598:27a4ab499189 6599:39189dd94f2c
66 66
67 def tearDown(self): 67 def tearDown(self):
68 DBTest.tearDown(self) 68 DBTest.tearDown(self)
69 postgresqlOpener.tearDown(self) 69 postgresqlOpener.tearDown(self)
70 70
71 def testUpgrade_6_to_7(self):
72
73 # load the database
74 self.db.issue.create(title="flebble frooz")
75 self.db.commit()
76
77 if self.db.database_schema['version'] != 7:
78 self.skipTest("This test only runs for database version 7")
79
80 self.db.database_schema['version'] = 6
81
82 # test by shrinking _words and trying to insert a long value
83 # it should fail.
84 # run post-init
85 # same test should succeed.
86
87 self.db.sql("alter table __words ALTER column _word type varchar(10)")
88
89 long_string = "a" * (self.db.indexer.maxlength + 5)
90
91 with self.assertRaises(psycopg2.DataError) as ctx:
92 # DataError : value too long for type character varying(10)
93 self.db.sql("insert into __words VALUES('%s',1)" % long_string)
94
95 self.assertIn("varying(10)", ctx.exception.args[0])
96
97 # clear the cursor error so it can be used again
98 self.db.rollback()
99
100 # test upgrade altering row
101 self.db.post_init()
102
103 # This insert with text of expected column size should succeed
104 self.db.sql("insert into __words VALUES('%s',1)" % long_string)
105
106 # verify it fails at one more than the expected column size
107 too_long_string = "a" * (self.db.indexer.maxlength + 6)
108 with self.assertRaises(psycopg2.DataError) as ctx:
109 self.db.sql("insert into __words VALUES('%s',1)" % too_long_string)
110
111 # clean db handle
112 self.db.rollback()
113
71 114
72 @skip_postgresql 115 @skip_postgresql
73 class postgresqlROTest(postgresqlOpener, ROTest, unittest.TestCase): 116 class postgresqlROTest(postgresqlOpener, ROTest, unittest.TestCase):
74 def setUp(self): 117 def setUp(self):
75 postgresqlOpener.setUp(self) 118 postgresqlOpener.setUp(self)

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