Skip to content

Commit

Permalink
fix: try fixing test again
Browse files Browse the repository at this point in the history
  • Loading branch information
tito committed Jan 23, 2025
1 parent bd57d20 commit 9af6efb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 5 additions & 2 deletions scope3ai/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
4 changes: 1 addition & 3 deletions scope3ai/worker.py
Original file line number Diff line number Diff line change
@@ -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")


Expand Down
10 changes: 10 additions & 0 deletions tests/test_lib_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()

0 comments on commit 9af6efb

Please sign in to comment.