fix(Presto): catch DatabaseError when testing Presto views (#25559)

Co-authored-by: Rui Zhao <zhaorui@dropbox.com>
This commit is contained in:
Rui Zhao
2023-10-11 10:31:07 -07:00
committed by GitHub
parent d0f2c5581d
commit be3714e131
2 changed files with 6 additions and 4 deletions

View File

@@ -925,9 +925,11 @@ class TestPrestoDbEngineSpec(TestDbEngineSpec):
def test_get_create_view_database_error(self):
from pyhive.exc import DatabaseError
mock_execute = mock.MagicMock(side_effect=DatabaseError())
mock_execute = mock.MagicMock()
mock_fetch_data = mock.MagicMock(side_effect=DatabaseError())
database = mock.MagicMock()
database.get_raw_connection().__enter__().cursor().execute = mock_execute
database.get_raw_connection().__enter__().cursor().fetchall = mock_fetch_data
schema = "schema"
table = "table"
result = PrestoEngineSpec.get_create_view(database, schema=schema, table=table)