diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-19 21:32:34 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-19 21:32:34 +0200 |
commit | 985093bae160419782b3d3cb9151e2e58625fd52 (patch) | |
tree | 2f19b97289d9d0af2eeea894dcc1f51e627261cf /test/git/test_remote.py | |
parent | 8f42db54c6b2cfbd7d68e6d34ac2ed70578402f7 (diff) | |
parent | 53d26977f1aff8289f13c02ee672349d78eeb2f0 (diff) | |
download | gitpython-985093bae160419782b3d3cb9151e2e58625fd52.tar.gz |
Merge branch 'remotes' into improvements
* remotes:
remote: added tests for creation and removal, finishing the remote interface
remote: base tests succeed now
config: fixed serious issues that would cause it to see initial tabs as continuation lines - this leads to very incorrect results when parsing git config files. Now the complete reading is overridden to make it work as there was no other way
Added configuration access including tests to remote
Added remote module and test cases - about to implement remote option handling
added initial frame for remote handling- remotes are somewhat related to either parsing the command output or to reading the repo configuration which would be faster
Diffstat (limited to 'test/git/test_remote.py')
-rw-r--r-- | test/git/test_remote.py | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/test/git/test_remote.py b/test/git/test_remote.py new file mode 100644 index 00000000..2446710f --- /dev/null +++ b/test/git/test_remote.py @@ -0,0 +1,89 @@ +# test_remote.py +# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors +# +# This module is part of GitPython and is released under +# the BSD License: http://www.opensource.org/licenses/bsd-license.php + +from test.testlib import * +from git import * + +class TestRemote(TestCase): + + @classmethod + def setUpAll(cls): + cls.repo = Repo(GIT_REPO) + + def test_base(self): + num_remotes = 0 + remote_set = set() + for remote in self.repo.remotes: + num_remotes += 1 + assert remote == remote + assert str(remote) != repr(remote) + remote_set.add(remote) + remote_set.add(remote) # should already exist + + # REFS + refs = remote.refs + assert refs + for ref in refs: + assert ref.remote_name == remote.name + assert ref.remote_branch + # END for each ref + + # OPTIONS + for opt in ("url", "fetch"): + val = getattr(remote, opt) + reader = remote.config_reader + assert reader.get(opt) == val + + # unable to write with a reader + self.failUnlessRaises(IOError, reader.set, opt, "test") + + # change value + writer = remote.config_writer + new_val = "myval" + writer.set(opt, new_val) + assert writer.get(opt) == new_val + writer.set(opt, val) + assert writer.get(opt) == val + del(writer) + assert getattr(remote, opt) == val + # END for each default option key + + # RENAME + other_name = "totally_other_name" + prev_name = remote.name + assert remote.rename(other_name) == remote + assert prev_name != remote.name + # multiple times + for time in range(2): + assert remote.rename(prev_name).name == prev_name + # END for each rename ( back to prev_name ) + + remote.update() + + # END for each remote + assert num_remotes + assert num_remotes == len(remote_set) + + + def test_creation_and_removal(self): + new_name = "test_new_one" + arg_list = (new_name, "git@server:hello.git") + remote = Remote.create(self.repo, *arg_list ) + assert remote.name == "test_new_one" + + # create same one again + self.failUnlessRaises(GitCommandError, Remote.create, self.repo, *arg_list) + + Remote.remove(self.repo, new_name) + + for remote in self.repo.remotes: + if remote.name == new_name: + raise AssertionError("Remote removal failed") + # END if deleted remote matches existing remote's name + # END for each remote + + + |