Skip to content

Commit

Permalink
add CollectionGroup.from_collection test
Browse files Browse the repository at this point in the history
  • Loading branch information
briantist committed Oct 8, 2023
1 parent b710d08 commit 9af2a32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion galactory/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __setitem__(self, key: t.Union[str, VersionInfo], item: CollectionData) -> N
def __delitem__(self, key: t.Union[str, VersionInfo]) -> None:
return super().__delitem__(self._get_key(key))

def __contains__(self, key: object) -> bool:
def __contains__(self, key: t.Union[str, VersionInfo]) -> bool:
return super().__contains__(self._get_key(key, raises=False))

# re-define for the type hints
Expand Down
11 changes: 10 additions & 1 deletion tests/unit/models/test_collectiongroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@ def test_collectiongroup_add(mocker: MockFixture, namespace, name, collection_da


colgroup.add(collection_data)
spy.assert_called_once_with(colgroup, collection_data.semver, collection_data)
assert len(colgroup) == 1
assert colgroup.latest is collection_data

spy.assert_called_once_with(colgroup, collection_data.semver, collection_data)

def test_collectiongroup_from_collection(mocker: MockFixture, collection_data: CollectionData):
spy = mocker.spy(CollectionGroup, '__init__')

colgroup = CollectionGroup.from_collection(collection_data)

spy.assert_called_once_with(mocker.ANY, namespace=collection_data.namespace, name=collection_data.name)
assert len(colgroup) == 1
assert colgroup.latest is collection_data

0 comments on commit 9af2a32

Please sign in to comment.