Skip to content

Commit

Permalink
fix test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
spikechroma committed Aug 23, 2024
1 parent 2d6213e commit 7d4c032
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions chromadb/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,15 +706,15 @@ def test_metadata_update_get_int_float(client):
def test_metadata_validation_add(client):
client.reset()
collection = client.create_collection("test_metadata_validation")
with pytest.raises(ValueError, match="metadata"):
with pytest.raises(Exception, match="metadata"):
collection.add(**bad_metadata_records)


def test_metadata_validation_update(client):
client.reset()
collection = client.create_collection("test_metadata_validation")
collection.add(**metadata_records)
with pytest.raises(ValueError, match="metadata"):
with pytest.raises(Exception, match="metadata"):
collection.update(ids=["id1"], metadatas={"value": {"nested": "5"}})


Expand Down Expand Up @@ -1203,17 +1203,17 @@ def test_invalid_id(client):
client.reset()
collection = client.create_collection("test_invalid_id")
# Add with non-string id
with pytest.raises(ValueError) as e:
with pytest.raises(Exception) as e:
collection.add(embeddings=[0, 0, 0], ids=[1], metadatas=[{}])
assert "ID" in str(e.value)

# Get with non-list id
with pytest.raises(ValueError) as e:
with pytest.raises(Exception) as e:
collection.get(ids=1)
assert "ID" in str(e.value)

# Delete with malformed ids
with pytest.raises(ValueError) as e:
with pytest.raises(Exception) as e:
collection.delete(ids=["valid", 0])
assert "ID" in str(e.value)

Expand Down Expand Up @@ -1548,12 +1548,12 @@ def test_invalid_embeddings(client):
"embeddings": [["0", "0", "0"], ["1.2", "2.24", "3.2"]],
"ids": ["id1", "id2"],
}
with pytest.raises(ValueError) as e:
with pytest.raises(Exception) as e:
collection.add(**invalid_records)
assert "embedding" in str(e.value)

# Query with invalid embeddings
with pytest.raises(ValueError) as e:
with pytest.raises(Exception) as e:
collection.query(
query_embeddings=[["1.1", "2.3", "3.2"]],
n_results=1,
Expand All @@ -1565,7 +1565,7 @@ def test_invalid_embeddings(client):
"embeddings": [[[0], [0], [0]], [[1.2], [2.24], [3.2]]],
"ids": ["id1", "id2"],
}
with pytest.raises(ValueError) as e:
with pytest.raises(Exception) as e:
collection.update(**invalid_records)
assert "embedding" in str(e.value)

Expand All @@ -1574,7 +1574,7 @@ def test_invalid_embeddings(client):
"embeddings": [[[1.1, 2.3, 3.2]], [[1.2, 2.24, 3.2]]],
"ids": ["id1", "id2"],
}
with pytest.raises(ValueError) as e:
with pytest.raises(Exception) as e:
collection.upsert(**invalid_records)
assert "embedding" in str(e.value)

Expand Down

0 comments on commit 7d4c032

Please sign in to comment.