def test_do_ismount_successes_ino(self):

        _os_lstat = os.lstat

        class MockStat(object):
            def __init__(self, mode, dev, ino):
                self.st_mode = mode
                self.st_dev = dev
                self.st_ino = ino

        def _mock_os_lstat(path):
            if path.endswith(".."):
                return _os_lstat(path)
            else:
                parent_path = os.path.join(path, "..")
                child = _os_lstat(path)
                parent = _os_lstat(parent_path)
                return MockStat(child.st_mode, parent.st_ino,
                                child.st_dev)

        tmpdir = mkdtemp()
        try:
            with patch("os.lstat", _mock_os_lstat):
                try:
                    fs.do_ismount(tmpdir)
                except SwiftOnFileSystemOSError:
                    self.fail("Unexpected exception")
                else:
                    pass
        finally:
            shutil.rmtree(tmpdir)
    def test_do_ismount_path_error(self):

        def _mock_os_lstat(path):
            raise OSError(13, "foo")

        tmpdir = mkdtemp()
        try:
            with patch("os.lstat", _mock_os_lstat):
                try:
                    fs.do_ismount(tmpdir)
                except SwiftOnFileSystemOSError:
                    pass
                else:
                    self.fail("Expected SwiftOnFileSystemOSError")
        finally:
            shutil.rmtree(tmpdir)
 def test_do_ismount_path_is_symlink(self):
     tmpdir = mkdtemp()
     try:
         link = os.path.join(tmpdir, "tmp")
         os.symlink("/tmp", link)
         assert False == fs.do_ismount(link)
     finally:
         shutil.rmtree(tmpdir)
 def test_do_ismount_path_not_mount(self):
     tmpdir = mkdtemp()
     try:
         assert False == fs.do_ismount(tmpdir)
     finally:
         shutil.rmtree(tmpdir)
 def test_do_ismount_path_does_not_exist(self):
     tmpdir = mkdtemp()
     try:
         assert False == fs.do_ismount(os.path.join(tmpdir, 'bar'))
     finally:
         shutil.rmtree(tmpdir)
 def test_do_ismount_path_is_root(self):
     assert True == fs.do_ismount('/')