comparison test/test_mysql.py @ 6638:e1588ae185dc issue2550923_computed_property

merge from default branch. Fix travis.ci so CI builds don't error out
author John Rouillard <rouilj@ieee.org>
date Thu, 21 Apr 2022 16:54:17 -0400
parents 0d99ae7c8de6
children 09d9c646ca89
comparison
equal deleted inserted replaced
6508:85db90cc1705 6638:e1588ae185dc
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
78 # test by shrinking _words and trying to insert a long value
79 # it should fail.
80 # run post-init
81 # same test should succeed.
82
83 self.db.sql("alter table __words change column "
84 "_word _word varchar(10)")
85
86 long_string = "a" * (self.db.indexer.maxlength + 5)
87
88 with self.assertRaises(MySQLdb.DataError) as ctx:
89 # DataError : Data too long for column '_word' at row 1
90 self.db.sql("insert into __words VALUES('%s',1)" % long_string)
91
92 self.assertIn("Data too long for column '_word'",
93 ctx.exception.args[1])
94
95 self.db.database_schema['version'] = 6
96
97 if hasattr(self,"downgrade_only"):
98 return
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(MySQLdb.DataError) as ctx:
109 self.db.sql("insert into __words VALUES('%s',1)" % too_long_string)
110
111 self.assertEqual(self.db.database_schema['version'],
112 self.db.current_db_version)
68 113
69 @skip_mysql 114 @skip_mysql
70 class mysqlROTest(mysqlOpener, ROTest, unittest.TestCase): 115 class mysqlROTest(mysqlOpener, ROTest, unittest.TestCase):
71 def setUp(self): 116 def setUp(self):
72 mysqlOpener.setUp(self) 117 mysqlOpener.setUp(self)

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