Skip to content

Commit

Permalink
added FsNode last_modified time test
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
  • Loading branch information
bigcat88 committed Jul 29, 2023
1 parent 1c97eef commit 9de3f04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 0 additions & 2 deletions nc_py_api/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,6 @@ def _lf_parse_webdav_records(self, webdav_res: Response, info: str, favorite=Fal
check_error(webdav_res.status_code, info=info)
if webdav_res.status_code != 207: # multistatus
raise NextcloudException(webdav_res.status_code, "Response is not a multistatus.", info=info)
if not webdav_res.text:
raise NextcloudException(webdav_res.status_code, "Response is empty.", info=info)
response_data = loads(dumps(xmltodict.parse(webdav_res.text)))
if "d:error" in response_data:
err = response_data["d:error"]
Expand Down
10 changes: 10 additions & 0 deletions tests/files_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import math
from datetime import datetime
from io import BytesIO
from random import choice, randbytes
from string import ascii_lowercase
Expand Down Expand Up @@ -549,3 +550,12 @@ def test_fs_node_is_xx(nc):
assert not folder.is_shared
finally:
nc.files.delete("test_root_folder")


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

0 comments on commit 9de3f04

Please sign in to comment.