Skip to content

Commit

Permalink
Improve test, previous version always returned 200
Browse files Browse the repository at this point in the history
  • Loading branch information
vblagoje committed May 2, 2024
1 parent e7730f7 commit 6171b15
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions integrations/langfuse/tests/test_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ def test_tracing_integration():
)
assert "Berlin" in response["llm"]["replies"][0].content
assert response["tracer"]["trace_url"]
url = "https://cloud.langfuse.com/api/public/traces/"
trace_url = response["tracer"]["trace_url"]
parsed_url = urlparse(trace_url)
# trace id is the last part of the path (after the last '/')
uuid = os.path.basename(parsed_url.path)
try:
# should be able to access the trace data because we set LangfuseConnector to public=True
response = requests.get(trace_url)
assert (
response.status_code == 200
), f"Failed to retrieve tracing data from {trace_url} got: {response.status_code}"
# GET request with Basic Authentication on the Langfuse API
response = requests.get(
url + uuid, auth=HTTPBasicAuth(os.environ.get("LANGFUSE_PUBLIC_KEY"), os.environ.get("LANGFUSE_SECRET_KEY"))
)

assert response.status_code == 200, f"Failed to retrieve data from Langfuse API: {response.status_code}"
except requests.exceptions.RequestException as e:
assert False, f"Failed to retrieve tracing data from Langfuse: {e}"
assert False, f"Failed to retrieve data from Langfuse API: {e}"

0 comments on commit 6171b15

Please sign in to comment.