Skip to content

Commit

Permalink
fix: Fixed test_collections.py property test
Browse files Browse the repository at this point in the history
- Moved the  model update after conditional checks for new_name and metadata.
  • Loading branch information
tazarov committed Feb 14, 2024
1 parent 01369af commit 6a5439b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions chromadb/test/property/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
run_state_machine_as_test,
MultipleResults,
)
from typing import Dict, Optional
from typing import Dict, Optional, Any, Mapping


class CollectionStateMachine(RuleBasedStateMachine):
Expand Down Expand Up @@ -195,7 +195,8 @@ def modify_coll(
return multiple()

c = self.api.get_collection(name=coll.name)

_metadata: Optional[Mapping[str, Any]] = coll.metadata
_name: str = coll.name
if new_metadata is not None:
if len(new_metadata) == 0:
with pytest.raises(Exception):
Expand All @@ -206,18 +207,18 @@ def modify_coll(
)
return multiple()
coll.metadata = new_metadata
self.set_model(coll.name, coll.metadata)
_metadata = new_metadata

if new_name is not None:
if new_name in self.model and new_name != coll.name:
with pytest.raises(Exception):
c.modify(metadata=new_metadata, name=new_name)
return multiple()

prev_metadata = self.model[coll.name]
self.delete_from_model(coll.name)
self.set_model(new_name, prev_metadata)
coll.name = new_name
_name = new_name
self.set_model(_name, _metadata) # type: ignore

c.modify(metadata=new_metadata, name=new_name)
c = self.api.get_collection(name=coll.name)
Expand Down

0 comments on commit 6a5439b

Please sign in to comment.