示例#1
0
    def test_can_determine_path_existence(self):
        """fab.tests.os.path_info_test  Can determine path existence"""

        self.mock_host_controller.path_exists("/some/path").AndReturn(True)
        self.mox.ReplayAll()

        path = PathInfo("/some/path", self.mock_host_controller)

        self.assertTrue(path.exists(), "Expected path to exist")
示例#2
0
    def test_can_recognise_mac_osx_symlink_path_type(self):
        """fab.tests.os.path_info_test  Can recognise a Mac OS X symbolic link path type"""

        self._set_expected_path_type_for(SystemType.MAC_OSX, "/some/path/to/symlink", "Symbolic Link")
        self.mox.ReplayAll()

        path = PathInfo("/some/path/to/symlink", self.mock_host_controller)

        self.assertTrue(path.is_symlink(), "Expected a Mac OS X symbolic link path to be recognised")
示例#3
0
    def test_can_recognise_mac_osx_file_path_type(self):
        """fab.tests.os.path_info_test  Can recognise a Mac OS X file path type"""

        self._set_expected_path_type_for(SystemType.MAC_OSX, "/some/path/to/file.txt", "Regular File")
        self.mox.ReplayAll()

        path = PathInfo("/some/path/to/file.txt", self.mock_host_controller)

        self.assertTrue(path.is_file(), "Expected a Mac OS X file path to be recognised")
示例#4
0
    def test_can_recognise_mac_osx_directory_path_type(self):
        """fab.tests.os.path_info_test  Can recognise a Mac OS X directory path type"""

        self._set_expected_path_type_for(SystemType.MAC_OSX, "/some/directory/path", "Directory")
        self.mox.ReplayAll()

        path = PathInfo("/some/directory/path", self.mock_host_controller)

        self.assertTrue(path.is_directory(), "Expected a Mac OS X directory path to be recognised")
示例#5
0
    def test_can_determine_path_existence(self):
        """fab.tests.os.path_info_test  Can determine path existence"""

        self.mock_host_controller.path_exists("/some/path").AndReturn(True)
        self.mox.ReplayAll()

        path = PathInfo("/some/path", self.mock_host_controller)

        self.assertTrue(path.exists(), "Expected path to exist")
示例#6
0
    def test_can_recognise_mac_osx_directory_path_type(self):
        """fab.tests.os.path_info_test  Can recognise a Mac OS X directory path type"""

        self._set_expected_path_type_for(SystemType.MAC_OSX,
                                         "/some/directory/path", "Directory")
        self.mox.ReplayAll()

        path = PathInfo("/some/directory/path", self.mock_host_controller)

        self.assertTrue(path.is_directory(),
                        "Expected a Mac OS X directory path to be recognised")
示例#7
0
    def test_can_recognise_mac_osx_file_path_type(self):
        """fab.tests.os.path_info_test  Can recognise a Mac OS X file path type"""

        self._set_expected_path_type_for(SystemType.MAC_OSX,
                                         "/some/path/to/file.txt",
                                         "Regular File")
        self.mox.ReplayAll()

        path = PathInfo("/some/path/to/file.txt", self.mock_host_controller)

        self.assertTrue(path.is_file(),
                        "Expected a Mac OS X file path to be recognised")
示例#8
0
    def test_can_recognise_mac_osx_symlink_path_type(self):
        """fab.tests.os.path_info_test  Can recognise a Mac OS X symbolic link path type"""

        self._set_expected_path_type_for(SystemType.MAC_OSX,
                                         "/some/path/to/symlink",
                                         "Symbolic Link")
        self.mox.ReplayAll()

        path = PathInfo("/some/path/to/symlink", self.mock_host_controller)

        self.assertTrue(
            path.is_symlink(),
            "Expected a Mac OS X symbolic link path to be recognised")
示例#9
0
    def ensure_symlink_exists(self, symlink_path, real_path, with_sudo=False):
        path = PathInfo(symlink_path, self.host_controller)

        if path.exists() and not path.is_symlink():
            self.feedback.abort("Found existing path but path is not a symlink: %s" % symlink_path)
        elif not PathInfo(real_path, self.host_controller).exists():
            self.feedback.abort("Cannot create symlink to nonexistent path: %s" % real_path)
        else:
            symlink = SymlinkInfo(symlink_path, self.host_controller)

            if symlink.exists() and symlink.is_linked_to(real_path):
                self.feedback.comment("Found expected symlink: %s" % symlink)
            elif symlink.exists():
                self.remove_symlink(symlink_path)
                self.create_symlink(symlink_path, real_path, with_sudo)
            else:
                self.create_symlink(symlink_path, real_path, with_sudo)
示例#10
0
    def ensure_symlink_exists(self, symlink_path, real_path, with_sudo=False):
        path = PathInfo(symlink_path, self.host_controller)

        if path.exists() and not path.is_symlink():
            self.feedback.abort(
                "Found existing path but path is not a symlink: %s" %
                symlink_path)
        elif not PathInfo(real_path, self.host_controller).exists():
            self.feedback.abort(
                "Cannot create symlink to nonexistent path: %s" % real_path)
        else:
            symlink = SymlinkInfo(symlink_path, self.host_controller)

            if symlink.exists() and symlink.is_linked_to(real_path):
                self.feedback.comment("Found expected symlink: %s" % symlink)
            elif symlink.exists():
                self.remove_symlink(symlink_path)
                self.create_symlink(symlink_path, real_path, with_sudo)
            else:
                self.create_symlink(symlink_path, real_path, with_sudo)