def test_create_symlinks(self, os): source, target = self.setup_symlink(os) source_directory = os.path.dirname(source) assert os.path.exists(source) assert not os.path.exists(target) self.config.overwrite = True core.create_symlinks(self.config, source_directory, self.home) self.verify_symlink(os, source, target)
def test_create_symlinks_with_single_directory_includes(self, os): include = self.setup_file(self.dotfiles_directory, '.foo') target = os.path.join(self.home, '.foo') self.config.includes = [include] core.create_symlinks(self.config, self.dotfiles_directory, self.home) assert os.path.exists(target) assert os.path.islink(target) assert os.readlink(target) == include
def test_create_symlinks_with_no_overwrite(self, os): source, target = self.setup_symlink(os) source_directory = os.path.dirname(source) self.setup_file(target) self.config.overwrite = False core.create_symlinks(self.config, source_directory, self.home) assert os.path.exists(source) assert os.path.exists(target) assert not os.path.islink(target)
def test_create_symlinks_with_multiple_sources(self, os): source_files = ['.bash_profile', '.gitignore', '.gvimrc', '.vimrc'] source_directories = ['bin', '.git', '.vim'] self.config.excludes = ['.git', '.gitignore'] self.config.overwrite = True for item in source_files: self.setup_file(self.dotfiles_directory, item) self.setup_file(self.home, item) for item in source_directories: self.setup_directory(self.dotfiles_directory, item) self.setup_file(self.home, item) core.create_symlinks(self.config, self.dotfiles_directory, self.home) for item in source_files: if item in self.config.excludes: assert not os.path.islink(os.path.join(self.home, item)) else: source = os.path.join(self.dotfiles_directory, item) target = os.path.join(self.home, item) self.verify_symlink(os, source, target)
def test_create_with_bad_includes(self, os): self.config.includes = ['', 'non-existing', os.sep] core.create_symlinks(self.config, self.dotfiles_directory, self.home) assert not os.path.exists(os.path.join(self.dotfiles_directory, 'non-existing'))
def test_create_symlinks_with_no_source_directory(self, os): self.setup_directory(self.home) source_directory = os.path.join(self.home, 'non-existant-directory') core.create_symlinks(self.config, source_directory, self.home) for item in os.listdir(self.home): assert not os.path.islink(item)
def test_create_symlinks_with_same_source_and_target(self, os): core.create_symlinks(self.config, self.home, self.home) for item in os.listdir(self.home): assert not os.path.islink(os.path.join(self.home, item))
def test_create_with_bad_includes(self, os): self.config.includes = ['', 'non-existing', os.sep] core.create_symlinks(self.config, self.dotfiles_directory, self.home) assert not os.path.exists( os.path.join(self.dotfiles_directory, 'non-existing'))