Skip to content

Commit c1d9d9f

Browse files
author
atollk
committed
Added test for new "modified" namespace in FTPFS.
1 parent 3d56a46 commit c1d9d9f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tests/test_ftpfs.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ def test_manager_with_host(self):
144144
@mark.slow
145145
@unittest.skipIf(platform.python_implementation() == "PyPy", "ftp unreliable with PyPy")
146146
class TestFTPFS(FSTestCases, unittest.TestCase):
147-
148147
user = "user"
149148
pasw = "1234"
150149

@@ -243,6 +242,23 @@ def test_getmeta_unicode_path(self):
243242
del self.fs.features["UTF8"]
244243
self.assertFalse(self.fs.getmeta().get("unicode_paths"))
245244

245+
def test_getinfo_modified(self):
246+
self.assertIn("MDTM", self.fs.features)
247+
self.fs.create("bar")
248+
mtime_detail = self.fs.getinfo("bar", ("basic", "details")).modified
249+
mtime_modified = self.fs.getinfo("bar", ("modified",)).modified
250+
# Microsecond and seconds might not actually be supported by all
251+
# FTP commands, so we strip them before comparing if it looks
252+
# like at least one of the two values does not contain them.
253+
replacement = {}
254+
if mtime_detail.microsecond == 0 or mtime_modified.microsecond == 0:
255+
replacement["microsecond"] = 0
256+
if mtime_detail.second == 0 or mtime_modified.second == 0:
257+
replacement["second"] = 0
258+
self.assertEqual(
259+
mtime_detail.replace(**replacement), mtime_modified.replace(**replacement)
260+
)
261+
246262
def test_opener_path(self):
247263
self.fs.makedir("foo")
248264
self.fs.writetext("foo/bar", "baz")
@@ -301,7 +317,6 @@ def test_features(self):
301317
@mark.slow
302318
@unittest.skipIf(platform.python_implementation() == "PyPy", "ftp unreliable with PyPy")
303319
class TestAnonFTPFS(FSTestCases, unittest.TestCase):
304-
305320
user = "anonymous"
306321
pasw = ""
307322

0 commit comments

Comments
 (0)