diff --git a/galactory/models.py b/galactory/models.py index 957bfd5..923d3a2 100644 --- a/galactory/models.py +++ b/galactory/models.py @@ -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 diff --git a/tests/unit/models/test_collectiongroup.py b/tests/unit/models/test_collectiongroup.py index 17bc43b..97964fb 100644 --- a/tests/unit/models/test_collectiongroup.py +++ b/tests/unit/models/test_collectiongroup.py @@ -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