From 024adf37acddd6a5d8293b6b5d15795c59a142c0 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 30 May 2011 13:06:37 +0200 Subject: Fixed tests far enough to allow basic repository tests to be applied to any of the new database types. This reduces code duplication to the mere minimum, but allows custom tests to be added on top easily and flexibly --- git/test/db/cmd/__init__.py | 4 ++++ git/test/db/cmd/test_base.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 git/test/db/cmd/__init__.py create mode 100644 git/test/db/cmd/test_base.py (limited to 'git/test/db/cmd') diff --git a/git/test/db/cmd/__init__.py b/git/test/db/cmd/__init__.py new file mode 100644 index 00000000..8a681e42 --- /dev/null +++ b/git/test/db/cmd/__init__.py @@ -0,0 +1,4 @@ +# Copyright (C) 2010, 2011 Sebastian Thiel (byronimo@gmail.com) and contributors +# +# This module is part of GitDB and is released under +# the New BSD License: http://www.opensource.org/licenses/bsd-license.php diff --git a/git/test/db/cmd/test_base.py b/git/test/db/cmd/test_base.py new file mode 100644 index 00000000..1404eca0 --- /dev/null +++ b/git/test/db/cmd/test_base.py @@ -0,0 +1,13 @@ +# Copyright (C) 2010, 2011 Sebastian Thiel (byronimo@gmail.com) and contributors +# +# This module is part of GitDB and is released under +# the New BSD License: http://www.opensource.org/licenses/bsd-license.php +from git.test.lib import * +from git.db import RefSpec + +class TestBase(TestDBBase): + + @with_rw_directory + def test_basics(self, path): + assert False + -- cgit v1.2.3 From 1f71ed94578799ee1667ba54b66a369e307f415b Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 30 May 2011 16:32:56 +0200 Subject: git cmd implementation of repository appears to work, at least this is what the test suggests. Pure python implementation still has some trouble, but this should be very fixable --- git/test/db/cmd/test_base.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'git/test/db/cmd') diff --git a/git/test/db/cmd/test_base.py b/git/test/db/cmd/test_base.py index 1404eca0..8d00f57f 100644 --- a/git/test/db/cmd/test_base.py +++ b/git/test/db/cmd/test_base.py @@ -2,12 +2,17 @@ # # This module is part of GitDB and is released under # the New BSD License: http://www.opensource.org/licenses/bsd-license.php -from git.test.lib import * -from git.db import RefSpec - -class TestBase(TestDBBase): - - @with_rw_directory - def test_basics(self, path): - assert False - +from git.test.lib import rorepo_dir +from git.test.db.base import RepoBase + +# immport test +from git.db.cmd.base import * +from git.db.cmd.complex import * + +from git.db.complex import CmdCompatibilityGitDB + +class TestBase(RepoBase): + RepoCls = CmdCompatibilityGitDB + + def test_basics(self): + pass -- cgit v1.2.3 From 6f960586feccff8c1f2c717765eb0a5e8b9cd6f3 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 30 May 2011 21:14:22 +0200 Subject: Fixed remaining tests as good as possible. remote/fetch/pull and submodule tests need some more work. Also, the tests need to be reorganized and move closer to their actual location within gitpython. Hence the refs tests go to git.test.refs, etc --- git/test/db/cmd/test_base.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'git/test/db/cmd') diff --git a/git/test/db/cmd/test_base.py b/git/test/db/cmd/test_base.py index 8d00f57f..59a6a55e 100644 --- a/git/test/db/cmd/test_base.py +++ b/git/test/db/cmd/test_base.py @@ -5,9 +5,8 @@ from git.test.lib import rorepo_dir from git.test.db.base import RepoBase -# immport test -from git.db.cmd.base import * -from git.db.cmd.complex import * +from git.util import bin_to_hex +from git.exc import BadObject from git.db.complex import CmdCompatibilityGitDB @@ -15,4 +14,14 @@ class TestBase(RepoBase): RepoCls = CmdCompatibilityGitDB def test_basics(self): - pass + gdb = self.rorepo + + # partial to complete - works with everything + hexsha = bin_to_hex(gdb.partial_to_complete_sha_hex("0.1.6")) + assert len(hexsha) == 40 + + assert bin_to_hex(gdb.partial_to_complete_sha_hex(hexsha[:20])) == hexsha + + # fails with BadObject + for invalid_rev in ("0000", "bad/ref", "super bad"): + self.failUnlessRaises(BadObject, gdb.partial_to_complete_sha_hex, invalid_rev) -- cgit v1.2.3 From 9bf3fdec93fe427bb5f0bd39c986a4e977969f41 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 7 Jun 2011 13:38:48 +0200 Subject: First run in order to fix the remote handling. Cleaned up interfaces and figured out that the implementation really should be specific to the git command. This leaves the interface open for other implemntations which use a different way to provide feedback (as we do not make assumptions about the format of a feedback line) --- git/test/db/cmd/test_base.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'git/test/db/cmd') diff --git a/git/test/db/cmd/test_base.py b/git/test/db/cmd/test_base.py index 59a6a55e..959be16b 100644 --- a/git/test/db/cmd/test_base.py +++ b/git/test/db/cmd/test_base.py @@ -9,6 +9,7 @@ from git.util import bin_to_hex from git.exc import BadObject from git.db.complex import CmdCompatibilityGitDB +from git.db.cmd.base import * class TestBase(RepoBase): RepoCls = CmdCompatibilityGitDB @@ -25,3 +26,7 @@ class TestBase(RepoBase): # fails with BadObject for invalid_rev in ("0000", "bad/ref", "super bad"): 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", '') -- cgit v1.2.3