From 12d8cbc4af9d1376e4d56718788a00227e7d36b3 Mon Sep 17 00:00:00 2001 From: Pedro Crespo-Valero <32402063+pcrespov@users.noreply.github.com> Date: Thu, 20 Mar 2025 10:25:25 +0100 Subject: [PATCH 1/3] compares oecs --- packages/service-library/tests/test_logging_errors.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/service-library/tests/test_logging_errors.py b/packages/service-library/tests/test_logging_errors.py index 8bbbee60d406..2b7746205fb0 100644 --- a/packages/service-library/tests/test_logging_errors.py +++ b/packages/service-library/tests/test_logging_errors.py @@ -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, @@ -22,7 +21,10 @@ class MyError(OsparcErrorMixin, RuntimeError): exc = exc_info.value error_code = create_error_code(exc) - assert exc.error_code() == error_code + fp1, ts1 = parse_error_code_parts(error_code) + fp2, ts2 = parse_error_code_parts(exc.error_code()) + assert fp1 == fp2 + assert ts1 <= ts2 msg = f"Nice message to user [{error_code}]" From 0e1eee69876de8b50d3325170771ced27fd0c36a Mon Sep 17 00:00:00 2001 From: Pedro Crespo-Valero <32402063+pcrespov@users.noreply.github.com> Date: Thu, 20 Mar 2025 10:26:16 +0100 Subject: [PATCH 2/3] minor --- packages/service-library/tests/test_logging_errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/service-library/tests/test_logging_errors.py b/packages/service-library/tests/test_logging_errors.py index 2b7746205fb0..25ef85c1c35d 100644 --- a/packages/service-library/tests/test_logging_errors.py +++ b/packages/service-library/tests/test_logging_errors.py @@ -47,7 +47,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" From 5b3546eccf8244552d87be303353924284892c05 Mon Sep 17 00:00:00 2001 From: Pedro Crespo-Valero <32402063+pcrespov@users.noreply.github.com> Date: Thu, 20 Mar 2025 10:30:03 +0100 Subject: [PATCH 3/3] names --- packages/service-library/tests/test_logging_errors.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/service-library/tests/test_logging_errors.py b/packages/service-library/tests/test_logging_errors.py index 25ef85c1c35d..ac99c2fd657c 100644 --- a/packages/service-library/tests/test_logging_errors.py +++ b/packages/service-library/tests/test_logging_errors.py @@ -21,10 +21,11 @@ class MyError(OsparcErrorMixin, RuntimeError): exc = exc_info.value error_code = create_error_code(exc) - fp1, ts1 = parse_error_code_parts(error_code) - fp2, ts2 = parse_error_code_parts(exc.error_code()) - assert fp1 == fp2 - assert ts1 <= ts2 + 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}]"