def test_symlink(self): args = self.Args({}) upgrade = self.PartialMockUnixInstall(args, None) self.mox.StubOutWithMock(os, 'symlink') os.symlink('new', 'sym') self.mox.ReplayAll() upgrade.symlink('new', 'sym') self.mox.VerifyAll()
def test_directories(self, deleteold, keepoldzip): args = self.Args({'delete_old': deleteold, 'keep_old_zip': keepoldzip}) upgrade = self.PartialMockUnixInstall(args, None) upgrade.dir = 'new' self.mox.StubOutWithMock(os.path, 'samefile') self.mox.StubOutWithMock(os, 'readlink') self.mox.StubOutWithMock(shutil, 'rmtree') self.mox.StubOutWithMock(os, 'unlink') self.mox.StubOutWithMock(upgrade, 'symlink') os.path.samefile('new', 'sym').AndReturn(False) os.readlink('sym').AndReturn('old/') if deleteold: shutil.rmtree('old') if not keepoldzip: os.unlink('old.zip') os.unlink('sym') upgrade.symlink('new', 'sym') self.mox.ReplayAll() upgrade.directories() self.mox.VerifyAll()
def test_directories(self, skipdelete, skipdeletezip): args = self.Args({'skipdelete': str(skipdelete), 'skipdeletezip': str(skipdeletezip)}) upgrade = self.PartialMockUnixInstall(args, None) upgrade.dir = 'new' self.mox.StubOutWithMock(os.path, 'samefile') self.mox.StubOutWithMock(os, 'readlink') self.mox.StubOutWithMock(shutil, 'rmtree') self.mox.StubOutWithMock(os, 'unlink') self.mox.StubOutWithMock(upgrade, 'symlink') os.path.samefile('new', 'sym').AndReturn(False) os.readlink('sym').AndReturn('old/') if not skipdelete: shutil.rmtree('old') if not skipdeletezip: os.unlink('old.zip') os.unlink('sym') upgrade.symlink('new', 'sym') self.mox.ReplayAll() upgrade.directories() self.mox.VerifyAll()