Skip to content

Commit

Permalink
fix test for ch wrt datetime precision (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Jul 24, 2024
1 parent 8ae71fa commit 3bbba09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ dev = [
"datachain[docs,tests]",
"mypy==1.10.1",
"types-python-dateutil",
"types-pytz",
"types-PyYAML",
"types-requests",
"types-ujson"
Expand Down
9 changes: 8 additions & 1 deletion tests/func/test_datachain.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import math
import os
import re
from datetime import datetime, timezone
from pathlib import Path

import pandas as pd
import pytest
import pytz

from datachain.data_storage.sqlite import SQLiteWarehouse
from datachain.dataset import DatasetStats
from datachain.lib.dc import DataChain
from datachain.lib.file import File
Expand Down Expand Up @@ -228,9 +231,13 @@ def test_from_storage_check_rows(tmp_dir, catalog):

dc = DataChain.from_storage(tmp_dir.as_uri(), catalog=catalog).save("test-data")

is_sqlite = isinstance(catalog.warehouse, SQLiteWarehouse)
tz = timezone.utc if is_sqlite else pytz.UTC

for (file,) in dc.collect():
assert isinstance(file, File)
stat = stats[file.name]
mtime = stat.st_mtime if is_sqlite else float(math.floor(stat.st_mtime))
assert file == File(
source=Path(tmp_dir.anchor).as_uri(),
parent=tmp_dir.relative_to(tmp_dir.anchor),
Expand All @@ -239,7 +246,7 @@ def test_from_storage_check_rows(tmp_dir, catalog):
version="",
etag=stat.st_mtime.hex(),
is_latest=True,
last_modified=datetime.fromtimestamp(stat.st_mtime, timezone.utc),
last_modified=datetime.fromtimestamp(mtime, tz=tz),
location=None,
vtype="",
)

0 comments on commit 3bbba09

Please sign in to comment.