core: Add ruff rules DTZ (#30657)

Add ruff rules DTZ:
https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
This commit is contained in:
Christophe Bornet 2025-04-04 19:43:47 +02:00 committed by GitHub
parent 5e418c2666
commit 150ac0cb79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 232 additions and 79 deletions

View File

@ -99,7 +99,6 @@ ignore = [
"ARG", "ARG",
"BLE", "BLE",
"ERA", "ERA",
"DTZ",
"FBT001", "FBT001",
"FBT002", "FBT002",
"PGH", "PGH",

View File

@ -18,21 +18,21 @@ EXAMPLES = [
outputs={"res": "a"}, outputs={"res": "a"},
dataset_id=uuid.uuid4(), dataset_id=uuid.uuid4(),
id=uuid.uuid4(), id=uuid.uuid4(),
created_at=datetime.datetime.now(), created_at=datetime.datetime.now(datetime.timezone.utc),
), ),
Example( Example(
inputs={"first": {"second": "bar"}}, inputs={"first": {"second": "bar"}},
outputs={"res": "b"}, outputs={"res": "b"},
dataset_id=uuid.uuid4(), dataset_id=uuid.uuid4(),
id=uuid.uuid4(), id=uuid.uuid4(),
created_at=datetime.datetime.now(), created_at=datetime.datetime.now(datetime.timezone.utc),
), ),
Example( Example(
inputs={"first": {"second": "baz"}}, inputs={"first": {"second": "baz"}},
outputs={"res": "c"}, outputs={"res": "c"},
dataset_id=uuid.uuid4(), dataset_id=uuid.uuid4(),
id=uuid.uuid4(), id=uuid.uuid4(),
created_at=datetime.datetime.now(), created_at=datetime.datetime.now(datetime.timezone.utc),
), ),
] ]

View File

