Skip to content

Commit

Permalink
fix: sync tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescalam committed Jan 11, 2025
1 parent 2f84ca1 commit 948674e
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions tests/unit/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def test_auto_sync_local(
@retry(max_retries=RETRY_COUNT, delay=PINECONE_SLEEP)
def check_sync():
# TODO JB: this should use include_metadata=True
assert route_layer.index.get_utterances(include_metadata=False) == [
assert route_layer.index.get_utterances(include_metadata=True) == [
Utterance(route="Route 1", utterance="Hello"),
Utterance(route="Route 2", utterance="Hi"),
], "The routes in the index should match the local routes"
Expand Down Expand Up @@ -450,7 +450,7 @@ def test_auto_sync_remote(

@retry(max_retries=RETRY_COUNT, delay=PINECONE_SLEEP)
def check_sync():
assert route_layer.index.get_utterances() == [
assert route_layer.index.get_utterances(include_metadata=True) == [
Utterance(route="Route 1", utterance="Hello"),
Utterance(route="Route 2", utterance="Hi"),
], "The routes in the index should match the local routes"
Expand Down Expand Up @@ -485,10 +485,10 @@ def check_sync():
# confirm local and remote are synced
assert route_layer.is_synced()
# now confirm utterances are correct
local_utterances = route_layer.index.get_utterances()
local_utterances = route_layer.index.get_utterances(include_metadata=True)
# we sort to ensure order is the same
# TODO JB: there is a bug here where if we include_metadata=True it fails
local_utterances.sort(key=lambda x: x.to_str(include_metadata=False))
local_utterances.sort(key=lambda x: x.to_str(include_metadata=True))
assert local_utterances == [
Utterance(route="Route 1", utterance="Hello"),
Utterance(route="Route 1", utterance="Hi"),
Expand Down Expand Up @@ -534,10 +534,10 @@ def check_r1_utterances():
Utterance(name="Route 2", utterances="Goodbye"),
Utterance(name="Route 3", utterances="Boo"),
]
local_utterances = route_layer.index.get_utterances()
local_utterances = route_layer.index.get_utterances(include_metadata=True)
# we sort to ensure order is the same
local_utterances.sort(
key=lambda x: x.to_str(include_metadata=include_metadata(index_cls))
key=lambda x: x.to_str(include_metadata=True)
)
assert local_utterances == r1_utterances

Expand All @@ -554,7 +554,9 @@ def check_r1_utterances():
def check_r2_utterances():
# confirm local and remote are synced
assert route_layer.is_synced()
local_utterances = route_layer.index.get_utterances()
local_utterances = route_layer.index.get_utterances(include_metadata=True)
# we sort to ensure order is the same
local_utterances.sort(key=lambda x: x.to_str(include_metadata=True))
assert local_utterances == [
Utterance(
route="Route 1", utterance="Hello", metadata={"type": "default"}
Expand Down Expand Up @@ -617,11 +619,9 @@ def check_sync():
# confirm local and remote are synced
assert route_layer.is_synced()
# now confirm utterances are correct
local_utterances = route_layer.index.get_utterances()
local_utterances = route_layer.index.get_utterances(include_metadata=True)
# we sort to ensure order is the same
local_utterances.sort(
key=lambda x: x.to_str(include_metadata=include_metadata(index_cls))
)
local_utterances.sort(key=lambda x: x.to_str(include_metadata=True))
assert local_utterances == [
Utterance(
route="Route 1", utterance="Hello", metadata={"type": "default"}
Expand Down Expand Up @@ -809,7 +809,7 @@ async def test_auto_sync_local(

@async_retry(max_retries=RETRY_COUNT, delay=PINECONE_SLEEP)
async def check_sync():
assert await route_layer.index.aget_utterances() == [
assert await route_layer.index.aget_utterances(include_metadata=True) == [
Utterance(route="Route 1", utterance="Hello"),
Utterance(route="Route 2", utterance="Hi"),
], "The routes in the index should match the local routes"
Expand Down Expand Up @@ -842,7 +842,7 @@ async def test_auto_sync_remote(

@async_retry(max_retries=RETRY_COUNT, delay=PINECONE_SLEEP)
async def check_sync():
assert await route_layer.index.aget_utterances() == [
assert await route_layer.index.aget_utterances(include_metadata=True) == [
Utterance(route="Route 1", utterance="Hello"),
Utterance(route="Route 2", utterance="Hi"),
], "The routes in the index should match the local routes"
Expand Down Expand Up @@ -878,10 +878,12 @@ async def check_sync():
# confirm local and remote are synced
assert await route_layer.async_is_synced()
# now confirm utterances are correct
local_utterances = await route_layer.index.aget_utterances()
local_utterances = await route_layer.index.aget_utterances(
include_metadata=True
)
# we sort to ensure order is the same
# TODO JB: there is a bug here where if we include_metadata=True it fails
local_utterances.sort(key=lambda x: x.to_str(include_metadata=False))
local_utterances.sort(key=lambda x: x.to_str(include_metadata=True))
assert local_utterances == [
Utterance(route="Route 1", utterance="Hello"),
Utterance(route="Route 1", utterance="Hi"),
Expand Down Expand Up @@ -1018,11 +1020,11 @@ async def check_sync():
# confirm local and remote are synced
assert await route_layer.async_is_synced()
# now confirm utterances are correct
local_utterances = await route_layer.index.aget_utterances()
# we sort to ensure order is the same
local_utterances.sort(
key=lambda x: x.to_str(include_metadata=include_metadata(index_cls))
local_utterances = await route_layer.index.aget_utterances(
include_metadata=True
)
# we sort to ensure order is the same
local_utterances.sort(key=lambda x: x.to_str(include_metadata=True))
assert local_utterances == [
Utterance(
route="Route 1",
Expand Down

0 comments on commit 948674e

Please sign in to comment.