~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_inventory_delta.py

  • Committer: Andrew Bennetts
  • Date: 2009-08-10 08:10:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4608.
  • Revision ID: andrew.bennetts@canonical.com-20090810081006-hsl2hvsh4awse3kl
Replace require_flags method with allow_versioned_root and allow_tree_references flags on InventoryDeltaSerializer.__init__, and shift some checking of delta compatibility from StreamSink to InventoryDeltaSerializer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
 
137
137
    def test_parse_versioned_root_only(self):
138
138
        deserializer = inventory_delta.InventoryDeltaDeserializer()
139
 
        deserializer.require_flags(versioned_root=True, tree_references=True)
140
139
        parse_result = deserializer.parse_text_bytes(root_only_lines)
141
140
        expected_entry = inventory.make_entry(
142
141
            'directory', u'', None, 'an-id')
148
147
 
149
148
    def test_parse_special_revid_not_valid_last_mod(self):
150
149
        deserializer = inventory_delta.InventoryDeltaDeserializer()
151
 
        deserializer.require_flags(versioned_root=False, tree_references=True)
152
150
        root_only_lines = """format: bzr inventory delta v1 (bzr 1.14)
153
151
parent: null:
154
152
version: null:
162
160
 
163
161
    def test_parse_versioned_root_versioned_disabled(self):
164
162
        deserializer = inventory_delta.InventoryDeltaDeserializer()
165
 
        deserializer.require_flags(versioned_root=False, tree_references=True)
166
163
        root_only_lines = """format: bzr inventory delta v1 (bzr 1.14)
167
164
parent: null:
168
165
version: null:
176
173
 
177
174
    def test_parse_unique_root_id_root_versioned_disabled(self):
178
175
        deserializer = inventory_delta.InventoryDeltaDeserializer()
179
 
        deserializer.require_flags(versioned_root=False, tree_references=True)
180
176
        root_only_lines = """format: bzr inventory delta v1 (bzr 1.14)
181
177
parent: parent-id
182
178
version: a@e\xc3\xa5ample.com--2004
190
186
 
191
187
    def test_parse_unversioned_root_versioning_enabled(self):
192
188
        deserializer = inventory_delta.InventoryDeltaDeserializer()
193
 
        deserializer.require_flags(versioned_root=True, tree_references=True)
194
 
        err = self.assertRaises(errors.BzrError,
195
 
            deserializer.parse_text_bytes, root_only_unversioned)
196
 
        self.assertContainsRe(
197
 
            str(err), 'serialized versioned_root flag is wrong: False')
 
189
        parse_result = deserializer.parse_text_bytes(root_only_unversioned)
 
190
        expected_entry = inventory.make_entry(
 
191
            'directory', u'', None, 'TREE_ROOT')
 
192
        expected_entry.revision = 'entry-version'
 
193
        self.assertEqual(
 
194
            ('null:', 'entry-version', False, False,
 
195
             [(None, u'', 'TREE_ROOT', expected_entry)]),
 
196
            parse_result)
 
197
 
 
198
    def test_parse_versioned_root_when_disabled(self):
 
199
        deserializer = inventory_delta.InventoryDeltaDeserializer(
 
200
            allow_versioned_root=False)
 
201
        err = self.assertRaises(inventory_delta._IncompatibleDelta,
 
202
            deserializer.parse_text_bytes, root_only_lines)
 
203
        self.assertEquals("versioned_root not allowed", str(err))
198
204
 
199
205
    def test_parse_tree_when_disabled(self):
200
 
        deserializer = inventory_delta.InventoryDeltaDeserializer()
201
 
        deserializer.require_flags(versioned_root=True, tree_references=False)
202
 
        err = self.assertRaises(errors.BzrError,
 
206
        deserializer = inventory_delta.InventoryDeltaDeserializer(
 
207
            allow_tree_references=False)
 
208
        err = self.assertRaises(inventory_delta._IncompatibleDelta,
203
209
            deserializer.parse_text_bytes, reference_lines)
204
 
        self.assertContainsRe(
205
 
            str(err), 'serialized tree_references flag is wrong: True')
 
210
        self.assertEquals("Tree reference not allowed", str(err))
206
211
 
207
212
    def test_parse_tree_when_header_disallows(self):
208
213
        # A deserializer that allows tree_references to be set or unset.