Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix last modified comparison in resolve file test #436

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions tests/unit/lib/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a similar strategy in test_from_storage_check_rows


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):
Expand Down