~ubuntu-branches/debian/sid/bzr-svn/sid

« back to all changes in this revision

Viewing changes to tests/test_errors.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2009-03-10 14:38:42 UTC
  • mfrom: (1.2.1 upstream) (3.1.4 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090310143842-ucp9fxog1yi3la8f
Tags: 0.5.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
 
1
# Copyright (C) 2007-2009 Jelmer Vernooij <jelmer@samba.org>
2
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 3 of the License, or
 
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
7
 
8
8
# This program is distributed in the hope that it will be useful,
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
16
16
 
17
 
from bzrlib.errors import (ConnectionError, ConnectionReset, LockError, 
18
 
                           PermissionDenied, TransportError,
19
 
                           UnexpectedEndOfContainerError)
 
17
import subvertpy
 
18
 
 
19
from bzrlib.errors import (
 
20
    ConnectionError,
 
21
    ConnectionReset,
 
22
    LockError,
 
23
    PermissionDenied,
 
24
    TransportError,
 
25
    UnexpectedEndOfContainerError,
 
26
    )
20
27
from bzrlib.tests import TestCase
21
28
 
22
 
from bzrlib.plugins.svn.errors import (convert_svn_error, convert_error, InvalidPropertyValue, 
23
 
                    NotSvnBranchPath, InvalidSvnBranchPath,
24
 
                    SVN_ERR_UNKNOWN_HOSTNAME)
25
 
 
26
 
import svn.core
27
 
from svn.core import SubversionException
 
29
from bzrlib.plugins.svn.errors import (
 
30
    convert_error, 
 
31
    convert_svn_error, 
 
32
    DavRequestFailed, 
 
33
    InvalidPropertyValue,
 
34
    NotSvnBranchPath,
 
35
    )
28
36
 
29
37
class TestConvertError(TestCase):
 
38
 
30
39
    def test_decorator_unknown(self):
31
40
        @convert_svn_error
32
41
        def test_throws_svn():
33
 
            raise SubversionException("foo", 2000)
 
42
            raise subvertpy.SubversionException("foo", 2000)
34
43
 
35
 
        self.assertRaises(SubversionException, test_throws_svn)
 
44
        self.assertRaises(subvertpy.SubversionException, test_throws_svn)
36
45
 
37
46
    def test_decorator_known(self):
38
47
        @convert_svn_error
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)
41
50
 
42
51
        self.assertRaises(ConnectionReset, test_throws_svn)
43
52
 
44
 
    def test_convert_error_oserror(self):
45
 
        self.assertIsInstance(convert_error(SubversionException("foo", 13)),
46
 
                OSError)
47
 
 
48
53
    def test_convert_error_unknown(self):
49
 
        self.assertIsInstance(convert_error(SubversionException("foo", -4)),
50
 
                SubversionException)
 
54
        self.assertIsInstance(convert_error(subvertpy.SubversionException("foo", -4)),
 
55
                subvertpy.SubversionException)
 
56
 
 
57
    def test_convert_dav_request_failed(self):
 
58
        self.assertIsInstance(convert_error(subvertpy.SubversionException("foo", subvertpy.ERR_RA_DAV_REQUEST_FAILED)), DavRequestFailed)
51
59
 
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)
54
62
 
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)
57
65
 
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)
60
68
 
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)
63
71
 
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)
66
74
 
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)
69
77
 
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)
72
80
 
73
81
    def test_decorator_nothrow(self):
74
82
        @convert_svn_error
86
94
    def test_notsvnbranchpath_nonascii(self):
87
95
        NotSvnBranchPath('\xc3\xb6', None)
88
96
 
89
 
    def test_invalidsvnbranchpath_nonascii(self):
90
 
        InvalidSvnBranchPath('\xc3\xb6', None)
91
97