def test_check_fail(self, conn_func_mock): conn_func_mock.return_value = conn = MagicMock() conn.ping.side_effect = mysql_mod.OperationalError ctx = _MySQLContext(one=1) self.assertFalse(ctx.check()) conn_func_mock.assert_called_with(one=1) conn.ping.assert_called_with()
def test_close(self, conn_func_mock): conn_func_mock.return_value = conn = MagicMock() ctx = _MySQLContext(one=1) ctx.close() conn_func_mock.assert_called_with(one=1) conn.close.assert_called_with()
def test_check(self, conn_func_mock): conn_func_mock.return_value = conn = MagicMock() ctx = _MySQLContext(one=1) self.assertTrue(ctx.check()) conn_func_mock.assert_called_with(one=1) conn.ping.assert_called_with()