~ubuntu-branches/ubuntu/gutsy/bzr/gutsy

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

  • Committer: Bazaar Package Importer
  • Author(s): Etienne Goyer
  • Date: 2007-04-27 17:53:49 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20070427175349-rvowqx994rfuikuu
Tags: 0.16~rc1-0ubuntu1
New upstream development release 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
 
3
#            and others
3
4
#
4
5
# This program is free software; you can redistribute it and/or modify
5
6
# it under the terms of the GNU General Public License as published by
30
31
 
31
32
class TestErrors(TestCaseWithTransport):
32
33
 
 
34
    def test_disabled_method(self):
 
35
        error = errors.DisabledMethod("class name")
 
36
        self.assertEqualDiff(
 
37
            "The smart server method 'class name' is disabled.", str(error))
 
38
 
33
39
    def test_duplicate_file_id(self):
34
40
        error = errors.DuplicateFileId('a_file_id', 'foo')
35
41
        self.assertEqualDiff('File id {a_file_id} already exists in inventory'
36
42
                             ' as foo', str(error))
37
43
 
 
44
    def test_duplicate_help_prefix(self):
 
45
        error = errors.DuplicateHelpPrefix('foo')
 
46
        self.assertEqualDiff('The prefix foo is in the help search path twice.',
 
47
            str(error))
 
48
 
38
49
    def test_inventory_modified(self):
39
50
        error = errors.InventoryModified("a tree to be repred")
40
51
        self.assertEqualDiff("The current inventory for the tree 'a tree to "
86
97
            "smart protocol.",
87
98
            str(error))
88
99
 
 
100
    def test_no_help_topic(self):
 
101
        error = errors.NoHelpTopic("topic")
 
102
        self.assertEqualDiff("No help could be found for 'topic'. "
 
103
            "Please use 'bzr help topics' to obtain a list of topics.",
 
104
            str(error))
 
105
 
89
106
    def test_no_such_id(self):
90
107
        error = errors.NoSuchId("atree", "anid")
91
108
        self.assertEqualDiff("The file id anid is not present in the tree "
114
131
        error = errors.TooManyConcurrentRequests("a medium")
115
132
        self.assertEqualDiff("The medium 'a medium' has reached its concurrent "
116
133
            "request limit. Be sure to finish_writing and finish_reading on "
117
 
            "the current request that is open.",
 
134
            "the currently open request.",
118
135
            str(error))
119
136
 
120
137
    def test_unknown_hook(self):
228
245
            host='ahost', port=444, msg='Unable to connect to ssh host',
229
246
            orig_error='my_error')
230
247
 
 
248
    def test_malformed_bug_identifier(self):
 
249
        """Test the formatting of MalformedBugIdentifier."""
 
250
        error = errors.MalformedBugIdentifier('bogus', 'reason for bogosity')
 
251
        self.assertEqual(
 
252
            "Did not understand bug identifier bogus: reason for bogosity",
 
253
            str(error))
 
254
 
 
255
    def test_unknown_bug_tracker_abbreviation(self):
 
256
        """Test the formatting of UnknownBugTrackerAbbreviation."""
 
257
        branch = self.make_branch('some_branch')
 
258
        error = errors.UnknownBugTrackerAbbreviation('xxx', branch)
 
259
        self.assertEqual(
 
260
            "Cannot find registered bug tracker called xxx on %s" % branch,
 
261
            str(error))
 
262
 
 
263
    def test_unexpected_smart_server_response(self):
 
264
        e = errors.UnexpectedSmartServerResponse(('not yes',))
 
265
        self.assertEqual(
 
266
            "Could not understand response from smart server: ('not yes',)",
 
267
            str(e))
231
268
 
232
269
 
233
270
class PassThroughError(errors.BzrError):