Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis committed Oct 24, 2024
1 parent 94d3a3e commit 05e628d
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions python/tests/integration_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import datetime
import io
import logging
import os
import random
import string
Expand Down Expand Up @@ -744,21 +745,26 @@ def test_batch_ingest_runs(
"""


def test_multipart_ingest_runs_empty(langchain_client: Client) -> None:
def test_multipart_ingest_runs_empty(
langchain_client: Client, caplog: pytest.LogCaptureFixture
) -> None:

runs_to_create: list[dict] = []
runs_to_update: list[dict] = []

# make sure no warnings logged
with warnings.catch_warnings():
warnings.simplefilter("error")
with caplog.at_level(logging.WARNING, logger="langsmith.client"):

langchain_client.multipart_ingest_runs(
create=runs_to_create, update=runs_to_update
)

assert not caplog.records


def test_multipart_ingest_runs_create_then_update(langchain_client: Client) -> None:
def test_multipart_ingest_runs_create_then_update(
langchain_client: Client, caplog: pytest.LogCaptureFixture
) -> None:
_session = "__test_multipart_ingest_runs_create_then_update"

trace_a_id = uuid4()
Expand All @@ -779,11 +785,12 @@ def test_multipart_ingest_runs_create_then_update(langchain_client: Client) -> N
]

# make sure no warnings logged
with warnings.catch_warnings():
warnings.simplefilter("error")
with caplog.at_level(logging.WARNING, logger="langsmith.client"):

langchain_client.multipart_ingest_runs(create=runs_to_create, update=[])

assert not caplog.records

runs_to_update: list[dict] = [
{
"id": str(trace_a_id),
Expand All @@ -792,13 +799,16 @@ def test_multipart_ingest_runs_create_then_update(langchain_client: Client) -> N
"outputs": {"output1": 3, "output2": 4},
}
]
with warnings.catch_warnings():
warnings.simplefilter("error")
with caplog.at_level(logging.WARNING, logger="langsmith.client"):

langchain_client.multipart_ingest_runs(create=[], update=runs_to_update)

assert not caplog.records


def test_multipart_ingest_runs_update_then_create(langchain_client: Client) -> None:
def test_multipart_ingest_runs_update_then_create(
langchain_client: Client, caplog: pytest.LogCaptureFixture
) -> None:
_session = "__test_multipart_ingest_runs_update_then_create"

trace_a_id = uuid4()
Expand All @@ -816,11 +826,12 @@ def test_multipart_ingest_runs_update_then_create(langchain_client: Client) -> N
]

# make sure no warnings logged
with warnings.catch_warnings():
warnings.simplefilter("error")
with caplog.at_level(logging.WARNING, logger="langsmith.client"):

langchain_client.multipart_ingest_runs(create=[], update=runs_to_update)

assert not caplog.records

runs_to_create: list[dict] = [
{
"id": str(trace_a_id),
Expand All @@ -833,13 +844,16 @@ def test_multipart_ingest_runs_update_then_create(langchain_client: Client) -> N
}
]

with warnings.catch_warnings():
warnings.simplefilter("error")
with caplog.at_level(logging.WARNING, logger="langsmith.client"):

langchain_client.multipart_ingest_runs(create=runs_to_create, update=[])

assert not caplog.records


def test_multipart_ingest_runs_create_wrong_type(langchain_client: Client) -> None:
def test_multipart_ingest_runs_create_wrong_type(
langchain_client: Client, caplog: pytest.LogCaptureFixture
) -> None:
_session = "__test_multipart_ingest_runs_create_then_update"

trace_a_id = uuid4()
Expand All @@ -860,11 +874,13 @@ def test_multipart_ingest_runs_create_wrong_type(langchain_client: Client) -> No
]

# make sure no warnings logged
with warnings.catch_warnings():
warnings.simplefilter("error")

with caplog.at_level(logging.WARNING, logger="langsmith.client"):
langchain_client.multipart_ingest_runs(create=runs_to_create, update=[])

# this should 422
assert len(caplog.records)
assert all("422" in record.message for record in caplog.records)


@freeze_time("2023-01-01")
def test_get_info() -> None:
Expand Down

0 comments on commit 05e628d

Please sign in to comment.