Skip to content
Merged
Changes from 3 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
11 changes: 7 additions & 4 deletions packages/service-library/tests/test_logging_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import logging

import pytest

from common_library.error_codes import create_error_code
from common_library.error_codes import create_error_code, parse_error_code_parts
from common_library.errors_classes import OsparcErrorMixin
from servicelib.logging_errors import (
create_troubleshotting_log_kwargs,
Expand All @@ -22,7 +21,11 @@ class MyError(OsparcErrorMixin, RuntimeError):
exc = exc_info.value
error_code = create_error_code(exc)

assert exc.error_code() == error_code
eoc1_fingerprint, eoc1_snapshot = parse_error_code_parts(error_code)
eoc2_fingerprint, eoc2_snapshot = parse_error_code_parts(exc.error_code())

assert eoc1_fingerprint == eoc2_fingerprint
assert eoc1_snapshot <= eoc2_snapshot

msg = f"Nice message to user [{error_code}]"

Expand All @@ -45,7 +48,7 @@ class MyError(OsparcErrorMixin, RuntimeError):
assert log_kwargs["extra"] is not None
assert (
# pylint: disable=unsubscriptable-object
log_kwargs["extra"]["log_uid"]
log_kwargs["extra"].get("log_uid")
== "123"
), "user_id is injected as extra from context"

Expand Down
Loading