Skip to content

Commit

Permalink
Return needed test
Browse files Browse the repository at this point in the history
  • Loading branch information
d.rudenko committed Dec 18, 2024
1 parent 552a4fc commit 3b46c80
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/test_qdrant_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2051,6 +2051,35 @@ def auth_token_provider():
client.unlock_storage()
assert token == "token_2"


def test_async_auth_token_provider():
"""Check that initialization fails if async auth_token_provider is provided to sync client."""
token = ""

async def auth_token_provider():
nonlocal token
await asyncio.sleep(0.1)
token = "test_token"
return token

client = QdrantClient(auth_token_provider=auth_token_provider)

with pytest.raises(
qdrant_client.http.exceptions.ResponseHandlingException,
match="Synchronous token provider is not set.",
):
client.get_collections()

assert token == ""

client = QdrantClient(auth_token_provider=auth_token_provider, prefer_grpc=True)
with pytest.raises(
ValueError, match="Synchronous channel requires synchronous auth token provider."
):
client.get_collections()

assert token == ""

@pytest.mark.parametrize("prefer_grpc", [True, False])
def test_read_consistency(prefer_grpc):
fixture_points = generate_fixtures(vectors_sizes=DIM, num=NUM_VECTORS)
Expand Down

0 comments on commit 3b46c80

Please sign in to comment.