~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-08-17 21:39:37 UTC
  • mfrom: (6072.2.5 match-tree-layout)
  • Revision ID: pqm@pqm.ubuntu.com-20110817213937-lzul6u2qz1svvgxm
(jelmer) Add a HasLayout matcher. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
            "mismatched ancestry for revision '%s' was ['%s'], expected []" % (
105
105
                revid1, revid1),
106
106
            mismatch.describe())
 
107
 
 
108
 
 
109
class TestHasLayout(TestCaseWithTransport):
 
110
 
 
111
    def test__str__(self):
 
112
        matcher = HasLayout([("a", "a-id")])
 
113
        self.assertEqual("HasLayout([('a', 'a-id')])", str(matcher))
 
114
 
 
115
    def test_match(self):
 
116
        t = self.make_branch_and_tree('.')
 
117
        self.build_tree(['a', 'b/', 'b/c'])
 
118
        t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
 
119
        self.assertThat(t, HasLayout(['', 'a', 'b', 'b/c']))
 
120
        self.assertThat(t, HasLayout(
 
121
            [('', t.get_root_id()),
 
122
             ('a', 'a-id'),
 
123
             ('b', 'b-id'),
 
124
             ('b/c', 'c-id')]))
 
125
 
 
126
    def test_mismatch(self):
 
127
        t = self.make_branch_and_tree('.')
 
128
        self.build_tree(['a', 'b/', 'b/c'])
 
129
        t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
 
130
        mismatch = HasLayout(['a']).match(t)
 
131
        self.assertIsNot(None, mismatch)
 
132
        self.assertEquals(
 
133
            "[u'', u'a', u'b', u'b/c'] != ['a']",
 
134
            mismatch.describe())