/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
class TestErrors(TestCaseWithTransport):
32
32
 
 
33
    def test_disabled_method(self):
 
34
        error = errors.DisabledMethod("class name")
 
35
        self.assertEqualDiff(
 
36
            "The smart server method 'class name' is disabled.", str(error))
 
37
 
 
38
    def test_duplicate_file_id(self):
 
39
        error = errors.DuplicateFileId('a_file_id', 'foo')
 
40
        self.assertEqualDiff('File id {a_file_id} already exists in inventory'
 
41
                             ' as foo', str(error))
 
42
 
 
43
    def test_duplicate_help_prefix(self):
 
44
        error = errors.DuplicateHelpPrefix('foo')
 
45
        self.assertEqualDiff('The prefix foo is in the help search path twice.',
 
46
            str(error))
 
47
 
33
48
    def test_inventory_modified(self):
34
49
        error = errors.InventoryModified("a tree to be repred")
35
50
        self.assertEqualDiff("The current inventory for the tree 'a tree to "
46
61
        error = errors.InstallFailed([None])
47
62
        self.assertEqual("Could not install revisions:\nNone", str(error))
48
63
 
 
64
    def test_lock_active(self):
 
65
        error = errors.LockActive("lock description")
 
66
        self.assertEqualDiff("The lock for 'lock description' is in use and "
 
67
            "cannot be broken.",
 
68
            str(error))
 
69
 
49
70
    def test_knit_header_error(self):
50
71
        error = errors.KnitHeaderError('line foo\n', 'path/to/file')
51
72
        self.assertEqual("Knit header error: 'line foo\\n' unexpected"
52
73
                         " for file path/to/file", str(error))
53
74
 
 
75
    def test_knit_index_unknown_method(self):
 
76
        error = errors.KnitIndexUnknownMethod('http://host/foo.kndx',
 
77
                                              ['bad', 'no-eol'])
 
78
        self.assertEqual("Knit index http://host/foo.kndx does not have a"
 
79
                         " known method in options: ['bad', 'no-eol']",
 
80
                         str(error))
 
81
 
54
82
    def test_medium_not_connected(self):
55
83
        error = errors.MediumNotConnected("a medium")
56
84
        self.assertEqualDiff(
68
96
            "smart protocol.",
69
97
            str(error))
70
98
 
 
99
    def test_no_help_topic(self):
 
100
        error = errors.NoHelpTopic("topic")
 
101
        self.assertEqualDiff("No help could be found for 'topic'. "
 
102
            "Please use 'bzr help topics' to obtain a list of topics.",
 
103
            str(error))
 
104
 
71
105
    def test_no_such_id(self):
72
106
        error = errors.NoSuchId("atree", "anid")
73
107
        self.assertEqualDiff("The file id anid is not present in the tree "
74
108
            "atree.",
75
109
            str(error))
76
110
 
 
111
    def test_no_such_revision_in_tree(self):
 
112
        error = errors.NoSuchRevisionInTree("atree", "anid")
 
113
        self.assertEqualDiff("The revision id anid is not present in the tree "
 
114
            "atree.",
 
115
            str(error))
 
116
        self.assertIsInstance(error, errors.NoSuchRevision)
 
117
 
77
118
    def test_not_write_locked(self):
78
119
        error = errors.NotWriteLocked('a thing to repr')
79
120
        self.assertEqualDiff("'a thing to repr' is not write locked but needs "
80
121
            "to be.",
81
122
            str(error))
82
123
 
 
124
    def test_read_only_lock_error(self):
 
125
        error = errors.ReadOnlyLockError('filename', 'error message')
 
126
        self.assertEqualDiff("Cannot acquire write lock on filename."
 
127
                             " error message", str(error))
 
128
 
83
129
    def test_too_many_concurrent_requests(self):
84
130
        error = errors.TooManyConcurrentRequests("a medium")
85
131
        self.assertEqualDiff("The medium 'a medium' has reached its concurrent "
86
132
            "request limit. Be sure to finish_writing and finish_reading on "
87
 
            "the current request that is open.",
 
133
            "the currently open request.",
 
134
            str(error))
 
135
 
 
136
    def test_unknown_hook(self):
 
137
        error = errors.UnknownHook("branch", "foo")
 
138
        self.assertEqualDiff("The branch hook 'foo' is unknown in this version"
 
139
            " of bzrlib.",
 
140
            str(error))
 
141
        error = errors.UnknownHook("tree", "bar")
 
142
        self.assertEqualDiff("The tree hook 'bar' is unknown in this version"
 
143
            " of bzrlib.",
88
144
            str(error))
89
145
 
90
146
    def test_up_to_date(self):
188
244
            host='ahost', port=444, msg='Unable to connect to ssh host',
189
245
            orig_error='my_error')
190
246
 
 
247
    def test_malformed_bug_identifier(self):
 
248
        """Test the formatting of MalformedBugIdentifier."""
 
249
        error = errors.MalformedBugIdentifier('bogus', 'reason for bogosity')
 
250
        self.assertEqual(
 
251
            "Did not understand bug identifier bogus: reason for bogosity",
 
252
            str(error))
 
253
 
 
254
    def test_unknown_bug_tracker_abbreviation(self):
 
255
        """Test the formatting of UnknownBugTrackerAbbreviation."""
 
256
        branch = self.make_branch('some_branch')
 
257
        error = errors.UnknownBugTrackerAbbreviation('xxx', branch)
 
258
        self.assertEqual(
 
259
            "Cannot find registered bug tracker called xxx on %s" % branch,
 
260
            str(error))
 
261
 
 
262
    def test_unexpected_smart_server_response(self):
 
263
        e = errors.UnexpectedSmartServerResponse(('not yes',))
 
264
        self.assertEqual(
 
265
            "Could not understand response from smart server: ('not yes',)",
 
266
            str(e))
191
267
 
192
268
 
193
269
class PassThroughError(errors.BzrError):