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

  • Committer: Ian Clatworthy
  • Date: 2009-02-17 23:41:29 UTC
  • mto: (0.64.114 trunk)
  • mto: This revision was merged to the branch mainline in revision 6631.
  • Revision ID: ian.clatworthy@canonical.com-20090217234129-yywcvloggdkqr4tb
symlink copying tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
232
232
            expected_added=[('b',), (dest_path,)])
233
233
        self.assertContent(branch, revtree2, dest_path, "aaa")
234
234
 
 
235
    def symlink_command_iter(self, src_path, dest_path):
 
236
        def command_list():
 
237
            author = ['', 'bugs@a.com', time.time(), time.timezone]
 
238
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
 
239
            def files_one():
 
240
                yield commands.FileModifyCommand(src_path, 'symlink', False,
 
241
                        None, "aaa")
 
242
            yield commands.CommitCommand('head', '1', author,
 
243
                committer, "commit 1", None, [], files_one)
 
244
            def files_two():
 
245
                yield commands.FileCopyCommand(src_path, dest_path)
 
246
            yield commands.CommitCommand('head', '2', author,
 
247
                committer, "commit 2", ":1", [], files_two)
 
248
        return command_list
 
249
 
 
250
    def assertSymlinkTarget(self, branch, tree, path, target):
 
251
        file_id = tree.inventory.path2id(path)
 
252
        branch.lock_read()
 
253
        self.addCleanup(branch.unlock)
 
254
        self.assertEqual(tree.get_symlink_target(file_id), target)
 
255
 
 
256
    def test_copy_symlink_in_root(self):
 
257
        handler, branch = self.get_handler()
 
258
        src_path = 'a'
 
259
        dest_path = 'b'
 
260
        handler.process(self.symlink_command_iter(src_path, dest_path))
 
261
        revtree1, revtree2 = self.assertChanges(branch, 1,
 
262
            expected_added=[(dest_path,)])
 
263
        self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
 
264
        self.assertEqual(revtree1.get_revision_id(),
 
265
                         revtree1.inventory.root.children['a'].revision)
 
266
        self.assertEqual(revtree2.get_revision_id(),
 
267
                         revtree2.inventory.root.children['b'].revision)
 
268
 
 
269
    def test_copy_symlink_in_subdir(self):
 
270
        handler, branch = self.get_handler()
 
271
        src_path = 'a/a'
 
272
        dest_path = 'a/b'
 
273
        handler.process(self.symlink_command_iter(src_path, dest_path))
 
274
        revtree1, revtree2 = self.assertChanges(branch, 1,
 
275
            expected_added=[(dest_path,)])
 
276
        self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
 
277
 
 
278
    def test_copy_symlink_to_new_dir(self):
 
279
        handler, branch = self.get_handler()
 
280
        src_path = 'a/a'
 
281
        dest_path = 'b/a'
 
282
        handler.process(self.symlink_command_iter(src_path, dest_path))
 
283
        revtree1, revtree2 = self.assertChanges(branch, 1,
 
284
            expected_added=[('b',), (dest_path,)])
 
285
        self.assertSymlinkTarget(branch, revtree2, dest_path, "aaa")
 
286
 
235
287
 
236
288
class TestFileKinds(TestCaseForGenericProcessor):
237
289