mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
refactor: dbapi exception mapping for dbapi's (#12869)
* refactor: dbapi exception mapping for dbapi's * fix test * fix lint * fix grammar on comment
This commit is contained in:
committed by
GitHub
parent
275e57f4f1
commit
6c018c0a28
@@ -14,7 +14,12 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from superset.db_engine_specs.clickhouse import ClickHouseEngineSpec
|
||||
from superset.db_engine_specs.exceptions import SupersetDBAPIDatabaseError
|
||||
from tests.db_engine_specs.base_tests import TestDbEngineSpec
|
||||
|
||||
|
||||
@@ -30,3 +35,13 @@ class TestClickHouseDbEngineSpec(TestDbEngineSpec):
|
||||
ClickHouseEngineSpec.convert_dttm("DATETIME", dttm),
|
||||
"toDateTime('2019-01-02 03:04:05')",
|
||||
)
|
||||
|
||||
def test_execute_connection_error(self):
|
||||
from urllib3.exceptions import NewConnectionError
|
||||
|
||||
cursor = mock.Mock()
|
||||
cursor.execute.side_effect = NewConnectionError(
|
||||
"Dummypool", message="Exception with sensitive data"
|
||||
)
|
||||
with pytest.raises(SupersetDBAPIDatabaseError) as ex:
|
||||
ClickHouseEngineSpec.execute(cursor, "SELECT col1 from table1")
|
||||
|
||||
Reference in New Issue
Block a user