# Path: pydoop/hdfs/common.py
# BUFSIZE = 16384
# 
# Path: pydoop/test_utils.py
# UNI_CHR = _get_special_chr()
# 
# def make_random_data(size=_RANDOM_DATA_SIZE, printable=True):
#     randint = random.randint
#     start, stop = (32, 126) if printable else (0, 255)
#     return bytes(bytearray([randint(start, stop) for _ in range(size)]))
# 
# class FSTree(object):
#     """
#   >>> t = FSTree('root')
#   >>> d1 = t.add('d1')
#   >>> f1 = t.add('f1', 0)
#   >>> d2 = d1.add('d2')
#   >>> f2 = d2.add('f2', 0)
#   >>> for x in t.walk(): print x.name, x.kind
#   ...
#   root 1
#   d1 1
#   d2 1
#   f2 0
#   f1 0
#   """
# 
#     def __init__(self, name, kind=1):
#         assert kind in (0, 1)  # (file, dir)
#         self.name = name
#         self.kind = kind
#         if self.kind:
#             self.children = []
# 
#     def add(self, name, kind=1):
#         t = FSTree(name, kind)
#         self.children.append(t)
#         return t
# 
#     def walk(self):
#         yield self
#         if self.kind:
#             for c in self.children:
#                 for t in c.walk():
#                     yield t


import unittest
import tempfile
import os
import stat
import pydoop.hdfs as hdfs
from pydoop.utils.py3compat import czip
from threading import Thread
from pydoop.hdfs.common import BUFSIZE
from pydoop.test_utils import UNI_CHR, make_random_data, FSTree
            self.__cp_file(wd)
            self.__cp_dir(wd)
            self.__cp_recursive(wd)

    def put(self):
        src = hdfs.path.split(self.local_paths[0])[-1]
        dest = self.hdfs_paths[0]
        with open(src, "wb") as f:
            f.write(self.data)
        hdfs.put(src, dest, mode="wb")
        with hdfs.open(dest) as fi:
            rdata = fi.read()
        self.assertEqual(rdata, self.data)

    def get(self):
        src = self.hdfs_paths[0]
        dest = hdfs.path.split(self.local_paths[0])[-1]
        hdfs.dump(self.data, src, mode="wb")
        hdfs.get(src, dest, mode="wb")
        with open(dest, 'rb') as fi:
            rdata = fi.read()
        self.assertEqual(rdata, self.data)

    def rm(self):
        for wd in self.local_wd, self.hdfs_wd:
            t1 = self.__make_tree(wd)
            hdfs.rm(t1.name)
            self.assertEqual(len(hdfs.ls(wd)), 0)

    def chmod(self):

# Path: pydoop/hdfs/common.py
# BUFSIZE = 16384
# 
# Path: pydoop/test_utils.py
# UNI_CHR = _get_special_chr()
# 
# def make_random_data(size=_RANDOM_DATA_SIZE, printable=True):
#     randint = random.randint
#     start, stop = (32, 126) if printable else (0, 255)
#     return bytes(bytearray([randint(start, stop) for _ in range(size)]))
# 
# class FSTree(object):
#     """
#   >>> t = FSTree('root')
#   >>> d1 = t.add('d1')
#   >>> f1 = t.add('f1', 0)
#   >>> d2 = d1.add('d2')
#   >>> f2 = d2.add('f2', 0)
#   >>> for x in t.walk(): print x.name, x.kind
#   ...
#   root 1
#   d1 1
#   d2 1
#   f2 0
#   f1 0
#   """
# 
#     def __init__(self, name, kind=1):
#         assert kind in (0, 1)  # (file, dir)
#         self.name = name
#         self.kind = kind
#         if self.kind:
#             self.children = []
# 
#     def add(self, name, kind=1):
#         t = FSTree(name, kind)
#         self.children.append(t)
#         return t
# 
#     def walk(self):
#         yield self
#         if self.kind:
#             for c in self.children:
#                 for t in c.walk():
#                     yield t


# Path: test/hdfs/test_hdfs.py
import unittest
import tempfile
import os
import stat
import pydoop.hdfs as hdfs
from pydoop.utils.py3compat import czip
from threading import Thread
from pydoop.hdfs.common import BUFSIZE
from pydoop.test_utils import UNI_CHR, make_random_data, FSTree

            self.__cp_file(wd)
            self.__cp_dir(wd)
            self.__cp_recursive(wd)

    def put(self):
        src = hdfs.path.split(self.local_paths[0])[-1]
        dest = self.hdfs_paths[0]
        with open(src, "wb") as f:
            f.write(self.data)
        hdfs.put(src, dest, mode="wb")
        with hdfs.open(dest) as fi:
            rdata = fi.read()
        self.assertEqual(rdata, self.data)

    def get(self):
        src = self.hdfs_paths[0]
        dest = hdfs.path.split(self.local_paths[0])[-1]
        hdfs.dump(self.data, src, mode="wb")
        hdfs.get(src, dest, mode="wb")
        with open(dest, 'rb') as fi:
            rdata = fi.read()
        self.assertEqual(rdata, self.data)

    def rm(self):
        for wd in self.local_wd, self.hdfs_wd:
            t1 = self.__make_tree(wd)
            hdfs.rm(t1.name)
            self.assertEqual(len(hdfs.ls(wd)), 0)

    def chmod(self):

        with tempfile.NamedTemporaryFile(suffix='_%s' % UNI_CHR) as f: