From 9af6efbb561fd03b174befc7c7ca4ae811f18418 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Wed, 22 Jan 2025 19:12:38 -0600 Subject: [PATCH] fix: try fixing test again --- scope3ai/lib.py | 7 +++++-- scope3ai/worker.py | 4 +--- tests/test_lib_metadata.py | 10 ++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/scope3ai/lib.py b/scope3ai/lib.py index f451794..7fd90fb 100644 --- a/scope3ai/lib.py +++ b/scope3ai/lib.py @@ -444,5 +444,8 @@ def set_only_if(row, field, *values): tracer.application_id if tracer else None, self.application_id, ) - if row.session_id is None and tracer: - row.session_id = tracer.session_id + set_only_if( + row, + "session_id", + tracer.session_id if tracer else None, + ) diff --git a/scope3ai/worker.py b/scope3ai/worker.py index ab77355..01384a2 100644 --- a/scope3ai/worker.py +++ b/scope3ai/worker.py @@ -1,11 +1,9 @@ import logging import queue import threading -from time import sleep +from time import monotonic, sleep from typing import Callable, Optional -from time import monotonic - logger = logging.getLogger("scope3ai.worker") diff --git a/tests/test_lib_metadata.py b/tests/test_lib_metadata.py index 784329a..ce39750 100644 --- a/tests/test_lib_metadata.py +++ b/tests/test_lib_metadata.py @@ -89,6 +89,8 @@ def test_impact_row_no_tracer(init_env, tracer_init): assert request.client_id == "client_id" assert request.project_id == "project_id" + tracer_init._worker.resume() + def test_impact_row_with_tracer(init_env, tracer_init): from scope3ai.api.types import ImpactRow @@ -114,6 +116,8 @@ def test_impact_row_with_tracer(init_env, tracer_init): assert request.client_id == "client_id_2" assert request.project_id == "project_id_2" + tracer_init._worker.resume() + def test_impact_row_with_nested_tracer(init_env, tracer_init): from scope3ai.api.types import ImpactRow @@ -141,6 +145,8 @@ def test_impact_row_with_nested_tracer(init_env, tracer_init): assert request.client_id == "client_id_2" assert request.project_id == "project_id_3" + tracer_init._worker.resume() + def test_impact_row_with_session_id(tracer_init): from scope3ai.api.types import ImpactRow @@ -160,6 +166,8 @@ def test_impact_row_with_session_id(tracer_init): assert request.trace_id == tracer.trace_id assert request.session_id == "session_id_1" + tracer_init._worker.resume() + def test_impact_row_nested_with_session_id(tracer_init): from scope3ai.api.types import ImpactRow @@ -181,3 +189,5 @@ def test_impact_row_nested_with_session_id(tracer_init): assert request.request_id is not None assert request.trace_id == tracer.trace_id assert request.session_id == "session_id_2" + + tracer_init._worker.resume()