comparison test/test_mysql.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 778a9f455067
children 0d99ae7c8de6
comparison
equal deleted inserted replaced
6598:27a4ab499189 6599:39189dd94f2c
63 class mysqlDBTest(mysqlOpener, DBTest, unittest.TestCase): 63 class mysqlDBTest(mysqlOpener, DBTest, unittest.TestCase):
64 def setUp(self): 64 def setUp(self):
65 mysqlOpener.setUp(self) 65 mysqlOpener.setUp(self)
66 DBTest.setUp(self) 66 DBTest.setUp(self)
67 67
68 def testUpgrade_6_to_7(self):
69
70 # load the database
71 self.db.issue.create(title="flebble frooz")
72 self.db.commit()
73
74 if self.db.database_schema['version'] != 7:
75 self.skipTest("This test only runs for database version 7")
76
77 self.db.database_schema['version'] = 6
78
79 # test by shrinking _words and trying to insert a long value
80 # it should fail.
81 # run post-init
82 # same test should succeed.
83
84 self.db.sql("alter table __words change column "
85 "_word _word varchar(10)")
86
87 long_string = "a" * (self.db.indexer.maxlength + 5)
88
89 with self.assertRaises(MySQLdb.DataError) as ctx:
90 # DataError : Data too long for column '_word' at row 1
91 self.db.sql("insert into __words VALUES('%s',1)" % long_string)
92
93 self.assertIn("Data too long for column '_word'",
94 ctx.exception.args[1])
95
96 # test upgrade altering row
97 self.db.post_init()
98
99 # This insert with text of expected column size should succeed
100 self.db.sql("insert into __words VALUES('%s',1)" % long_string)
101
102 # Verify it fails at one more than the expected column size
103 too_long_string = "a" * (self.db.indexer.maxlength + 6)
104 with self.assertRaises(MySQLdb.DataError) as ctx:
105 self.db.sql("insert into __words VALUES('%s',1)" % too_long_string)
68 106
69 @skip_mysql 107 @skip_mysql
70 class mysqlROTest(mysqlOpener, ROTest, unittest.TestCase): 108 class mysqlROTest(mysqlOpener, ROTest, unittest.TestCase):
71 def setUp(self): 109 def setUp(self):
72 mysqlOpener.setUp(self) 110 mysqlOpener.setUp(self)

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