Skip to content

Commit

Permalink
Add unit test at IndexModel
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamon committed Jul 18, 2024
1 parent 1e42790 commit 824802d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/unit/models/test_index_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from pinecone.core.openapi.control.models import (
IndexModel as OpenApiIndexModel,
IndexModelStatus,
IndexModelSpec,
ServerlessSpec,
DeletionProtection,
)
from pinecone.models import IndexModel

class TestIndexModel:
def test_index_model(self):
openapi_model = OpenApiIndexModel(
name="test-index-1",
dimension=2,
metric="cosine",
host="https://test-index-1.pinecone.io",
status=IndexModelStatus(ready=True, state="Ready"),
deletion_protection=DeletionProtection("enabled"),
spec=IndexModelSpec(serverless=ServerlessSpec(cloud="aws", region="us-west-1"))
)

wrapped = IndexModel(openapi_model)

assert wrapped.name == "test-index-1"
assert wrapped.dimension == 2
assert wrapped.metric == "cosine"
assert wrapped.host == "https://test-index-1.pinecone.io"
assert wrapped.status.ready == True
assert wrapped.status.state == "Ready"
assert wrapped.deletion_protection == "enabled"

assert wrapped['name'] == "test-index-1"

0 comments on commit 824802d

Please sign in to comment.