Skip to content

Commit 86af0a5

Browse files
authored
fix coverage for "creation_date" (#337)
Related PR: #335 Signed-off-by: bigcat88 <bigcat88@icloud.com>
1 parent 0f8566c commit 86af0a5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

nc_py_api/files/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ def __init__(self, **kwargs):
104104
except (ValueError, TypeError):
105105
self.last_modified = datetime.datetime(1970, 1, 1)
106106
try:
107-
self._creation_date = kwargs.get("creation_date", datetime.datetime(1970, 1, 1))
107+
self.creation_date = kwargs.get("creation_date", datetime.datetime(1970, 1, 1))
108108
except (ValueError, TypeError):
109-
self._creation_date = datetime.datetime(1970, 1, 1)
109+
self.creation_date = datetime.datetime(1970, 1, 1)
110110
self._trashbin: dict[str, str | int] = {}
111111
for i in ("trashbin_filename", "trashbin_original_location", "trashbin_deletion_time"):
112112
if i in kwargs:

tests/actual_tests/files_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ def test_fs_node_fields(nc_any):
827827
assert res_by_id.user == res_by_path.user == result.user
828828
assert res_by_id.etag == res_by_path.etag == result.etag
829829
assert res_by_id.info.last_modified == res_by_path.info.last_modified == result.info.last_modified
830+
assert res_by_id.info.creation_date == res_by_path.info.creation_date == result.info.creation_date
830831

831832

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

963964

965+
def test_fs_node_creation_date_time():
966+
fs_node = FsNode("", creation_date="wrong time")
967+
assert fs_node.info.creation_date == datetime(1970, 1, 1)
968+
fs_node = FsNode("", creation_date="Sat, 29 Jul 2023 11:56:31")
969+
assert fs_node.info.creation_date == datetime(2023, 7, 29, 11, 56, 31)
970+
fs_node = FsNode("", creation_date=datetime(2022, 4, 5, 1, 2, 3))
971+
assert fs_node.info.creation_date == datetime(2022, 4, 5, 1, 2, 3)
972+
973+
964974
@pytest.mark.parametrize(
965975
"file_path", ("test_dir_tmp/trashbin_test", "test_dir_tmp/trashbin_test-ä", "test_dir_tmp/trashbin_test-1##3")
966976
)

0 commit comments

Comments
 (0)