Skip to content

Commit 2e67b17

Browse files
authored
✅ Fixes flaky test: create_troubleshotting_log_message (ITISFoundation#7400)
1 parent b5230f1 commit 2e67b17

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/service-library/tests/test_logging_errors.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import logging
44

55
import pytest
6-
7-
from common_library.error_codes import create_error_code
6+
from common_library.error_codes import create_error_code, parse_error_code_parts
87
from common_library.errors_classes import OsparcErrorMixin
98
from servicelib.logging_errors import (
109
create_troubleshotting_log_kwargs,
@@ -22,7 +21,11 @@ class MyError(OsparcErrorMixin, RuntimeError):
2221
exc = exc_info.value
2322
error_code = create_error_code(exc)
2423

25-
assert exc.error_code() == error_code
24+
eoc1_fingerprint, eoc1_snapshot = parse_error_code_parts(error_code)
25+
eoc2_fingerprint, eoc2_snapshot = parse_error_code_parts(exc.error_code())
26+
27+
assert eoc1_fingerprint == eoc2_fingerprint
28+
assert eoc1_snapshot <= eoc2_snapshot
2629

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

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

0 commit comments

Comments
 (0)