|
8 | 8 |
|
9 | 9 | import pinecone as oem_pinecone
|
10 | 10 | import pytest # pylint: disable=unused-import
|
| 11 | +from pinecone import Pinecone |
11 | 12 |
|
12 | 13 | from models.conf import settings
|
13 | 14 | from models.pinecone import PineconeIndex
|
@@ -50,29 +51,38 @@ def test_04_initialize(self):
|
50 | 51 |
|
51 | 52 | def test_05_delete(self):
|
52 | 53 | """Test that the index can be deleted."""
|
53 |
| - pinecone = PineconeIndex() |
54 |
| - indexes = oem_pinecone.manage.list_indexes() |
55 |
| - assert pinecone.index_name in indexes |
| 54 | + pinecone_index = PineconeIndex() |
| 55 | + |
| 56 | + # pylint: disable=E1101 |
| 57 | + api_key = settings.pinecone_api_key.get_secret_value() |
| 58 | + pinecone = Pinecone(api_key=api_key) |
| 59 | + indexes = pinecone.list_indexes().names() |
| 60 | + assert pinecone_index.index_name in indexes |
56 | 61 | # pylint: disable=broad-except
|
57 | 62 | try:
|
58 |
| - pinecone.delete() |
| 63 | + pinecone_index.delete() |
59 | 64 | except Exception as e:
|
60 | 65 | assert False, f"Pinecone.delete() failed with exception: {e}"
|
61 | 66 |
|
62 | 67 | def test_06_create(self):
|
63 | 68 | """Test that the index can be created."""
|
64 |
| - pinecone = PineconeIndex() |
65 |
| - indexes = oem_pinecone.manage.list_indexes() |
66 |
| - if pinecone.index_name in indexes: |
67 |
| - pinecone.delete() |
| 69 | + pinecone_index = PineconeIndex() |
| 70 | + |
| 71 | + # pylint: disable=E1101 |
| 72 | + api_key = settings.pinecone_api_key.get_secret_value() |
| 73 | + pinecone = Pinecone(api_key=api_key) |
| 74 | + |
| 75 | + indexes = pinecone.list_indexes().names() |
| 76 | + if pinecone_index.index_name in indexes: |
| 77 | + pinecone_index.delete() |
68 | 78 |
|
69 | 79 | # pylint: disable=broad-except
|
70 | 80 | try:
|
71 |
| - pinecone.create() |
| 81 | + pinecone_index.create() |
72 | 82 | except Exception as e:
|
73 | 83 | assert False, f"Pinecone.create() failed with exception: {e}"
|
74 |
| - assert isinstance(pinecone.index, oem_pinecone.Index) |
75 |
| - pinecone.delete() |
| 84 | + assert isinstance(pinecone_index.index, oem_pinecone.Index) |
| 85 | + pinecone_index.delete() |
76 | 86 |
|
77 | 87 | def test_07_load_pdf(self):
|
78 | 88 | """Test that we can load a PDF document to the index."""
|
|
0 commit comments