diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-23 15:22:07 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-23 15:22:07 +0200 |
commit | ddc5496506f0484e4f1331261aa8782c7e606bf2 (patch) | |
tree | 91c805398899b2671ac887149b0193a74e7a8628 /test/git/test_refs.py | |
parent | 2c23ca3cd9b9bbeaca1b79068dee1eae045be5b6 (diff) | |
download | gitpython-ddc5496506f0484e4f1331261aa8782c7e606bf2.tar.gz |
Implemented head methods: create, delete, rename, including tests
Diffstat (limited to 'test/git/test_refs.py')
-rw-r--r-- | test/git/test_refs.py | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/test/git/test_refs.py b/test/git/test_refs.py index 2665d93b..ac213384 100644 --- a/test/git/test_refs.py +++ b/test/git/test_refs.py @@ -109,10 +109,39 @@ class TestRefs(TestBase): # type check self.failUnlessRaises(ValueError, setattr, cur_head, "reference", "that") + # head handling + commit = 'HEAD' + prev_head_commit = cur_head.commit + for count, new_name in enumerate(("my_new_head", "feature/feature1")): + actual_commit = commit+"^"*count + new_head = Head.create(rw_repo, new_name, actual_commit) + assert cur_head.commit == prev_head_commit + assert isinstance(new_head, Head) + # already exists + self.failUnlessRaises(GitCommandError, Head.create, rw_repo, new_name) + + # force it + new_head = Head.create(rw_repo, new_name, actual_commit, force=True) + old_path = new_head.path + old_name = new_head.name + + assert new_head.rename("hello").name == "hello" + assert new_head.rename("hello/world").name == "hello/world" + assert new_head.rename(old_name).name == old_name and new_head.path == old_path + + # rename with force + tmp_head = Head.create(rw_repo, "tmphead") + self.failUnlessRaises(GitCommandError, tmp_head.rename, new_head) + tmp_head.rename(new_head, force=True) + assert tmp_head == new_head and tmp_head.object == new_head.object + + Head.delete(rw_repo, tmp_head) + heads = rw_repo.heads + assert tmp_head not in heads and new_head not in heads + # force on deletion testing would be missing here, code looks okay though ;) + # END for each new head name + self.failUnlessRaises(TypeError, RemoteReference.create, rw_repo, "some_name") - self.fail("head creation") - self.fail("head renaming") - self.fail("head removal") self.fail("tag creation") self.fail("tag deletion") self.fail("remote deletion") |