def test_get_dir_creation_date(self): path = self.temp_path("a/b/c.txt") fsutil.create_file(path, content="Hello World") creation_date = fsutil.get_dir_creation_date(self.temp_path("a/b")) now = dt.datetime.now() self.assertTrue((now - creation_date) < dt.timedelta(seconds=0.1)) time.sleep(0.2) creation_date = fsutil.get_dir_creation_date(self.temp_path("a/b")) now = dt.datetime.now() self.assertFalse((now - creation_date) < dt.timedelta(seconds=0.1))
def test_get_dir_last_modified_date(self): path = self.temp_path("a/b/c.txt") fsutil.create_file(path, content="Hello") creation_date = fsutil.get_dir_creation_date(self.temp_path("a")) time.sleep(0.2) fsutil.write_file(path, content="Goodbye", append=True) now = dt.datetime.now() lastmod_date = fsutil.get_dir_last_modified_date(self.temp_path("a")) self.assertTrue((now - lastmod_date) < dt.timedelta(seconds=0.1)) self.assertTrue((lastmod_date - creation_date) > dt.timedelta(seconds=0.15))