Skip to content

Commit

Permalink
fix tests and added getInfoNotExistentCollection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vga91 committed Jul 30, 2024
1 parent 29d58a0 commit b8fa616
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ note that the list and the signature procedures are consistent with the others,
[opts=header, cols="1, 3"]
|===
| name | description
| apoc.vectordb.chroma.info(hostOrKey, collection, $config) | Get information about the specified existing collection or throws an error if it does not exist
| apoc.vectordb.chroma.info(hostOrKey, collection, $config) | Get information about the specified existing collection or throws an error 500 if it does not exist
| apoc.vectordb.chroma.createCollection(hostOrKey, collection, similarity, size, $config) |
Creates a collection, with the name specified in the 2nd parameter, and with the specified `similarity` and `size`.
The default endpoint is `<hostOrKey param>/api/v1/collections`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Here is a list of all available Pinecone procedures:
[opts=header, cols="1, 3"]
|===
| name | description
| apoc.vectordb.pinecone.info(hostOrKey, collection, $config) | Get information about the specified existing collection or throws an error if it does not exist
| apoc.vectordb.pinecone.info(hostOrKey, collection, $config) | Get information about the specified existing collection or throws a 404 error if it does not exist
| apoc.vectordb.pinecone.createCollection(hostOrKey, index, similarity, size, $config) |
Creates an index, with the name specified in the 2nd parameter, and with the specified `similarity` and `size`.
The default endpoint is `<hostOrKey param>/indexes`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ note that the list and the signature procedures are consistent with the others,
[opts=header, cols="1, 3"]
|===
| name | description
| apoc.vectordb.qdrant.info(hostOrKey, collection, $config) | Get information about the specified existing collection or throws an error if it does not exist or throws an error
| apoc.vectordb.qdrant.info(hostOrKey, collection, $config) | Get information about the specified existing collection or throws a FileNotFoundException if it does not exist
| apoc.vectordb.qdrant.createCollection(hostOrKey, collection, similarity, size, $config) |
Creates a collection, with the name specified in the 2nd parameter, and with the specified `similarity` and `size`.
The default endpoint is `<hostOrKey param>/collections/<collection param>`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ note that the list and the signature procedures are consistent with the others,
[opts=header, cols="1, 3"]
|===
| name | description
| apoc.vectordb.weaviate.info($host, $collectionName, $config) | Get information about the specified existing collection or throws an error if it does not exist
| apoc.vectordb.weaviate.info($host, $collectionName, $config) | Get information about the specified existing collection or throws a FileNotFoundException if it does not exist
| apoc.vectordb.weaviate.createCollection(hostOrKey, collection, similarity, size, $config) |
Creates a collection, with the name specified in the 2nd parameter, and with the specified `similarity` and `size`.
The default endpoint is `<hostOrKey param>/schema`.
Expand Down
9 changes: 9 additions & 0 deletions extended-it/src/test/java/apoc/vectordb/ChromaDbTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static apoc.ml.Prompt.API_KEY_CONF;
import static apoc.ml.RestAPIConfig.HEADERS_KEY;
import static apoc.util.ExtendedTestUtil.assertFails;
import static apoc.util.MapUtil.map;
import static apoc.util.TestUtil.testCall;
import static apoc.util.TestUtil.testResult;
Expand Down Expand Up @@ -118,6 +119,14 @@ public void getInfo() {
assertEquals(COLLECTION_NAME, row.get("name"));
});
}

@Test
public void getInfoNotExistentCollection() {
assertFails(db, "CALL apoc.vectordb.chroma.info($host, 'wrong_collection', $conf) ",
map("host", HOST, "collection", COLLECTION_NAME, "conf", map(ALL_RESULTS_KEY, true)),
"Server returned HTTP response code: 500"
);
}

