Add test_broken_symlink.

This commit is contained in:
Atul Varma 2017-05-23 21:01:40 -04:00 committed by Brian Warner
parent 0737a24712
commit 067b47fceb

View File

@ -12,7 +12,8 @@ from twisted.internet.defer import gatherResults, inlineCallbacks, returnValue
from .. import __version__
from .common import ServerBase, config
from ..cli import cmd_send, cmd_receive, welcome, cli
from ..errors import TransferError, WrongPasswordError, WelcomeError
from ..errors import (TransferError, WrongPasswordError, WelcomeError,
UnsendableFileError)
from wormhole.server.cmd_server import MyPlugin
from wormhole.server.cli import server
@ -65,6 +66,24 @@ class OfferData(unittest.TestCase):
self.assertEqual(fd_to_send.tell(), 0)
self.assertEqual(fd_to_send.read(), message)
def test_broken_symlink(self):
if not hasattr(os, 'symlink'):
raise unittest.SkipTest("host OS does not support symlinks")
parent_dir = self.mktemp()
os.mkdir(parent_dir)
send_dir = "dirname"
os.mkdir(os.path.join(parent_dir, send_dir))
os.symlink('/non/existent/file',
os.path.join(parent_dir, send_dir, 'linky'))
send_dir_arg = send_dir
self.cfg.what = send_dir_arg
self.cfg.cwd = parent_dir
e = self.assertRaises(UnsendableFileError, build_offer, self.cfg)
self.assertEqual(str(e), "linky: No such file or directory")
def test_missing_file(self):
self.cfg.what = filename = "missing"
send_dir = self.mktemp()