tests: fix readonly error messages for v1.1.54335+

the commit that made the changes
59aa1359c8
This commit is contained in:
Ivan Ladelshchikov 2018-03-14 13:01:41 +04:00 committed by Itai Shirav
parent 99de0f6637
commit 6673841bf9

View File

@ -20,11 +20,11 @@ class ReadonlyTestCase(TestCaseWithData):
list(self.database.select('SELECT * from $table', Person)) list(self.database.select('SELECT * from $table', Person))
with self.assertRaises(ServerError) as cm: with self.assertRaises(ServerError) as cm:
self.database.drop_table(Person) self.database.drop_table(Person)
self._check_db_readonly_err(cm.exception) self._check_db_readonly_err(cm.exception, drop_table=True)
with self.assertRaises(ServerError) as cm: with self.assertRaises(ServerError) as cm:
self.database.drop_database() self.database.drop_database()
self._check_db_readonly_err(cm.exception) self._check_db_readonly_err(cm.exception, drop_table=True)
except ServerError as e: except ServerError as e:
if e.code == 192 and e.message.startswith('Unknown user'): if e.code == 192 and e.message.startswith('Unknown user'):
raise unittest.SkipTest('Database user "%s" is not defined' % username) raise unittest.SkipTest('Database user "%s" is not defined' % username)
@ -33,9 +33,12 @@ class ReadonlyTestCase(TestCaseWithData):
finally: finally:
self.database = orig_database self.database = orig_database
def _check_db_readonly_err(self, exc): def _check_db_readonly_err(self, exc, drop_table=None):
self.assertEqual(exc.code, 164) self.assertEqual(exc.code, 164)
self.assertEqual(exc.message, 'Cannot execute query in readonly mode') if drop_table:
self.assertEqual(exc.message, 'Cannot drop table in readonly mode')
else:
self.assertEqual(exc.message, 'Cannot insert into table in readonly mode')
def test_readonly_db_with_default_user(self): def test_readonly_db_with_default_user(self):
self._test_readonly_db('default') self._test_readonly_db('default')