diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-02-19 16:52:38 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-02-19 17:54:30 +0100 |
commit | f96ee7463e2454e95bf0d77ca4fe5107d3f24d68 (patch) | |
tree | 49f0deaa7221f5a259a0943b26b65dd2c2316f85 /test/git/test_index.py | |
parent | 76fd1d4119246e2958c571d1f64c5beb88a70bd4 (diff) | |
download | gitpython-f96ee7463e2454e95bf0d77ca4fe5107d3f24d68.tar.gz |
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
Diffstat (limited to 'test/git/test_index.py')
-rw-r--r-- | test/git/test_index.py | 33 |
1 files changed, 31 insertions, 2 deletions
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) |