Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pinecone/models/collection_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ def __init__(self, collection_list: OpenAPICollectionList):
self.collection_list = collection_list
self.current = 0

def names(self):
return [i['name'] for i in self.collection_list.collections]

def __getitem__(self, key):
return self.collection_list.collections[key]

Expand Down
9 changes: 8 additions & 1 deletion tests/unit/models/test_collection_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ def test_collection_list_getitem(self, collection_list_response):

def test_collection_list_proxies_methods(self, collection_list_response):
# Forward compatibility, in case we add more attributes to IndexList for pagination
assert CollectionList(collection_list_response).collection_list.collections == collection_list_response.collections
assert CollectionList(collection_list_response).collection_list.collections == collection_list_response.collections

def test_when_results_are_empty(self):
assert len(CollectionList(OpenApiCollectionList(collections=[]))) == 0

def test_collection_list_names_syntactic_sugar(self, collection_list_response):
icl = CollectionList(collection_list_response)
assert icl.names() == ['collection1', 'collection2']