diff options
Diffstat (limited to 'git/test')
-rw-r--r-- | git/test/db/cmd/test_base.py | 63 | ||||
-rw-r--r-- | git/test/refs/test_refs.py | 5 | ||||
-rw-r--r-- | git/test/test_remote.py | 4 |
3 files changed, 68 insertions, 4 deletions
diff --git a/git/test/db/cmd/test_base.py b/git/test/db/cmd/test_base.py index 959be16b..cbb4a339 100644 --- a/git/test/db/cmd/test_base.py +++ b/git/test/db/cmd/test_base.py @@ -11,6 +11,8 @@ from git.exc import BadObject from git.db.complex import CmdCompatibilityGitDB from git.db.cmd.base import * +from git.refs import TagReference, Reference, RemoteReference + class TestBase(RepoBase): RepoCls = CmdCompatibilityGitDB @@ -28,5 +30,62 @@ class TestBase(RepoBase): self.failUnlessRaises(BadObject, gdb.partial_to_complete_sha_hex, invalid_rev) def test_fetch_info(self): - self.failUnlessRaises(ValueError, CmdFetchInfo._from_line, self.rorepo, "nonsense", '') - self.failUnlessRaises(ValueError, CmdFetchInfo._from_line, self.rorepo, "? [up to date] 0.1.7RC -> origin/0.1.7RC", '') + self.failUnlessRaises(ValueError, CmdCmdFetchInfo._from_line, self.rorepo, "nonsense", '') + self.failUnlessRaises(ValueError, CmdCmdFetchInfo._from_line, self.rorepo, "? [up to date] 0.1.7RC -> origin/0.1.7RC", '') + + + def test_fetch_info(self): + # assure we can handle remote-tracking branches + fetch_info_line_fmt = "c437ee5deb8d00cf02f03720693e4c802e99f390 not-for-merge %s '0.3' of git://github.com/gitpython-developers/GitPython" + remote_info_line_fmt = "* [new branch] nomatter -> %s" + fi = CmdFetchInfo._from_line(self.rorepo, + remote_info_line_fmt % "local/master", + fetch_info_line_fmt % 'remote-tracking branch') + + # we wouldn't be here if it wouldn't have worked + + # handles non-default refspecs: One can specify a different path in refs/remotes + # or a special path just in refs/something for instance + + fi = CmdFetchInfo._from_line(self.rorepo, + remote_info_line_fmt % "subdir/tagname", + fetch_info_line_fmt % 'tag') + + assert isinstance(fi.ref, TagReference) + assert fi.ref.path.startswith('refs/tags') + + # it could be in a remote direcftory though + fi = CmdFetchInfo._from_line(self.rorepo, + remote_info_line_fmt % "remotename/tags/tagname", + fetch_info_line_fmt % 'tag') + + assert isinstance(fi.ref, TagReference) + assert fi.ref.path.startswith('refs/remotes/') + + # it can also be anywhere ! + tag_path = "refs/something/remotename/tags/tagname" + fi = CmdFetchInfo._from_line(self.rorepo, + remote_info_line_fmt % tag_path, + fetch_info_line_fmt % 'tag') + + assert isinstance(fi.ref, TagReference) + assert fi.ref.path == tag_path + + # branches default to refs/remotes + fi = CmdFetchInfo._from_line(self.rorepo, + remote_info_line_fmt % "remotename/branch", + fetch_info_line_fmt % 'branch') + + assert isinstance(fi.ref, RemoteReference) + assert fi.ref.remote_name == 'remotename' + + # but you can force it anywhere, in which case we only have a references + fi = CmdFetchInfo._from_line(self.rorepo, + remote_info_line_fmt % "refs/something/branch", + fetch_info_line_fmt % 'branch') + + assert type(fi.ref) is Reference + assert fi.ref.path == "refs/something/branch" + + + diff --git a/git/test/refs/test_refs.py b/git/test/refs/test_refs.py index 668dd94c..81be173c 100644 --- a/git/test/refs/test_refs.py +++ b/git/test/refs/test_refs.py @@ -29,6 +29,11 @@ class TestRefs(TestBase): assert isinstance(instance, ref_type) # END for each name # END for each type + + # invalid path + self.failUnlessRaises(ValueError, TagReference, self.rorepo, "refs/invalid/tag") + # works without path check + TagReference(self.rorepo, "refs/invalid/tag", check_path=False) def test_tag_base(self): tag_object_refs = list() diff --git a/git/test/test_remote.py b/git/test/test_remote.py index 8ae9fe43..cef8687b 100644 --- a/git/test/test_remote.py +++ b/git/test/test_remote.py @@ -256,7 +256,7 @@ class TestRemote(TestBase): shutil.rmtree(other_repo_dir) # END test and cleanup - def _test_push_and_pull(self,remote, rw_repo, remote_repo): + def _verify_push_and_pull(self,remote, rw_repo, remote_repo): # push our changes lhead = rw_repo.head lindex = rw_repo.index @@ -407,7 +407,7 @@ class TestRemote(TestBase): # END for each rename ( back to prev_name ) # PUSH/PULL TESTING - self._test_push_and_pull(remote, rw_repo, remote_repo) + self._verify_push_and_pull(remote, rw_repo, remote_repo) # FETCH TESTING # Only for remotes - local cases are the same or less complicated |