Skip to content

fix coverage for "creation_date" #337

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

Merged
merged 1 commit into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions nc_py_api/files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def __init__(self, **kwargs):
except (ValueError, TypeError):
self.last_modified = datetime.datetime(1970, 1, 1)
try:
self._creation_date = kwargs.get("creation_date", datetime.datetime(1970, 1, 1))
self.creation_date = kwargs.get("creation_date", datetime.datetime(1970, 1, 1))
except (ValueError, TypeError):
self._creation_date = datetime.datetime(1970, 1, 1)
self.creation_date = datetime.datetime(1970, 1, 1)
self._trashbin: dict[str, str | int] = {}
for i in ("trashbin_filename", "trashbin_original_location", "trashbin_deletion_time"):
if i in kwargs:
Expand Down
10 changes: 10 additions & 0 deletions tests/actual_tests/files_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ def test_fs_node_fields(nc_any):
assert res_by_id.user == res_by_path.user == result.user
assert res_by_id.etag == res_by_path.etag == result.etag
assert res_by_id.info.last_modified == res_by_path.info.last_modified == result.info.last_modified
assert res_by_id.info.creation_date == res_by_path.info.creation_date == result.info.creation_date


def test_makedirs(nc_any):
Expand Down Expand Up @@ -961,6 +962,15 @@ def test_fs_node_last_modified_time():
assert fs_node.info.last_modified == datetime(2022, 4, 5, 1, 2, 3)


def test_fs_node_creation_date_time():
fs_node = FsNode("", creation_date="wrong time")
assert fs_node.info.creation_date == datetime(1970, 1, 1)
fs_node = FsNode("", creation_date="Sat, 29 Jul 2023 11:56:31")
assert fs_node.info.creation_date == datetime(2023, 7, 29, 11, 56, 31)
fs_node = FsNode("", creation_date=datetime(2022, 4, 5, 1, 2, 3))
assert fs_node.info.creation_date == datetime(2022, 4, 5, 1, 2, 3)


@pytest.mark.parametrize(
"file_path", ("test_dir_tmp/trashbin_test", "test_dir_tmp/trashbin_test-ä", "test_dir_tmp/trashbin_test-1##3")
)
Expand Down