# Path: pydoop/hdfs/common.py
# DEFAULT_PORT = 8020  # org/apache/hadoop/hdfs/server/namenode/NameNode.java
# 
# DEFAULT_USER = getpass.getuser()
# 
# Path: pydoop/test_utils.py
# UNI_CHR = _get_special_chr()


import os
import unittest
import tempfile
import pydoop.hdfs as hdfs
from numbers import Number
from pydoop.hdfs.common import DEFAULT_PORT, DEFAULT_USER
from pydoop.utils.misc import make_random_str
from pydoop.test_utils import UNI_CHR
            )

    def with_user(self):
        abs_p = hdfs.path.abspath(self.p, user="pydoop", local=False)
        if hdfs.default_is_local():
            self.assertEqual(
                abs_p, '%s%s' % (self.root, os.path.abspath(self.p))
            )
        else:
            self.assertEqual(abs_p, '%s/user/pydoop/%s' % (self.root, self.p))

    def forced_local(self):
        for user in None, "pydoop":
            abs_p = hdfs.path.abspath(self.p, user=user, local=True)
            self.assertEqual(abs_p, 'file:%s' % os.path.abspath(self.p))

    def already_absolute(self):
        for p in ('file:/a/%s' % UNI_CHR,
                  'hdfs://localhost:9000/a/%s' % UNI_CHR):
            for user in None, "pydoop":
                abs_p = hdfs.path.abspath(p, user=user, local=False)
                self.assertEqual(abs_p, p)
                abs_p = hdfs.path.abspath(p, user=user, local=True)
                self.assertEqual(abs_p, 'file:%s' % os.path.abspath(p))


class TestSplitBasenameDirname(unittest.TestCase):

    def runTest(self):
        cases = [  # path, expected dirname, expected basename

# Path: pydoop/hdfs/common.py
# DEFAULT_PORT = 8020  # org/apache/hadoop/hdfs/server/namenode/NameNode.java
# 
# DEFAULT_USER = getpass.getuser()
# 
# Path: pydoop/test_utils.py
# UNI_CHR = _get_special_chr()


# Path: test/hdfs/test_path.py
import os
import unittest
import tempfile
import pydoop.hdfs as hdfs
from numbers import Number
from pydoop.hdfs.common import DEFAULT_PORT, DEFAULT_USER
from pydoop.utils.misc import make_random_str
from pydoop.test_utils import UNI_CHR

            )

    def with_user(self):
        abs_p = hdfs.path.abspath(self.p, user="pydoop", local=False)
        if hdfs.default_is_local():
            self.assertEqual(
                abs_p, '%s%s' % (self.root, os.path.abspath(self.p))
            )
        else:
            self.assertEqual(abs_p, '%s/user/pydoop/%s' % (self.root, self.p))

    def forced_local(self):
        for user in None, "pydoop":
            abs_p = hdfs.path.abspath(self.p, user=user, local=True)
            self.assertEqual(abs_p, 'file:%s' % os.path.abspath(self.p))

    def already_absolute(self):
        for p in ('file:/a/%s' % UNI_CHR,
                  'hdfs://localhost:9000/a/%s' % UNI_CHR):
            for user in None, "pydoop":
                abs_p = hdfs.path.abspath(p, user=user, local=False)
                self.assertEqual(abs_p, p)
                abs_p = hdfs.path.abspath(p, user=user, local=True)
                self.assertEqual(abs_p, 'file:%s' % os.path.abspath(p))


class TestSplitBasenameDirname(unittest.TestCase):

    def runTest(self):
        cases = [  # path, expected dirname, expected basename

            ("hdfs://host:1/a/%s" % UNI_CHR, "hdfs://host:1/a", UNI_CHR),