~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_matchers.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-19 18:33:40 UTC
  • mfrom: (5972.3.25 get-ancestry-is-evil)
  • Revision ID: pqm@pqm.ubuntu.com-20110619183340-ds1rpql77nxrmo4n
(jelmer) Deprecate Repository.get_ancestry(). (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from testtools.matchers import *
20
20
 
21
 
from bzrlib.tests import TestCase
 
21
from bzrlib.tests import (
 
22
    TestCase,
 
23
    TestCaseWithTransport,
 
24
    )
22
25
from bzrlib.tests.matchers import *
23
26
 
24
27
 
62
65
        self.assertNotEqual(None, mismatch)
63
66
        self.assertThat(mismatch.describe(), Equals("I am da tree is locked"))
64
67
 
 
68
 
 
69
class TestMatchesAncestry(TestCaseWithTransport):
 
70
 
 
71
    def test__str__(self):
 
72
        matcher = MatchesAncestry("A repository", "arevid")
 
73
        self.assertEqual(
 
74
            "MatchesAncestry(repository='A repository', "
 
75
            "revision_id='arevid')",
 
76
            str(matcher))
 
77
 
 
78
    def test_match(self):
 
79
        b = self.make_branch_builder('.')
 
80
        b.start_series()
 
81
        revid1 = b.build_commit()
 
82
        revid2 = b.build_commit()
 
83
        b.finish_series()
 
84
        branch = b.get_branch()
 
85
        m = MatchesAncestry(branch.repository, revid2)
 
86
        self.assertThat([revid2, revid1], m)
 
87
        self.assertThat([revid1, revid2], m)
 
88
        m = MatchesAncestry(branch.repository, revid1)
 
89
        self.assertThat([revid1], m)
 
90
        m = MatchesAncestry(branch.repository, "unknown")
 
91
        self.assertThat(["unknown"], m)
 
92
 
 
93
    def test_mismatch(self):
 
94
        b = self.make_branch_builder('.')
 
95
        b.start_series()
 
96
        revid1 = b.build_commit()
 
97
        revid2 = b.build_commit()
 
98
        b.finish_series()
 
99
        branch = b.get_branch()
 
100
        m = MatchesAncestry(branch.repository, revid1)
 
101
        mismatch = m.match([])
 
102
        self.assertIsNot(None, mismatch)
 
103
        self.assertEquals(
 
104
            "mismatched ancestry for revision '%s' was ['%s'], expected []" % (
 
105
                revid1, revid1),
 
106
            mismatch.describe())