/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 breezy/tests/test_matchers.py

  • Committer: Jelmer Vernooij
  • Date: 2018-04-02 00:52:27 UTC
  • mfrom: (6939 work)
  • mto: This revision was merged to the branch mainline in revision 7274.
  • Revision ID: jelmer@jelmer.uk-20180402005227-pecflp1mvdjrjqd6
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
    def test_match(self):
119
119
        t = self.make_branch_and_tree('.')
120
120
        self.build_tree(['a', 'b/', 'b/c'])
121
 
        t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
 
121
        t.add(['a', 'b', 'b/c'], [b'a-id', b'b-id', b'c-id'])
122
122
        self.assertThat(t, HasLayout(['', 'a', 'b/', 'b/c']))
123
123
        self.assertThat(t, HasLayout(
124
124
            [('', t.get_root_id()),
125
 
             ('a', 'a-id'),
126
 
             ('b/', 'b-id'),
127
 
             ('b/c', 'c-id')]))
 
125
             ('a', b'a-id'),
 
126
             ('b/', b'b-id'),
 
127
             ('b/c', b'c-id')]))
128
128
 
129
129
    def test_mismatch(self):
130
130
        t = self.make_branch_and_tree('.')
131
131
        self.build_tree(['a', 'b/', 'b/c'])
132
 
        t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
 
132
        t.add(['a', 'b', 'b/c'], [b'a-id', b'b-id', b'c-id'])
133
133
        mismatch = HasLayout(['a']).match(t)
134
134
        self.assertIsNot(None, mismatch)
135
135
        self.assertEqual(
141
141
        t = self.make_branch_and_tree('.')
142
142
        t.has_versioned_directories = lambda: False
143
143
        self.build_tree(['a', 'b/', 'b/c'])
144
 
        t.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
 
144
        t.add(['a', 'b', 'b/c'], [b'a-id', b'b-id', b'c-id'])
145
145
        self.assertIs(None, HasLayout(['', 'a', 'b/', 'b/c']).match(t))
146
146
        self.assertIs(None, HasLayout(['', 'a', 'b/', 'b/c', 'd/']).match(t))
147
147
        mismatch = HasLayout([u'', u'a', u'd/']).match(t)
151
151
            set(mismatch.describe().split(" != ")))
152
152
 
153
153
 
 
154
class TestHasPathRelations(TestCaseWithTransport):
 
155
 
 
156
    def test__str__(self):
 
157
        t = self.make_branch_and_tree('.')
 
158
        matcher = HasPathRelations(t, [("a", "b")])
 
159
        self.assertEqual("HasPathRelations(%r, [('a', 'b')])" % t, str(matcher))
 
160
 
 
161
    def test_match(self):
 
162
        t = self.make_branch_and_tree('.')
 
163
        self.build_tree(['a', 'b/', 'b/c'])
 
164
        t.add(['a', 'b', 'b/c'])
 
165
        self.assertThat(t, HasPathRelations(t,
 
166
            [('', ''),
 
167
             ('a', 'a'),
 
168
             ('b/', 'b/'),
 
169
             ('b/c', 'b/c')]))
 
170
 
 
171
    def test_mismatch(self):
 
172
        t = self.make_branch_and_tree('.')
 
173
        self.build_tree(['a', 'b/', 'b/c'])
 
174
        t.add(['a', 'b', 'b/c'])
 
175
        mismatch = HasPathRelations(t, [('a', 'a')]).match(t)
 
176
        self.assertIsNot(None, mismatch)
 
177
 
 
178
 
154
179
class TestContainsNoVfsCalls(TestCase):
155
180
 
156
181
    def _make_call(self, method, args):
189
214
 
190
215
    def test_matches(self):
191
216
        tree = self.make_branch_and_tree('.')
192
 
        tree.commit('msg1', rev_id='a')
193
 
        tree.commit('msg2', rev_id='b')
 
217
        tree.commit('msg1', rev_id=b'a')
 
218
        tree.commit('msg2', rev_id=b'b')
194
219
        matcher = RevisionHistoryMatches(['a', 'b'])
195
220
        self.assertIs(None, matcher.match(tree.branch))
196
221
 
197
222
    def test_mismatch(self):
198
223
        tree = self.make_branch_and_tree('.')
199
 
        tree.commit('msg1', rev_id='a')
200
 
        tree.commit('msg2', rev_id='b')
 
224
        tree.commit('msg1', rev_id=b'a')
 
225
        tree.commit('msg2', rev_id=b'b')
201
226
        matcher = RevisionHistoryMatches(['a', 'b', 'c'])
202
227
        self.assertEqual(
203
228
            set(("['a', 'b']", "['a', 'b', 'c']")),