From f96ee7463e2454e95bf0d77ca4fe5107d3f24d68 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 19 Feb 2010 16:52:38 +0100 Subject: index: added move method including test test.helpers: temporary rw repository creators now set the working dir of the program, easing working with relative paths a lot --- test/git/test_index.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'test/git/test_index.py') diff --git a/test/git/test_index.py b/test/git/test_index.py index a2689f99..7d3f13cd 100644 --- a/test/git/test_index.py +++ b/test/git/test_index.py @@ -14,10 +14,10 @@ import glob import shutil from stat import * -class TestTree(TestBase): +class TestIndex(TestBase): def __init__(self, *args): - super(TestTree, self).__init__(*args) + super(TestIndex, self).__init__(*args) self._reset_progress() def _assert_fprogress(self, entries): @@ -498,3 +498,32 @@ class TestTree(TestBase): open(fake_symlink_path,'rb').read() == link_target else: assert S_ISLNK(os.lstat(fake_symlink_path)[ST_MODE]) + + # TEST RENAMING + def assert_mv_rval(rval): + for source, dest in rval: + assert not os.path.exists(source) and os.path.exists(dest) + # END for each renamed item + # END move assertion utility + + self.failUnlessRaises(ValueError, index.move, ['just_one_path']) + # file onto existing file + files = ['AUTHORS', 'LICENSE'] + self.failUnlessRaises(GitCommandError, index.move, files) + + # again, with force + assert_mv_rval(index.move(files, force=True)) + + # files into directory - dry run + paths = ['LICENSE', 'VERSION', 'doc'] + rval = index.move(paths, dry_run=True) + assert len(rval) == 2 + assert os.path.exists(paths[0]) + + # again, no dry run + rval = index.move(paths) + assert_mv_rval(rval) + + # dir into dir + rval = index.move(['doc', 'test']) + assert_mv_rval(rval) -- cgit v1.2.1