def test_get_updated_stats(self): test_file = tempfile.NamedTemporaryFile(dir=self.tmp_dir_1, delete=True) self.assertEqual(FileUtil.get_file_stat(test_file.name)[0], 0) test_file.write(b"test\n") test_file.flush() self.assertEqual(FileUtil.get_file_stat(test_file.name)[0], 5)
def test_get_updated_stats(self): test_file = tempfile.NamedTemporaryFile(dir=self.tmp_dir_1, delete=True) self.assertEqual(FileUtil.get_file_stat(test_file.name)[0], 0) test_file.write(b"test\n") test_file.flush() self.assertEqual(FileUtil.get_file_stat(test_file.name)[0], 5)
def test_get_file_stat_for_invalid_file(self): self.assertIsNone(FileUtil.get_file_stat('/tmp/xyz.gpg'))
def test_get_file_stat_for_empty_file(self): test_file = tempfile.NamedTemporaryFile(dir=self.tmp_dir_1, delete=True) self.assertEqual(FileUtil.get_file_stat(test_file.name)[0], 0)
def test_get_file_stat_for_non_empty_file(self): file_size = FileUtil.get_file_stat(self.test_file_1)[0] self.assertEqual(file_size, 5)
def get_updated_file_stats(self): return {filename: FileUtil.get_file_stat(filename) for filename in self.file_stats.keys()}
def add_file_to_snapshot(self, file_path): if file_path and os.path.exists(file_path): self.file_stats[file_path] = FileUtil.get_file_stat(file_path)
def test_get_file_stat_for_invalid_file(self): self.assertIsNone(FileUtil.get_file_stat('/tmp/xyz.gpg'))
def test_get_file_stat_for_empty_file(self): test_file = tempfile.NamedTemporaryFile(dir=self.tmp_dir_1, delete=True) self.assertEqual(FileUtil.get_file_stat(test_file.name)[0], 0)
def test_get_file_stat_for_non_empty_file(self): file_size = FileUtil.get_file_stat(self.test_file_1)[0] self.assertEqual(file_size, 5)