Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
isahers1 committed Dec 10, 2024
1 parent 7573691 commit cf85e56
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions python/tests/integration_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,17 +1608,18 @@ def test_update_example_with_attachments_operations(langchain_client: Client) ->
dataset_name=dataset_name,
description="Test dataset for updating example attachments",
)

example_id = uuid4()
# Create example with attachments
example = ExampleUploadWithAttachments(
id=example_id,
inputs={"query": "What's in this image?"},
outputs={"answer": "A test image"},
attachments={
"image1": ("image/png", b"fake image data 1"),
"image2": ("image/png", b"fake image data 2"),
},
)
created_example = langchain_client.upload_examples_multipart(
langchain_client.upload_examples_multipart(
dataset_id=dataset.id, uploads=[example]
)

Expand All @@ -1629,26 +1630,26 @@ def test_update_example_with_attachments_operations(langchain_client: Client) ->
)

langchain_client.update_example(
example_id=created_example.id,
example_id=example_id,
attachments_operations=attachments_operations,
)

# Verify the update
retrieved_example = langchain_client.read_example(
example_id=created_example.id,
example_id=example_id,
)

# Check that only the renamed attachment exists
assert len(retrieved_example.attachments_info) == 2
assert "renamed_image" in retrieved_example.attachments_info
assert "image2" in retrieved_example.attachments_info
assert "image1" not in retrieved_example.attachments_info
assert len(retrieved_example.attachments) == 2
assert "renamed_image" in retrieved_example.attachments
assert "image2" in retrieved_example.attachments
assert "image1" not in retrieved_example.attachments
assert (
retrieved_example.attachments_info["image2"]["reader"].read()
retrieved_example.attachments["image2"]["reader"].read()
== b"fake image data 2"
)
assert (
retrieved_example.attachments_info["renamed_image"]["reader"].read()
retrieved_example.attachments["renamed_image"]["reader"].read()
== b"fake image data 1"
)

Expand Down

0 comments on commit cf85e56

Please sign in to comment.