Exemple #1
0
 def testTranslateDeferredError(self):
     """If the decorated function returns a Deferred, the error should still
     be translated."""
     def f():
         return defer.fail(ivfs.VFSError('error message'))
     f = sftp.translateErrors(f)
     d = f()
     return self.assertFailure(d, SFTPError)
Exemple #2
0
    def testTranslateDeferredError(self):
        """If the decorated function returns a Deferred, the error should still
        be translated."""
        def f():
            return defer.fail(ivfs.VFSError('error message'))

        f = sftp.translateErrors(f)
        d = f()
        return self.assertFailure(d, SFTPError)
Exemple #3
0
 def testTranslateDeferredError2(self):
     """If the decorated function returns a Deferred that hasn't fired
     immediately, the error should still be translated."""
     d = defer.Deferred()
     def f():
         return d
     f = sftp.translateErrors(f)
     d2 = f()
     d.errback(ivfs.VFSError("foo"))
     return self.assertFailure(d2, SFTPError)
Exemple #4
0
 def assertTranslation(self, error, code):
     """Asserts that the translate_error decorator translates 'error' to an
     SFTPError with a code of 'code'."""
     message = 'test error message'
     def f():
         raise error(message)
     f = sftp.translateErrors(f)
     e = self.assertRaises(SFTPError, f)
     self.assertEqual(code, e.code)
     self.assertEqual(message, e.message)
Exemple #5
0
    def testTranslateDeferredError2(self):
        """If the decorated function returns a Deferred that hasn't fired
        immediately, the error should still be translated."""
        d = defer.Deferred()

        def f():
            return d

        f = sftp.translateErrors(f)
        d2 = f()
        d.errback(ivfs.VFSError("foo"))
        return self.assertFailure(d2, SFTPError)
Exemple #6
0
    def assertTranslation(self, error, code):
        """Asserts that the translate_error decorator translates 'error' to an
        SFTPError with a code of 'code'."""
        message = 'test error message'

        def f():
            raise error(message)

        f = sftp.translateErrors(f)
        e = self.assertRaises(SFTPError, f)
        self.assertEqual(code, e.code)
        self.assertEqual(message, e.message)