|
a |
|
b/tests/unit/backends/test_emis.py |
|
|
1 |
import pytest |
|
|
2 |
from trino import exceptions as trino_exceptions |
|
|
3 |
|
|
|
4 |
from ehrql.backends.emis import EMISBackend |
|
|
5 |
|
|
|
6 |
|
|
|
7 |
@pytest.mark.parametrize( |
|
|
8 |
"exception", |
|
|
9 |
[ |
|
|
10 |
# These are trino errors that we may want to support in future with |
|
|
11 |
# custom exit codes, but currently inherit from the base method |
|
|
12 |
# Database errors |
|
|
13 |
trino_exceptions.DatabaseError, |
|
|
14 |
# OperationError is a subclass of DatabaseError |
|
|
15 |
trino_exceptions.OperationalError, |
|
|
16 |
# TrinoQueryError is encountered for over-complex/over-nested queries |
|
|
17 |
trino_exceptions.TrinoQueryError, |
|
|
18 |
# TrinoUserError is encountered for out of range numbers |
|
|
19 |
trino_exceptions.TrinoUserError, |
|
|
20 |
# TrinoUserError is encountered for bad/out of range dates |
|
|
21 |
trino_exceptions.TrinoDataError, |
|
|
22 |
], |
|
|
23 |
) |
|
|
24 |
def test_backend_exceptions(exception): |
|
|
25 |
backend = EMISBackend() |
|
|
26 |
assert backend.get_exit_status_for_exception(exception) is None |