def size(self): """ Calculates aggregate length of files contained in the directory or the length of a file in case regular file. :return: size of file :rtype: long """ self._assert_exists_() return fs.file_size(self.path)
def test_directory_size_command(self): _stdout = "3137674753 /tmp/file.txt" with patch(HDFS_IS_DIR_FUNC) as mock_isdir: mock_isdir.return_value = True size = hdfs_client.file_size( "/tmp/file.txt", executor=lambda cmd, *args: self._assert_command_generation( "hadoop fs -du -s /tmp/file.txt", stdout=_stdout) (cmd, *args)) self.assertEqual(3137674753, size)
def test_directory_size_command(self): _stdout = "3137674753 /tmp/file.txt" with patch(HDFS_IS_DIR_FUNC) as mock_isdir: mock_isdir.return_value = True size = hdfs_client.file_size( "/tmp/file.txt", executor=lambda cmd, *args: self._assert_command_generation( "hadoop fs -du -s /tmp/file.txt", stdout=_stdout )(cmd, *args), ) self.assertEqual(3137674753, size)