@Test
public void getVectors() {
Expand Down
13 changes: 12 additions & 1 deletion extended-it/src/test/java/apoc/vectordb/MilvusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,25 @@ public void before() {

@Test
public void getInfo() {
testResult(db, "CALL apoc.vectordb.milvus.info($host, 'taaaest_collection', '', $conf) ",
testResult(db, "CALL apoc.vectordb.milvus.info($host, 'test_collection', '', $conf) ",
map("host", HOST, "conf", map(FIELDS_KEY, FIELDS)),
r -> {
Map<String, Object> row = r.next();
Map value = (Map) row.get("value");
assertEquals(200L, value.get("code"));
});
}

@Test
public void getInfoNotExistentCollection() {
testResult(db, "CALL apoc.vectordb.milvus.info($host, 'wrong_collection', '', $conf) ",
map("host", HOST, "conf", map(FIELDS_KEY, FIELDS)),
r -> {
Map<String, Object> row = r.next();
Map value = (Map) row.get("value");
assertEquals(100L, value.get("code"));
});
}

@Test
public void getVectorsWithoutVectorResult() {
Expand Down
11 changes: 11 additions & 0 deletions extended-it/src/test/java/apoc/vectordb/QdrantTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static apoc.ml.Prompt.API_KEY_CONF;
import static apoc.ml.RestAPIConfig.HEADERS_KEY;
import static apoc.util.ExtendedTestUtil.assertFails;
import static apoc.util.MapUtil.map;
import static apoc.util.TestUtil.testCall;
import static apoc.util.TestUtil.testResult;
Expand Down Expand Up @@ -132,6 +133,16 @@ public void getInfo() {
});
}

@Test
public void getInfoNotExistentCollection() {
assertFails(
db,
"CALL apoc.vectordb.qdrant.info($host, 'wrong_collection', $conf)",
map("host", HOST, "conf", ADMIN_HEADER_CONF),
"java.io.FileNotFoundException"
);
}

@Test
public void getVectorsWithReadOnlyApiKey() {
testResult(db, "CALL apoc.vectordb.qdrant.get($host, 'test_collection', [1], $conf) ",
Expand Down
11 changes: 11 additions & 0 deletions extended-it/src/test/java/apoc/vectordb/WeaviateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import static apoc.ml.Prompt.API_KEY_CONF;
import static apoc.ml.RestAPIConfig.HEADERS_KEY;
import static apoc.util.ExtendedTestUtil.assertFails;
import static apoc.util.TestUtil.testCall;
import static apoc.util.TestUtil.testCallEmpty;
import static apoc.util.TestUtil.testResult;
Expand Down Expand Up @@ -159,6 +160,16 @@ public void getInfo() {
});
}

@Test
public void getInfoNotExistentCollection() {
assertFails(
db,
"CALL apoc.vectordb.weaviate.info($host, 'wrong_collection', $conf)",
map("host", HOST, "collectionName", COLLECTION_NAME, "conf", map(ALL_RESULTS_KEY, true, HEADERS_KEY, READONLY_AUTHORIZATION)),
"java.io.FileNotFoundException"
);
}

@Test
public void getVectorsWithReadOnlyApiKey() {
testResult(db, "CALL apoc.vectordb.weaviate.get($host, 'TestCollection', [$id1], $conf)",
Expand Down
5 changes: 5 additions & 0 deletions extended/src/main/resources/extended.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ apoc.vectordb.chroma.get
apoc.vectordb.chroma.getAndUpdate
apoc.vectordb.chroma.query
apoc.vectordb.chroma.queryAndUpdate
apoc.vectordb.chroma.info
apoc.vectordb.qdrant.createCollection
apoc.vectordb.qdrant.deleteCollection
apoc.vectordb.qdrant.upsert
Expand All @@ -237,6 +238,7 @@ apoc.vectordb.qdrant.get
apoc.vectordb.qdrant.getAndUpdate
apoc.vectordb.qdrant.query
apoc.vectordb.qdrant.queryAndUpdate
apoc.vectordb.qdrant.info
apoc.vectordb.weaviate.createCollection
apoc.vectordb.weaviate.deleteCollection
apoc.vectordb.weaviate.upsert
Expand All @@ -245,6 +247,7 @@ apoc.vectordb.weaviate.get
apoc.vectordb.weaviate.getAndUpdate
apoc.vectordb.weaviate.query
apoc.vectordb.weaviate.queryAndUpdate
apoc.vectordb.weaviate.info
apoc.vectordb.pinecone.createCollection
apoc.vectordb.pinecone.deleteCollection
apoc.vectordb.pinecone.upsert
Expand All @@ -253,6 +256,7 @@ apoc.vectordb.pinecone.get
apoc.vectordb.pinecone.getAndUpdate
apoc.vectordb.pinecone.query
apoc.vectordb.pinecone.queryAndUpdate
apoc.vectordb.pinecone.info
apoc.vectordb.milvus.createCollection
apoc.vectordb.milvus.deleteCollection
apoc.vectordb.milvus.upsert
Expand All @@ -261,6 +265,7 @@ apoc.vectordb.milvus.get
apoc.vectordb.milvus.getAndUpdate
apoc.vectordb.milvus.query
apoc.vectordb.milvus.queryAndUpdate
apoc.vectordb.milvus.info
apoc.vectordb.custom.get
apoc.vectordb.custom
apoc.vectordb.configure
11 changes: 11 additions & 0 deletions extended/src/test/java/apoc/vectordb/PineconeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static apoc.ml.Prompt.API_KEY_CONF;
import static apoc.ml.RestAPIConfig.HEADERS_KEY;
import static apoc.util.ExtendedTestUtil.assertFails;
import static apoc.util.MapUtil.map;
import static apoc.util.TestUtil.testCall;
import static apoc.util.TestUtil.testCallEmpty;
Expand Down Expand Up @@ -138,6 +139,16 @@ public void getInfo() {
assertEquals(collName, value.get("name"));
});
}

@Test
public void getInfoNotExistentCollection() {
assertFails(db, "CALL apoc.vectordb.pinecone.info($host, 'wrong_collection', $conf) ",
map("host", HOST, "coll", collName,
"conf", map(ALL_RESULTS_KEY, true, HEADERS_KEY, ADMIN_AUTHORIZATION)
),
"Server returned HTTP response code: 500"
);
}

@Test
public void getVectors() {
Expand Down

0 comments on commit b8fa616

Please # to comment.