diff --git a/tests/test_core_sdk.py b/tests/test_core_sdk.py index 8d761794..b2292542 100644 --- a/tests/test_core_sdk.py +++ b/tests/test_core_sdk.py @@ -249,7 +249,7 @@ 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() @@ -257,7 +257,7 @@ def test_create_update_trace(): 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 @@ -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 @@ -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 diff --git a/tests/test_decorators.py b/tests/test_decorators.py index c5090e48..7db46e2f 100644 --- a/tests/test_decorators.py +++ b/tests/test_decorators.py @@ -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 @@ -227,6 +228,7 @@ def level_1_function(*args, **kwargs): ) langfuse_context.flush() + sleep(1) trace_data = get_api().trace.get(mock_trace_id) @@ -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) @@ -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" diff --git a/tests/test_langchain.py b/tests/test_langchain.py index 3f3bcc6c..8e66a84e 100644 --- a/tests/test_langchain.py +++ b/tests/test_langchain.py @@ -2,6 +2,7 @@ import random import string import time +from time import sleep from typing import Any, Dict, List, Mapping, Optional import pytest @@ -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())