Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/firebolt/async_db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
)
from firebolt.async_db.connection import Connection, connect
from firebolt.async_db.cursor import Cursor
from firebolt.common.exception import (
DatabaseError,
DataError,
Error,
IntegrityError,
InterfaceError,
InternalError,
NotSupportedError,
OperationalError,
ProgrammingError,
Warning,
)

apilevel = "2.0"
# threads may only share the module and connections, cursors should not be shared
Expand Down
12 changes: 12 additions & 0 deletions src/firebolt/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
Timestamp,
TimestampFromTicks,
)
from firebolt.common.exception import (
DatabaseError,
DataError,
Error,
IntegrityError,
InterfaceError,
InternalError,
NotSupportedError,
OperationalError,
ProgrammingError,
Warning,
)
from firebolt.db.connection import Connection, connect
from firebolt.db.cursor import Cursor

Expand Down
7 changes: 7 additions & 0 deletions tests/unit/async_db/test_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import firebolt.async_db


def test_has_exceptions(db_api_exceptions):
"""Verify async module has top-level dbapi exceptions exposed"""
for ex_name, ex_class in db_api_exceptions.items():
assert issubclass(getattr(firebolt.async_db, ex_name), ex_class)
29 changes: 29 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
from pytest_httpx import to_response
from pytest_httpx._httpx_internals import Response

from firebolt.common.exception import (
DatabaseError,
DataError,
Error,
IntegrityError,
InterfaceError,
InternalError,
NotSupportedError,
OperationalError,
ProgrammingError,
Warning,
)
from firebolt.common.settings import Settings
from firebolt.common.urls import (
ACCOUNT_ENGINE_URL,
Expand Down Expand Up @@ -202,3 +214,20 @@ def get_engines_url(settings: Settings) -> str:
@pytest.fixture
def get_databases_url(settings: Settings) -> str:
return f"https://{settings.server}{DATABASES_URL}"


@pytest.fixture
def db_api_exceptions():
exceptions = {
"DatabaseError": DatabaseError,
"DataError": DataError,
"Error": Error,
"IntegrityError": IntegrityError,
"InterfaceError": InterfaceError,
"InternalError": InternalError,
"NotSupportedError": NotSupportedError,
"OperationalError": OperationalError,
"ProgrammingError": ProgrammingError,
"Warning": Warning,
}
return exceptions
7 changes: 7 additions & 0 deletions tests/unit/db/test_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import firebolt.db


def test_has_exceptions(db_api_exceptions):
"""Verify sync module has top-level dbapi exceptions exposed"""
for ex_name, ex_class in db_api_exceptions.items():
assert issubclass(getattr(firebolt.db, ex_name), ex_class)