-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e2a6e8
commit 030a6c3
Showing
3 changed files
with
20 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,28 @@ | ||
import random | ||
import string | ||
|
||
from dewy_client.api.default import add_collection, get_collection, list_collections | ||
from dewy_client.models import CollectionCreate | ||
|
||
async def test_create_collection(client): | ||
name = "".join(random.choices(string.ascii_lowercase, k=5)) | ||
create_response = await client.put("/api/collections/", json={"name": name}) | ||
assert create_response.status_code == 200 | ||
collection = await add_collection.asyncio(client=client, body=CollectionCreate( | ||
name = name | ||
)) | ||
|
||
json = create_response.json() | ||
assert json["name"] == name | ||
assert json["text_embedding_model"] == "openai:text-embedding-ada-002" | ||
assert json["text_distance_metric"] == "cosine" | ||
assert collection.name == name | ||
assert collection.text_embedding_model == "openai:text-embedding-ada-002" | ||
assert collection.text_distance_metric == "cosine" | ||
|
||
collection_id = json["id"] | ||
collection_id = collection.id | ||
|
||
list_response = await client.get("/api/collections/") | ||
assert list_response.status_code == 200 | ||
list_response = await list_collections.asyncio(client=client) | ||
|
||
# "find" the collection with the new collection ID, since | ||
# other tests may have created other collections | ||
json = list_response.json() | ||
collection_row = next(x for x in list_response.json() if x["id"] == collection_id) | ||
collection_row = next(x for x in list_response if x.id == collection_id) | ||
assert collection_row is not None | ||
assert collection_row["name"] == name | ||
assert collection_row.name == name | ||
|
||
get_response = await client.get(f"/api/collections/{collection_id}") | ||
assert get_response.status_code == 200 | ||
get_response = await get_collection.asyncio(collection_id, client=client) | ||
|
||
json = get_response.json() | ||
assert collection_row["name"] == name | ||
assert get_response.name == name |