~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_errors.py

  • Committer: v.ladeuil+lp at free
  • Date: 2006-10-13 10:50:33 UTC
  • mfrom: (2077 +trunk)
  • mto: (2145.1.1 keepalive)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: v.ladeuil+lp@free.fr-20061013105033-7e091ff8dcc0ed0c
Merge bzr.dev. Including http modifications by "smart" related code

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
class TestErrors(TestCaseWithTransport):
28
28
 
 
29
    def test_medium_not_connected(self):
 
30
        error = errors.MediumNotConnected("a medium")
 
31
        self.assertEqualDiff(
 
32
            "The medium 'a medium' is not connected.", str(error))
 
33
        
29
34
    def test_no_repo(self):
30
35
        dir = bzrdir.BzrDir.create(self.get_url())
31
36
        error = errors.NoRepositoryPresent(dir)
32
37
        self.assertNotEqual(-1, str(error).find((dir.transport.clone('..').base)))
33
38
        self.assertEqual(-1, str(error).find((dir.transport.base)))
34
39
        
 
40
    def test_no_smart_medium(self):
 
41
        error = errors.NoSmartMedium("a transport")
 
42
        self.assertEqualDiff("The transport 'a transport' cannot tunnel the "
 
43
            "smart protocol.",
 
44
            str(error))
 
45
 
35
46
    def test_no_such_id(self):
36
47
        error = errors.NoSuchId("atree", "anid")
37
48
        self.assertEqualDiff("The file id anid is not present in the tree "
38
49
            "atree.",
39
50
            str(error))
40
51
 
 
52
    def test_too_many_concurrent_requests(self):
 
53
        error = errors.TooManyConcurrentRequests("a medium")
 
54
        self.assertEqualDiff("The medium 'a medium' has reached its concurrent "
 
55
            "request limit. Be sure to finish_writing and finish_reading on "
 
56
            "the current request that is open.",
 
57
            str(error))
 
58
 
41
59
    def test_up_to_date(self):
42
60
        error = errors.UpToDateFormat(bzrdir.BzrDirFormat4())
43
61
        self.assertEqualDiff("The branch format Bazaar-NG branch, "
53
71
                             repo.bzrdir.root_transport.base,
54
72
                             str(error))
55
73
 
 
74
    def test_reading_completed(self):
 
75
        error = errors.ReadingCompleted("a request")
 
76
        self.assertEqualDiff("The MediumRequest 'a request' has already had "
 
77
            "finish_reading called upon it - the request has been completed and"
 
78
            " no more data may be read.",
 
79
            str(error))
 
80
 
 
81
    def test_writing_completed(self):
 
82
        error = errors.WritingCompleted("a request")
 
83
        self.assertEqualDiff("The MediumRequest 'a request' has already had "
 
84
            "finish_writing called upon it - accept bytes may not be called "
 
85
            "anymore.",
 
86
            str(error))
 
87
 
 
88
    def test_writing_not_completed(self):
 
89
        error = errors.WritingNotComplete("a request")
 
90
        self.assertEqualDiff("The MediumRequest 'a request' has not has "
 
91
            "finish_writing called upon it - until the write phase is complete"
 
92
            " no data may be read.",
 
93
            str(error))
 
94
 
56
95
 
57
96
class PassThroughError(errors.BzrNewError):
58
97
    """Pass through %(foo)s and %(bar)s"""