Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
hassiebp committed Jan 12, 2025
1 parent e8b4807 commit 79622c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions tests/test_core_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,15 @@ def test_create_update_trace():
metadata={"key": "value"},
public=True,
)
trace.update(metadata={"key": "value2"}, public=False)
trace.update(metadata={"key2": "value2"}, public=False)

langfuse.flush()

trace = get_api().trace.get(trace.id)

assert trace.name == trace_name
assert trace.user_id == "test"
assert trace.metadata == {"key": "value2"}
assert trace.metadata == {"key": "value", "key2": "value2"}
assert trace.public is False


Expand Down Expand Up @@ -747,7 +747,7 @@ def test_create_span_and_get_observation():
langfuse.span(id=span_id, name="span")
langfuse.flush()

sleep(1)
sleep(2)
observation = langfuse.get_observation(span_id)
assert observation.name == "span"
assert observation.id == span_id
Expand Down Expand Up @@ -1414,7 +1414,7 @@ def test_fetch_sessions():
langfuse.flush()

# Fetch traces
sleep(1)
sleep(2)
response = langfuse.fetch_sessions()

# Assert the structure of the response, cannot check for the exact number of sessions as the table is not cleared between tests
Expand Down
6 changes: 4 additions & 2 deletions tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor
from contextvars import ContextVar
from time import sleep
from typing import Optional

import pytest
Expand Down Expand Up @@ -227,6 +228,7 @@ def level_1_function(*args, **kwargs):
)

langfuse_context.flush()
sleep(1)

trace_data = get_api().trace.get(mock_trace_id)

Expand Down Expand Up @@ -309,8 +311,7 @@ def level_1_function(*args, **kwargs):

langfuse_context.flush()

print("mock_id_1", mock_trace_id_1)
print("mock_id_2", mock_trace_id_2)
sleep(1)

for mock_id in [mock_trace_id_1, mock_trace_id_2]:
trace_data = get_api().trace.get(mock_id)
Expand Down Expand Up @@ -1416,6 +1417,7 @@ def main():
main(langfuse_observation_id=mock_trace_id)

langfuse_context.flush()
sleep(1)

trace_data = get_api().trace.get(mock_trace_id)
assert trace_data.name == "updated_name"
Expand Down
2 changes: 2 additions & 0 deletions tests/test_langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import random
import string
import time
from time import sleep
from typing import Any, Dict, List, Mapping, Optional

import pytest
Expand Down Expand Up @@ -1811,6 +1812,7 @@ def test_link_langfuse_prompts_invoke():
)

langfuse_handler.flush()
sleep(1)

trace = get_api().trace.get(langfuse_handler.get_trace_id())

Expand Down

0 comments on commit 79622c5

Please sign in to comment.