From 1db73345d6bbf71401f8615a2ec1d1967dcfd431 Mon Sep 17 00:00:00 2001 From: Matt Seddon Date: Fri, 13 Sep 2024 09:38:08 +1000 Subject: [PATCH] fix timezone and microseconds of last modified in resolve file test --- tests/unit/lib/test_file.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/unit/lib/test_file.py b/tests/unit/lib/test_file.py index 38d177b04..ca6d4599c 100644 --- a/tests/unit/lib/test_file.py +++ b/tests/unit/lib/test_file.py @@ -2,12 +2,14 @@ from unittest.mock import Mock import pytest +import pytz from fsspec.implementations.local import LocalFileSystem from PIL import Image from datachain import DataChain from datachain.cache import UniqueId from datachain.catalog import Catalog +from datachain.data_storage.sqlite import SQLiteWarehouse from datachain.lib.file import File, ImageFile, TextFile, resolve from datachain.utils import TIME_ZERO @@ -327,11 +329,21 @@ def test_read_text(tmp_path, catalog): def test_resolve_file(cloud_test_catalog): ctc = cloud_test_catalog + is_sqlite = isinstance(cloud_test_catalog.catalog.warehouse, SQLiteWarehouse) + dc = DataChain.from_storage(ctc.src_uri, session=ctc.session) for orig_file in dc.collect("file"): - resolved_file = File(source=orig_file.source, path=orig_file.path) - resolved_file._catalog = ctc.catalog - assert orig_file == resolved_file.resolve() + file = File( + source=orig_file.source, + path=orig_file.path, + ) + file._catalog = ctc.catalog + resolved_file = file.resolve() + if not is_sqlite: + resolved_file.last_modified = resolved_file.last_modified.replace( + microsecond=0, tzinfo=pytz.UTC + ) + assert orig_file == resolved_file def test_resolve_file_no_exist(cloud_test_catalog):