-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathtest_arrow_error_decorator.py
More file actions
33 lines (27 loc) · 1.01 KB
/
test_arrow_error_decorator.py
File metadata and controls
33 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pyarrow.flight as fl
import pytest
from feast.arrow_error_handler import arrow_client_error_handling_decorator
from feast.errors import PermissionNotFoundException
permissionError = PermissionNotFoundException("dummy_name", "dummy_project")
@arrow_client_error_handling_decorator
def decorated_method(error):
raise error
@pytest.mark.parametrize(
"error, expected_raised_error",
[
(fl.FlightError("Flight error: "), fl.FlightError("Flight error: ")),
(
fl.FlightError(f"Flight error: {permissionError.to_error_detail()}"),
permissionError,
),
(fl.FlightError("Test Error"), fl.FlightError("Test Error")),
(RuntimeError("Flight error: "), RuntimeError("Flight error: ")),
(permissionError, permissionError),
],
)
def test_rest_error_handling_with_feast_exception(error, expected_raised_error):
with pytest.raises(
type(expected_raised_error),
match=str(expected_raised_error),
):
decorated_method(error)