@ -1,4 +1,4 @@
from datetime import datetime from datetime import datetime, timezone
from unittest.mock import patch from unittest.mock import patch
import pytest import pytest
@ -55,50 +55,94 @@ def test_update_timestamp(manager: InMemoryRecordManager) -> None:
"""Test updating records in the database.""" """Test updating records in the database."""
# no keys should be present in the set # no keys should be present in the set
with patch.object( with patch.object(
manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
manager.update(["key1"]) manager.update(["key1"])
assert manager.list_keys() == ["key1"] assert manager.list_keys() == ["key1"]
assert manager.list_keys(before=datetime(2021, 1, 1).timestamp()) == [] assert (
assert manager.list_keys(after=datetime(2021, 1, 1).timestamp()) == ["key1"] manager.list_keys(before=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp())
assert manager.list_keys(after=datetime(2021, 1, 3).timestamp()) == [] == []
)
assert manager.list_keys(
after=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp()
) == ["key1"]
assert (
manager.list_keys(after=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp())
== []
)
# Update the timestamp # Update the timestamp
with patch.object( with patch.object(
manager, "get_time", return_value=datetime(2023, 1, 5).timestamp() manager,
"get_time",
return_value=datetime(2023, 1, 5, tzinfo=timezone.utc).timestamp(),
): ):
manager.update(["key1"]) manager.update(["key1"])
assert manager.list_keys() == ["key1"] assert manager.list_keys() == ["key1"]
assert manager.list_keys(before=datetime(2023, 1, 1).timestamp()) == [] assert (
assert manager.list_keys(after=datetime(2023, 1, 1).timestamp()) == ["key1"] manager.list_keys(before=datetime(2023, 1, 1, tzinfo=timezone.utc).timestamp())
assert manager.list_keys(after=datetime(2023, 1, 3).timestamp()) == ["key1"] == []
)
assert manager.list_keys(
after=datetime(2023, 1, 1, tzinfo=timezone.utc).timestamp()
) == ["key1"]
assert manager.list_keys(
after=datetime(2023, 1, 3, tzinfo=timezone.utc).timestamp()
) == ["key1"]
async def test_aupdate_timestamp(manager: InMemoryRecordManager) -> None: async def test_aupdate_timestamp(manager: InMemoryRecordManager) -> None:
"""Test updating records in the database.""" """Test updating records in the database."""
# no keys should be present in the set # no keys should be present in the set
with patch.object( with patch.object(
manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
await manager.aupdate(["key1"]) await manager.aupdate(["key1"])
assert await manager.alist_keys() == ["key1"] assert await manager.alist_keys() == ["key1"]
assert await manager.alist_keys(before=datetime(2021, 1, 1).timestamp()) == [] assert (
assert await manager.alist_keys(after=datetime(2021, 1, 1).timestamp()) == ["key1"] await manager.alist_keys(
assert await manager.alist_keys(after=datetime(2021, 1, 3).timestamp()) == [] before=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp()
)
== []
)
assert await manager.alist_keys(
after=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp()
) == ["key1"]
assert (
await manager.alist_keys(
after=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp()
)
== []
)
# Update the timestamp # Update the timestamp
with patch.object( with patch.object(
manager, "get_time", return_value=datetime(2023, 1, 5).timestamp() manager,
"get_time",
return_value=datetime(2023, 1, 5, tzinfo=timezone.utc).timestamp(),
): ):
await manager.aupdate(["key1"]) await manager.aupdate(["key1"])
assert await manager.alist_keys() == ["key1"] assert await manager.alist_keys() == ["key1"]
assert await manager.alist_keys(before=datetime(2023, 1, 1).timestamp()) == [] assert (
assert await manager.alist_keys(after=datetime(2023, 1, 1).timestamp()) == ["key1"] await manager.alist_keys(
assert await manager.alist_keys(after=datetime(2023, 1, 3).timestamp()) == ["key1"] before=datetime(2023, 1, 1, tzinfo=timezone.utc).timestamp()
)
== []
)
assert await manager.alist_keys(
after=datetime(2023, 1, 1, tzinfo=timezone.utc).timestamp()
) == ["key1"]
assert await manager.alist_keys(
after=datetime(2023, 1, 3, tzinfo=timezone.utc).timestamp()
) == ["key1"]
def test_exists(manager: InMemoryRecordManager) -> None: def test_exists(manager: InMemoryRecordManager) -> None:
@ -138,14 +182,18 @@ async def test_list_keys(manager: InMemoryRecordManager) -> None:
assert await manager.alist_keys() == [] assert await manager.alist_keys() == []
with patch.object( with patch.object(
manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
manager.update(["key1", "key2"]) manager.update(["key1", "key2"])
manager.update(["key3"], group_ids=["group1"]) manager.update(["key3"], group_ids=["group1"])
manager.update(["key4"], group_ids=["group2"]) manager.update(["key4"], group_ids=["group2"])
with patch.object( with patch.object(
manager, "get_time", return_value=datetime(2021, 1, 10).timestamp() manager,
"get_time",
return_value=datetime(2021, 1, 10, tzinfo=timezone.utc).timestamp(),
): ):
manager.update(["key5"]) manager.update(["key5"])
@ -163,14 +211,18 @@ async def test_list_keys(manager: InMemoryRecordManager) -> None:
assert await manager.alist_keys(group_ids=["group1"]) == ["key3"] assert await manager.alist_keys(group_ids=["group1"]) == ["key3"]
# Before # Before
assert sorted(manager.list_keys(before=datetime(2021, 1, 3).timestamp())) == [ assert sorted(
manager.list_keys(before=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp())
) == [
"key1", "key1",
"key2", "key2",
"key3", "key3",
"key4", "key4",
] ]
assert sorted( assert sorted(
await manager.alist_keys(before=datetime(2021, 1, 3).timestamp()) await manager.alist_keys(
before=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp()
)
) == [ ) == [
"key1", "key1",
"key2", "key2",
@ -179,10 +231,14 @@ async def test_list_keys(manager: InMemoryRecordManager) -> None:
] ]
# After # After
assert sorted(manager.list_keys(after=datetime(2021, 1, 3).timestamp())) == ["key5"] assert sorted(
assert sorted(await manager.alist_keys(after=datetime(2021, 1, 3).timestamp())) == [ manager.list_keys(after=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp())
"key5" ) == ["key5"]
] assert sorted(
await manager.alist_keys(
after=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp()
)
) == ["key5"]
results = manager.list_keys(limit=1) results = manager.list_keys(limit=1)
assert len(results) == 1 assert len(results) == 1

View File

@ -1,5 +1,5 @@
from collections.abc import AsyncIterator, Iterable, Iterator, Sequence from collections.abc import AsyncIterator, Iterable, Iterator, Sequence
from datetime import datetime from datetime import datetime, timezone
from typing import ( from typing import (
Any, Any,
) )
@ -151,7 +151,9 @@ def test_index_simple_delete_full(
) )
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert index(loader, record_manager, vector_store, cleanup="full") == { assert index(loader, record_manager, vector_store, cleanup="full") == {
"num_added": 2, "num_added": 2,
@ -161,7 +163,9 @@ def test_index_simple_delete_full(
} }
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert index(loader, record_manager, vector_store, cleanup="full") == { assert index(loader, record_manager, vector_store, cleanup="full") == {
"num_added": 0, "num_added": 0,
@ -182,7 +186,9 @@ def test_index_simple_delete_full(
) )
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
indexing_result = index(loader, record_manager, vector_store, cleanup="full") indexing_result = index(loader, record_manager, vector_store, cleanup="full")
@ -202,7 +208,9 @@ def test_index_simple_delete_full(
# Attempt to index again verify that nothing changes # Attempt to index again verify that nothing changes
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert index(loader, record_manager, vector_store, cleanup="full") == { assert index(loader, record_manager, vector_store, cleanup="full") == {
"num_added": 0, "num_added": 0,
@ -228,7 +236,9 @@ async def test_aindex_simple_delete_full(
) )
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex(loader, arecord_manager, vector_store, cleanup="full") == { assert await aindex(loader, arecord_manager, vector_store, cleanup="full") == {
"num_added": 2, "num_added": 2,
@ -238,7 +248,9 @@ async def test_aindex_simple_delete_full(
} }
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex(loader, arecord_manager, vector_store, cleanup="full") == { assert await aindex(loader, arecord_manager, vector_store, cleanup="full") == {
"num_added": 0, "num_added": 0,
@ -259,7 +271,9 @@ async def test_aindex_simple_delete_full(
) )
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex(loader, arecord_manager, vector_store, cleanup="full") == { assert await aindex(loader, arecord_manager, vector_store, cleanup="full") == {
"num_added": 1, "num_added": 1,
@ -277,7 +291,9 @@ async def test_aindex_simple_delete_full(
# Attempt to index again verify that nothing changes # Attempt to index again verify that nothing changes
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex(loader, arecord_manager, vector_store, cleanup="full") == { assert await aindex(loader, arecord_manager, vector_store, cleanup="full") == {
"num_added": 0, "num_added": 0,
@ -303,7 +319,9 @@ def test_index_delete_full_recovery_after_deletion_failure(
) )
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert index(loader, record_manager, vector_store, cleanup="full") == { assert index(loader, record_manager, vector_store, cleanup="full") == {
"num_added": 2, "num_added": 2,
@ -325,7 +343,9 @@ def test_index_delete_full_recovery_after_deletion_failure(
with ( with (
patch.object( patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
), ),
patch.object(vector_store, "delete", return_value=False), patch.object(vector_store, "delete", return_value=False),
pytest.raises(IndexingException), pytest.raises(IndexingException),
@ -346,7 +366,9 @@ def test_index_delete_full_recovery_after_deletion_failure(
} }
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 3).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp(),
): ):
indexing_result = index(loader, record_manager, vector_store, cleanup="full") indexing_result = index(loader, record_manager, vector_store, cleanup="full")
doc_texts = { doc_texts = {
@ -380,7 +402,9 @@ async def test_aindex_delete_full_recovery_after_deletion_failure(
) )
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex(loader, arecord_manager, vector_store, cleanup="full") == { assert await aindex(loader, arecord_manager, vector_store, cleanup="full") == {
"num_added": 2, "num_added": 2,
@ -402,7 +426,9 @@ async def test_aindex_delete_full_recovery_after_deletion_failure(
with ( with (
patch.object( patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
), ),
patch.object(vector_store, "adelete", return_value=False), patch.object(vector_store, "adelete", return_value=False),
pytest.raises(IndexingException), pytest.raises(IndexingException),
@ -425,7 +451,9 @@ async def test_aindex_delete_full_recovery_after_deletion_failure(
} }
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 3).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp(),
): ):
indexing_result = await aindex( indexing_result = await aindex(
loader, arecord_manager, vector_store, cleanup="full" loader, arecord_manager, vector_store, cleanup="full"
@ -564,7 +592,9 @@ def test_index_simple_delete_scoped_full(
) )
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -580,7 +610,9 @@ def test_index_simple_delete_scoped_full(
} }
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -609,7 +641,9 @@ def test_index_simple_delete_scoped_full(
) )
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 3).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -636,7 +670,9 @@ def test_index_simple_delete_scoped_full(
# Attempt to index again verify that nothing changes # Attempt to index again verify that nothing changes
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 4).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 4, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -678,7 +714,9 @@ async def test_aindex_simple_delete_scoped_full(
) )
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader, loader,
@ -694,7 +732,9 @@ async def test_aindex_simple_delete_scoped_full(
} }
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader, loader,
@ -723,7 +763,9 @@ async def test_aindex_simple_delete_scoped_full(
) )
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 3).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader, loader,
@ -750,7 +792,9 @@ async def test_aindex_simple_delete_scoped_full(
# Attempt to index again verify that nothing changes # Attempt to index again verify that nothing changes
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 4).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 4, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader, loader,
@ -880,7 +924,9 @@ def test_index_empty_doc_scoped_full(
) )
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -896,7 +942,9 @@ def test_index_empty_doc_scoped_full(
} }
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -914,7 +962,9 @@ def test_index_empty_doc_scoped_full(
loader = ToyLoader(documents=[]) loader = ToyLoader(documents=[])
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 3).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -956,7 +1006,9 @@ async def test_aindex_empty_doc_scoped_full(
) )
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader, loader,
@ -972,7 +1024,9 @@ async def test_aindex_empty_doc_scoped_full(
} }
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader, loader,
@ -990,7 +1044,9 @@ async def test_aindex_empty_doc_scoped_full(
loader = ToyLoader(documents=[]) loader = ToyLoader(documents=[])
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 3).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader, loader,
@ -1024,7 +1080,9 @@ def test_no_delete(
) )
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -1041,7 +1099,9 @@ def test_no_delete(
# If we add the same content twice it should be skipped # If we add the same content twice it should be skipped
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -1071,7 +1131,9 @@ def test_no_delete(
# Should result in no updates or deletions! # Should result in no updates or deletions!
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -1105,7 +1167,9 @@ async def test_ano_delete(
) )
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader, loader,
@ -1122,7 +1186,9 @@ async def test_ano_delete(
# If we add the same content twice it should be skipped # If we add the same content twice it should be skipped
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader, loader,
@ -1152,7 +1218,9 @@ async def test_ano_delete(
# Should result in no updates or deletions! # Should result in no updates or deletions!
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader, loader,
@ -1186,7 +1254,9 @@ def test_incremental_delete(
) )
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -1210,7 +1280,9 @@ def test_incremental_delete(
# Attempt to index again verify that nothing changes # Attempt to index again verify that nothing changes
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -1245,7 +1317,9 @@ def test_incremental_delete(
# Attempt to index again verify that nothing changes # Attempt to index again verify that nothing changes
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 3).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -1290,7 +1364,9 @@ def test_incremental_delete_with_same_source(
) )
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -1323,7 +1399,9 @@ def test_incremental_delete_with_same_source(
) )
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -1374,7 +1452,9 @@ def test_incremental_indexing_with_batch_size(
) )
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -1398,7 +1478,9 @@ def test_incremental_indexing_with_batch_size(
assert doc_texts == {"1", "2", "3", "4"} assert doc_texts == {"1", "2", "3", "4"}
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -1448,7 +1530,9 @@ def test_incremental_delete_with_batch_size(
) )
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 1).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 1, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -1473,7 +1557,9 @@ def test_incremental_delete_with_batch_size(
# Attempt to index again verify that nothing changes # Attempt to index again verify that nothing changes
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() record_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert index( assert index(
loader, loader,
@ -1498,7 +1584,9 @@ def test_incremental_delete_with_batch_size(
# Attempt to index again verify that nothing changes # Attempt to index again verify that nothing changes
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2022, 1, 3).timestamp() record_manager,
"get_time",
return_value=datetime(2022, 1, 3, tzinfo=timezone.utc).timestamp(),
): ):
# Docs with same content # Docs with same content
docs = [ docs = [
@ -1534,7 +1622,9 @@ def test_incremental_delete_with_batch_size(
# Attempt to index again verify that nothing changes # Attempt to index again verify that nothing changes
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2023, 1, 4).timestamp() record_manager,
"get_time",
return_value=datetime(2023, 1, 4, tzinfo=timezone.utc).timestamp(),
): ):
# Docs with same content # Docs with same content
docs = [ docs = [
@ -1570,7 +1660,9 @@ def test_incremental_delete_with_batch_size(
# Try to index with changed docs now # Try to index with changed docs now
with patch.object( with patch.object(
record_manager, "get_time", return_value=datetime(2024, 1, 5).timestamp() record_manager,
"get_time",
return_value=datetime(2024, 1, 5, tzinfo=timezone.utc).timestamp(),
): ):
# Docs with same content # Docs with same content
docs = [ docs = [
@ -1622,7 +1714,9 @@ async def test_aincremental_delete(
) )
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader.lazy_load(), loader.lazy_load(),
@ -1646,7 +1740,9 @@ async def test_aincremental_delete(
# Attempt to index again verify that nothing changes # Attempt to index again verify that nothing changes
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 2).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader.lazy_load(), loader.lazy_load(),
@ -1681,7 +1777,9 @@ async def test_aincremental_delete(
# Attempt to index again verify that nothing changes # Attempt to index again verify that nothing changes
with patch.object( with patch.object(
arecord_manager, "get_time", return_value=datetime(2021, 1, 3).timestamp() arecord_manager,
"get_time",
return_value=datetime(2021, 1, 3, tzinfo=timezone.utc).timestamp(),
): ):
assert await aindex( assert await aindex(
loader.lazy_load(), loader.lazy_load(),