mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Cleanup.
This commit is contained in:
parent
b85c5bf6d9
commit
af3e1459c3
1 changed files with 2 additions and 8 deletions
|
@ -283,17 +283,11 @@ class MySQLTestCase(TestCase, LoaderModuleMockMixin):
|
|||
self._test_call(mysql.query, 'SELECT * FROM testdb', 'testdb', 'SELECT * FROM testdb')
|
||||
|
||||
def test_query_error(self):
|
||||
def mock_execute(cur, query):
|
||||
'''
|
||||
Mock of info method
|
||||
'''
|
||||
raise MySQLdb.OperationalError(9999, 'Something Went Wrong')
|
||||
|
||||
connect_mock = MagicMock()
|
||||
with patch.object(mysql, '_connect', connect_mock):
|
||||
with patch.dict(mysql.__salt__, {'config.option': MagicMock()}):
|
||||
with patch.object(mysql, '_execute') as execute_mock:
|
||||
execute_mock.side_effect = mock_execute
|
||||
side_effect = MySQLdb.OperationalError(9999, 'Something Went Wrong')
|
||||
with patch.object(mysql, '_execute', MagicMock(side_effect=side_effect)):
|
||||
mysql.query('testdb', 'SELECT * FROM testdb')
|
||||
self.assertIn('mysql.error', mysql.__context__)
|
||||
expected = 'MySQL Error 9999: Something Went Wrong'
|
||||
|
|
Loading…
Add table
Reference in a new issue