Add test_broken_symlink.
This commit is contained in:
parent
0737a24712
commit
067b47fceb
|
@ -12,7 +12,8 @@ from twisted.internet.defer import gatherResults, inlineCallbacks, returnValue
|
||||||
from .. import __version__
|
from .. import __version__
|
||||||
from .common import ServerBase, config
|
from .common import ServerBase, config
|
||||||
from ..cli import cmd_send, cmd_receive, welcome, cli
|
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.cmd_server import MyPlugin
|
||||||
from wormhole.server.cli import server
|
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.tell(), 0)
|
||||||
self.assertEqual(fd_to_send.read(), message)
|
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):
|
def test_missing_file(self):
|
||||||
self.cfg.what = filename = "missing"
|
self.cfg.what = filename = "missing"
|
||||||
send_dir = self.mktemp()
|
send_dir = self.mktemp()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user