diff --git a/tests/integration/control/serverless/conftest.py b/tests/integration/control/serverless/conftest.py index 7a3abcd7..ef2ef732 100644 --- a/tests/integration/control/serverless/conftest.py +++ b/tests/integration/control/serverless/conftest.py @@ -1,9 +1,12 @@ import pytest import random import time +import logging from pinecone import Pinecone, NotFoundException, PineconeApiException from ...helpers import generate_index_name, get_environment_var +logger = logging.getLogger(__name__) + @pytest.fixture() def client(): @@ -101,6 +104,7 @@ def cleanup(client, index_name): yield try: + logger.debug("Attempting to delete index with name: " + index_name) client.delete_index(index_name, -1) except Exception: pass diff --git a/tests/integration/control/serverless/test_create_index_sl_happy_path.py b/tests/integration/control/serverless/test_create_index_sl_happy_path.py index 69aeb0e8..8069f340 100644 --- a/tests/integration/control/serverless/test_create_index_sl_happy_path.py +++ b/tests/integration/control/serverless/test_create_index_sl_happy_path.py @@ -1,5 +1,12 @@ import pytest -from pinecone import Metric, VectorType +from pinecone import ( + Metric, + VectorType, + DeletionProtection, + ServerlessSpec, + CloudProvider, + AwsRegion, +) class TestCreateSLIndexHappyPath: @@ -14,10 +21,7 @@ def test_create_index(self, client, create_sl_index_params): assert desc.deletion_protection == "disabled" # default value assert desc.vector_type == "dense" # default value - @pytest.mark.parametrize( - "metric", - ["cosine", "euclidean", "dotproduct", Metric.COSINE, Metric.EUCLIDEAN, Metric.DOTPRODUCT], - ) + @pytest.mark.parametrize("metric", ["cosine", "euclidean", "dotproduct"]) def test_create_default_index_with_metric(self, client, create_sl_index_params, metric): create_sl_index_params["metric"] = metric client.create_index(**create_sl_index_params) @@ -25,6 +29,34 @@ def test_create_default_index_with_metric(self, client, create_sl_index_params, assert desc.metric == metric assert desc.vector_type == "dense" + @pytest.mark.parametrize( + "metric_enum,vector_type_enum,dim", + [ + (Metric.COSINE, VectorType.DENSE, 10), + (Metric.EUCLIDEAN, VectorType.DENSE, 10), + (Metric.DOTPRODUCT, VectorType.SPARSE, None), + ], + ) + def test_create_with_enum_values(self, client, index_name, metric_enum, vector_type_enum, dim): + args = { + "name": index_name, + "metric": metric_enum, + "vector_type": vector_type_enum, + "deletion_protection": DeletionProtection.DISABLED, + "spec": ServerlessSpec(cloud=CloudProvider.AWS, region=AwsRegion.US_EAST_1), + } + if dim is not None: + args["dimension"] = dim + client.create_index(**args) + desc = client.describe_index(index_name) + assert desc.metric == metric_enum.value + assert desc.vector_type == vector_type_enum.value + assert desc.dimension == dim + assert desc.deletion_protection == DeletionProtection.DISABLED.value + assert desc.name == index_name + assert desc.spec.serverless.cloud == "aws" + assert desc.spec.serverless.region == "us-east-1" + @pytest.mark.parametrize("metric", ["cosine", "euclidean", "dotproduct"]) def test_create_dense_index_with_metric(self, client, create_sl_index_params, metric): create_sl_index_params["metric"] = metric