43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import asdict
|
|
from typing import cast
|
|
|
|
import delta_barth._management
|
|
from delta_barth import errors
|
|
from delta_barth.types import Status
|
|
|
|
|
|
def test_error_handler_parsing():
|
|
predef_errs = errors.DATA_PIPELINE_STATUS_DESCR
|
|
|
|
err_hdlr = delta_barth._management.ErrorHandler()
|
|
assert err_hdlr.pipe_states is not None
|
|
parsed_pipe_errs = err_hdlr.pipe_states
|
|
parsed_pipe_errs = asdict(parsed_pipe_errs)
|
|
|
|
for err in predef_errs:
|
|
dopt_err = cast(Status, parsed_pipe_errs[err[0]])
|
|
assert isinstance(dopt_err, Status)
|
|
assert dopt_err.status_code == err[1]
|
|
assert dopt_err.description == err[2]
|
|
assert dopt_err.message == ""
|
|
|
|
err_hdlr._parse_data_pipe_states()
|
|
|
|
|
|
def test_error_handler_internal():
|
|
DESCRIPTION = "test case"
|
|
MESSAGE = "an error occurred"
|
|
ERR_CODE = 101
|
|
|
|
err_hdlr = delta_barth._management.ErrorHandler()
|
|
new_err = err_hdlr.error(
|
|
description=DESCRIPTION,
|
|
message=MESSAGE,
|
|
err_code=ERR_CODE,
|
|
)
|
|
assert new_err.status_code == ERR_CODE
|
|
assert new_err.description == DESCRIPTION
|
|
assert new_err.message == MESSAGE
|