diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-22 16:06:10 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-22 16:06:51 +0200 |
commit | 3c770f8e98a0079497d3eb5bc31e7260cc70cc63 (patch) | |
tree | 9ccea0ef524e5a0fc928be6b89e3a7071471111d /test | |
parent | 9c3bbc43d097656b54c808290ce0c656d127ce47 (diff) | |
download | gitpython-3c770f8e98a0079497d3eb5bc31e7260cc70cc63.tar.gz |
Fixed decorator issue that would cause a function to be passed even though there is a default argument. This feels inconsistent as the 'argument passer' wrapper function can be called with a function or a string as first argument depending on whether the client code was explicitly passing an argument or not. That ... sucks. Now test for that case specifically and fail with a proper assertion error. I don't like it, but what can I do ... .
Remote tests adjusted to use rw repositories instead. More tests to follow, and many api methods are to be implemented now these things can be tested properly.
Diffstat (limited to 'test')
-rw-r--r-- | test/git/test_base.py | 7 | ||||
-rw-r--r-- | test/git/test_remote.py | 27 | ||||
-rw-r--r-- | test/testlib/helper.py | 6 |
3 files changed, 22 insertions, 18 deletions
diff --git a/test/git/test_base.py b/test/git/test_base.py index c2e199b3..a7ef9374 100644 --- a/test/git/test_base.py +++ b/test/git/test_base.py @@ -108,12 +108,15 @@ class TestBase(TestBase): @with_bare_rw_repo def test_with_bare_rw_repo(self, bare_rw_repo): assert bare_rw_repo.config_reader("repository").getboolean("core", "bare") + assert os.path.isfile(os.path.join(bare_rw_repo.path,'HEAD')) - @with_rw_repo(working_tree_ref='0.1.6') + @with_rw_repo('0.1.6') def test_with_rw_repo(self, rw_repo): assert not rw_repo.config_reader("repository").getboolean("core", "bare") + assert os.path.isdir(os.path.join(rw_repo.git.git_dir,'lib')) - @with_rw_and_rw_remote_repo + @with_rw_and_rw_remote_repo('0.1.6') def test_with_rw_remote_and_rw_repo(self, rw_repo, rw_remote_repo): assert not rw_repo.config_reader("repository").getboolean("core", "bare") assert rw_remote_repo.config_reader("repository").getboolean("core", "bare") + assert os.path.isdir(os.path.join(rw_repo.git.git_dir,'lib')) diff --git a/test/git/test_remote.py b/test/git/test_remote.py index aeb6b4af..ef00056d 100644 --- a/test/git/test_remote.py +++ b/test/git/test_remote.py @@ -7,16 +7,13 @@ from test.testlib import * from git import * -class TestRemote(TestCase): +class TestRemote(TestBase): - @classmethod - def setUpAll(cls): - cls.repo = Repo(GIT_REPO) - - def test_base(self): + @with_rw_and_rw_remote_repo('0.1.6') + def test_base(self, rw_repo, remote_repo): num_remotes = 0 remote_set = set() - for remote in self.repo.remotes: + for remote in rw_repo.remotes: num_remotes += 1 assert remote == remote assert str(remote) != repr(remote) @@ -64,27 +61,29 @@ class TestRemote(TestCase): remote.fetch() self.failUnlessRaises(GitCommandError, remote.pull) + remote.pull('master') remote.update() self.fail("test push once there is a test-repo") # END for each remote assert num_remotes assert num_remotes == len(remote_set) - origin = self.repo.remote('origin') - assert origin == self.repo.remotes.origin + origin = rw_repo.remote('origin') + assert origin == rw_repo.remotes.origin - def test_creation_and_removal(self): + @with_bare_rw_repo + def test_creation_and_removal(self, bare_rw_repo): new_name = "test_new_one" arg_list = (new_name, "git@server:hello.git") - remote = Remote.create(self.repo, *arg_list ) + remote = Remote.create(bare_rw_repo, *arg_list ) assert remote.name == "test_new_one" # create same one again - self.failUnlessRaises(GitCommandError, Remote.create, self.repo, *arg_list) + self.failUnlessRaises(GitCommandError, Remote.create, bare_rw_repo, *arg_list) - Remote.remove(self.repo, new_name) + Remote.remove(bare_rw_repo, new_name) - for remote in self.repo.remotes: + for remote in bare_rw_repo.remotes: if remote.name == new_name: raise AssertionError("Remote removal failed") # END if deleted remote matches existing remote's name diff --git a/test/testlib/helper.py b/test/testlib/helper.py index c4fccbf6..eef7876f 100644 --- a/test/testlib/helper.py +++ b/test/testlib/helper.py @@ -88,13 +88,14 @@ def with_bare_rw_repo(func): bare_repo_creator.__name__ = func.__name__ return bare_repo_creator -def with_rw_repo(working_tree_ref='0.1.6'): +def with_rw_repo(working_tree_ref): """ Same as with_bare_repo, but clones the rorepo as non-bare repository, checking out the working tree at the given working_tree_ref. This repository type is more costly due to the working copy checkout. """ + assert isinstance(working_tree_ref, basestring), "Decorator requires ref name for working tree checkout" def argument_passer(func): def repo_creator(self): repo_dir = tempfile.mktemp("non_bare_repo") @@ -111,7 +112,7 @@ def with_rw_repo(working_tree_ref='0.1.6'): # END argument passer return argument_passer -def with_rw_and_rw_remote_repo(working_tree_ref='0.1.6'): +def with_rw_and_rw_remote_repo(working_tree_ref): """ Same as with_rw_repo, but also provides a writable remote repository from which the rw_repo has been forked. The remote repository was cloned as bare repository from @@ -125,6 +126,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref='0.1.6'): This setup allows you to test push and pull scenarios and hooks nicely. """ + assert isinstance(working_tree_ref, basestring), "Decorator requires ref name for working tree checkout" def argument_passer(func): def remote_repo_creator(self): remote_repo_dir = tempfile.mktemp("remote_repo") |