14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
from bzrlib.errors import (ConnectionError, ConnectionReset, LockError,
18
PermissionDenied, TransportError,
19
UnexpectedEndOfContainerError)
19
from bzrlib.errors import (
25
UnexpectedEndOfContainerError,
20
27
from bzrlib.tests import TestCase
22
from bzrlib.plugins.svn.errors import (convert_svn_error, convert_error, InvalidPropertyValue,
23
NotSvnBranchPath, InvalidSvnBranchPath,
24
SVN_ERR_UNKNOWN_HOSTNAME)
27
from svn.core import SubversionException
29
from bzrlib.plugins.svn.errors import (
29
37
class TestConvertError(TestCase):
30
39
def test_decorator_unknown(self):
32
41
def test_throws_svn():
33
raise SubversionException("foo", 2000)
42
raise subvertpy.SubversionException("foo", 2000)
35
self.assertRaises(SubversionException, test_throws_svn)
44
self.assertRaises(subvertpy.SubversionException, test_throws_svn)
37
46
def test_decorator_known(self):
39
48
def test_throws_svn():
40
raise SubversionException("Connection closed", svn.core.SVN_ERR_RA_SVN_CONNECTION_CLOSED)
49
raise subvertpy.SubversionException("Connection closed", subvertpy.ERR_RA_SVN_CONNECTION_CLOSED)
42
51
self.assertRaises(ConnectionReset, test_throws_svn)
44
def test_convert_error_oserror(self):
45
self.assertIsInstance(convert_error(SubversionException("foo", 13)),
48
53
def test_convert_error_unknown(self):
49
self.assertIsInstance(convert_error(SubversionException("foo", -4)),
54
self.assertIsInstance(convert_error(subvertpy.SubversionException("foo", -4)),
55
subvertpy.SubversionException)
57
def test_convert_dav_request_failed(self):
58
self.assertIsInstance(convert_error(subvertpy.SubversionException("foo", subvertpy.ERR_RA_DAV_REQUEST_FAILED)), DavRequestFailed)
52
60
def test_convert_malformed(self):
53
self.assertIsInstance(convert_error(SubversionException("foo", svn.core.SVN_ERR_RA_SVN_MALFORMED_DATA)), TransportError)
61
self.assertIsInstance(convert_error(subvertpy.SubversionException("foo", subvertpy.ERR_RA_SVN_MALFORMED_DATA)), TransportError)
55
63
def test_convert_error_reset(self):
56
self.assertIsInstance(convert_error(SubversionException("Connection closed", svn.core.SVN_ERR_RA_SVN_CONNECTION_CLOSED)), ConnectionReset)
64
self.assertIsInstance(convert_error(subvertpy.SubversionException("Connection closed", subvertpy.ERR_RA_SVN_CONNECTION_CLOSED)), ConnectionReset)
58
66
def test_convert_error_lock(self):
59
self.assertIsInstance(convert_error(SubversionException("Working copy locked", svn.core.SVN_ERR_WC_LOCKED)), LockError)
67
self.assertIsInstance(convert_error(subvertpy.SubversionException("Working copy locked", subvertpy.ERR_WC_LOCKED)), LockError)
61
69
def test_convert_perm_denied(self):
62
self.assertIsInstance(convert_error(SubversionException("Permission Denied", svn.core.SVN_ERR_RA_NOT_AUTHORIZED)), PermissionDenied)
70
self.assertIsInstance(convert_error(subvertpy.SubversionException("Permission Denied", subvertpy.ERR_RA_NOT_AUTHORIZED)), PermissionDenied)
64
72
def test_convert_unexpected_end(self):
65
self.assertIsInstance(convert_error(SubversionException("Unexpected end of stream", svn.core.SVN_ERR_INCOMPLETE_DATA)), UnexpectedEndOfContainerError)
73
self.assertIsInstance(convert_error(subvertpy.SubversionException("Unexpected end of stream", subvertpy.ERR_INCOMPLETE_DATA)), UnexpectedEndOfContainerError)
67
75
def test_convert_unknown_hostname(self):
68
self.assertIsInstance(convert_error(SubversionException("Unknown hostname 'bla'", SVN_ERR_UNKNOWN_HOSTNAME)), ConnectionError)
76
self.assertIsInstance(convert_error(subvertpy.SubversionException("Unknown hostname 'bla'", subvertpy.ERR_UNKNOWN_HOSTNAME)), ConnectionError)
70
78
def test_not_implemented(self):
71
self.assertIsInstance(convert_error(SubversionException("Remote server doesn't support ...", svn.core.SVN_ERR_RA_NOT_IMPLEMENTED)), NotImplementedError)
79
self.assertIsInstance(convert_error(subvertpy.SubversionException("Remote server doesn't support ...", subvertpy.ERR_RA_NOT_IMPLEMENTED)), NotImplementedError)
73
81
def test_decorator_nothrow(self):