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/py/test_git.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 git/test/db/py/test_git.py (limited to 'git/test/db/py/test_git.py') diff --git a/git/test/db/py/test_git.py b/git/test/db/py/test_git.py new file mode 100644 index 00000000..46a2d24f --- /dev/null +++ b/git/test/db/py/test_git.py @@ -0,0 +1,47 @@ +# 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 lib import * +from git.exc import BadObject +from git.db.py import PureGitODB +from git.base import OStream, OInfo +from git.util import hex_to_bin, bin_to_hex + +class TestGitDB(TestDBBase): + + def test_reading(self): + gdb = PureGitODB(fixture_path('../../../.git/objects')) + + # we have packs and loose objects, alternates doesn't necessarily exist + assert 1 < len(gdb.databases()) < 4 + + # access should be possible + git_sha = hex_to_bin("5690fd0d3304f378754b23b098bd7cb5f4aa1976") + assert isinstance(gdb.info(git_sha), OInfo) + assert isinstance(gdb.stream(git_sha), OStream) + assert gdb.size() > 200 + sha_list = list(gdb.sha_iter()) + assert len(sha_list) == gdb.size() + + + # This is actually a test for compound functionality, but it doesn't + # have a separate test module + # test partial shas + # this one as uneven and quite short + assert gdb.partial_to_complete_sha_hex('155b6') == hex_to_bin("155b62a9af0aa7677078331e111d0f7aa6eb4afc") + + # mix even/uneven hexshas + for i, binsha in enumerate(sha_list): + assert gdb.partial_to_complete_sha_hex(bin_to_hex(binsha)[:8-(i%2)]) == binsha + # END for each sha + + self.failUnlessRaises(BadObject, gdb.partial_to_complete_sha_hex, "0000") + + @with_rw_directory + def test_writing(self, path): + gdb = PureGitODB(path) + + # its possible to write objects + self._assert_object_writing(gdb) + self._assert_object_writing_async(gdb) -- cgit v1.2.3 From 09a11c78950ce8e6376ab7a34cdaec77555c6679 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 30 May 2011 17:55:04 +0200 Subject: Fixed test_git.py --- git/test/db/py/test_git.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'git/test/db/py/test_git.py') diff --git a/git/test/db/py/test_git.py b/git/test/db/py/test_git.py index 46a2d24f..524d4080 100644 --- a/git/test/db/py/test_git.py +++ b/git/test/db/py/test_git.py @@ -2,22 +2,26 @@ # # This module is part of GitDB and is released under # the New BSD License: http://www.opensource.org/licenses/bsd-license.php -from lib import * +from git.test.lib import rorepo_dir +from git.test.db.lib import * from git.exc import BadObject -from git.db.py import PureGitODB +from git.db.py.complex import PureGitODB from git.base import OStream, OInfo from git.util import hex_to_bin, bin_to_hex - + +import os + class TestGitDB(TestDBBase): + RepoCls = PureGitODB def test_reading(self): - gdb = PureGitODB(fixture_path('../../../.git/objects')) + gdb = self.RepoCls(os.path.join(rorepo_dir(), 'objects')) # we have packs and loose objects, alternates doesn't necessarily exist assert 1 < len(gdb.databases()) < 4 # access should be possible - git_sha = hex_to_bin("5690fd0d3304f378754b23b098bd7cb5f4aa1976") + git_sha = hex_to_bin("5aebcd5cb3340fb31776941d7e4d518a712a8655") assert isinstance(gdb.info(git_sha), OInfo) assert isinstance(gdb.stream(git_sha), OStream) assert gdb.size() > 200 @@ -29,10 +33,10 @@ class TestGitDB(TestDBBase): # have a separate test module # test partial shas # this one as uneven and quite short - assert gdb.partial_to_complete_sha_hex('155b6') == hex_to_bin("155b62a9af0aa7677078331e111d0f7aa6eb4afc") + assert gdb.partial_to_complete_sha_hex('5aebcd') == hex_to_bin("5aebcd5cb3340fb31776941d7e4d518a712a8655") # mix even/uneven hexshas - for i, binsha in enumerate(sha_list): + for i, binsha in enumerate(sha_list[:50]): assert gdb.partial_to_complete_sha_hex(bin_to_hex(binsha)[:8-(i%2)]) == binsha # END for each sha @@ -40,7 +44,7 @@ class TestGitDB(TestDBBase): @with_rw_directory def test_writing(self, path): - gdb = PureGitODB(path) + gdb = self.RepoCls(path) # its possible to write objects self._assert_object_writing(gdb) -- cgit v1.2.3 From c192638aae09c1b5c087d67cc99dd4c7ec4ed916 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 30 May 2011 18:19:44 +0200 Subject: Fixed all remaining python repository tests --- git/test/db/py/test_git.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'git/test/db/py/test_git.py') diff --git a/git/test/db/py/test_git.py b/git/test/db/py/test_git.py index 524d4080..ecaa5c8f 100644 --- a/git/test/db/py/test_git.py +++ b/git/test/db/py/test_git.py @@ -3,7 +3,7 @@ # 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 rorepo_dir -from git.test.db.lib import * +from git.test.db.lib import TestDBBase, with_rw_directory from git.exc import BadObject from git.db.py.complex import PureGitODB from git.base import OStream, OInfo @@ -12,10 +12,10 @@ from git.util import hex_to_bin, bin_to_hex import os class TestGitDB(TestDBBase): - RepoCls = PureGitODB + needs_ro_repo = False def test_reading(self): - gdb = self.RepoCls(os.path.join(rorepo_dir(), 'objects')) + gdb = PureGitODB(os.path.join(rorepo_dir(), 'objects')) # we have packs and loose objects, alternates doesn't necessarily exist assert 1 < len(gdb.databases()) < 4 @@ -44,7 +44,7 @@ class TestGitDB(TestDBBase): @with_rw_directory def test_writing(self, path): - gdb = self.RepoCls(path) + gdb = PureGitODB(path) # its possible to write objects self._assert_object_writing(gdb) -- cgit v1.2.3