From 4177eefd7bdaea96a529b00ba9cf751924ede202 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 May 2011 19:43:22 +0200 Subject: Added all code from gitdb to gitpython. Next is to make it generally work. Then the tests will need some work --- git/test/test_base.py | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) (limited to 'git/test/test_base.py') diff --git a/git/test/test_base.py b/git/test/test_base.py index e630d151..408b9833 100644 --- a/git/test/test_base.py +++ b/git/test/test_base.py @@ -15,6 +15,22 @@ from git.objects.util import get_object_type_by_name from gitdb.util import hex_to_bin import tempfile +################## +from lib import ( + TestBase, + DummyStream, + DeriveTest, + ) + +from gitdb import * +from gitdb.util import ( + NULL_BIN_SHA + ) + +from gitdb.typ import ( + str_blob_type + ) + class TestBase(TestBase): type_tuples = ( ("blob", "8741fc1d09d61f02ffd8cded15ff603eff1ec070", "blob.py"), @@ -98,3 +114,85 @@ class TestBase(TestBase): 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.working_tree_dir,'lib')) + + + +class TestBaseTypes(TestBase): + + def test_streams(self): + # test info + sha = NULL_BIN_SHA + s = 20 + blob_id = 3 + + info = OInfo(sha, str_blob_type, s) + assert info.binsha == sha + assert info.type == str_blob_type + assert info.type_id == blob_id + assert info.size == s + + # test pack info + # provides type_id + pinfo = OPackInfo(0, blob_id, s) + assert pinfo.type == str_blob_type + assert pinfo.type_id == blob_id + assert pinfo.pack_offset == 0 + + dpinfo = ODeltaPackInfo(0, blob_id, s, sha) + assert dpinfo.type == str_blob_type + assert dpinfo.type_id == blob_id + assert dpinfo.delta_info == sha + assert dpinfo.pack_offset == 0 + + + # test ostream + stream = DummyStream() + ostream = OStream(*(info + (stream, ))) + assert ostream.stream is stream + ostream.read(15) + stream._assert() + assert stream.bytes == 15 + ostream.read(20) + assert stream.bytes == 20 + + # test packstream + postream = OPackStream(*(pinfo + (stream, ))) + assert postream.stream is stream + postream.read(10) + stream._assert() + assert stream.bytes == 10 + + # test deltapackstream + dpostream = ODeltaPackStream(*(dpinfo + (stream, ))) + dpostream.stream is stream + dpostream.read(5) + stream._assert() + assert stream.bytes == 5 + + # derive with own args + DeriveTest(sha, str_blob_type, s, stream, 'mine',myarg = 3)._assert() + + # test istream + istream = IStream(str_blob_type, s, stream) + assert istream.binsha == None + istream.binsha = sha + assert istream.binsha == sha + + assert len(istream.binsha) == 20 + assert len(istream.hexsha) == 40 + + assert istream.size == s + istream.size = s * 2 + istream.size == s * 2 + assert istream.type == str_blob_type + istream.type = "something" + assert istream.type == "something" + assert istream.stream is stream + istream.stream = None + assert istream.stream is None + + assert istream.error is None + istream.error = Exception() + assert isinstance(istream.error, Exception) + + -- cgit v1.2.3 From acf5e6ea64a2f24117f1d419c208ed1c38c43690 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 6 May 2011 15:03:14 +0200 Subject: replaced all gitdb strings with git --- git/test/test_base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'git/test/test_base.py') diff --git a/git/test/test_base.py b/git/test/test_base.py index 408b9833..29916066 100644 --- a/git/test/test_base.py +++ b/git/test/test_base.py @@ -12,7 +12,7 @@ from git.test.lib import * from git import * from itertools import chain from git.objects.util import get_object_type_by_name -from gitdb.util import hex_to_bin +from git.util import hex_to_bin import tempfile ################## @@ -22,12 +22,12 @@ from lib import ( DeriveTest, ) -from gitdb import * -from gitdb.util import ( +from git import * +from git.util import ( NULL_BIN_SHA ) -from gitdb.typ import ( +from git.typ import ( str_blob_type ) -- cgit v1.2.3 From 7ae36c3e019a5cc16924d1b6007774bfb625036f Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 6 May 2011 18:53:59 +0200 Subject: Started to fix imports - tests still have no chance to work as database changed drastically. Now the actual work begins --- git/test/test_base.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'git/test/test_base.py') diff --git a/git/test/test_base.py b/git/test/test_base.py index 29916066..ca812ed4 100644 --- a/git/test/test_base.py +++ b/git/test/test_base.py @@ -3,12 +3,18 @@ # # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php +from lib import ( + TestBase, + with_rw_repo, + DummyStream, + DeriveTest, + with_rw_and_rw_remote_repo + ) import git.objects.base as base import git.refs as refs import os -from git.test.lib import * from git import * from itertools import chain from git.objects.util import get_object_type_by_name @@ -16,11 +22,6 @@ from git.util import hex_to_bin import tempfile ################## -from lib import ( - TestBase, - DummyStream, - DeriveTest, - ) from git import * from git.util import ( -- cgit v1.2.3 From cd26aaebbda94dc3740e41bbd3f91ba6b1a25c10 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 10 May 2011 10:21:26 +0200 Subject: Made repository paths methods a property to be compatible with the existing repo interface. Added submodule interface ... goal is to provide all of the extra repo functionality in custom interfaces --- git/test/test_base.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'git/test/test_base.py') diff --git a/git/test/test_base.py b/git/test/test_base.py index ca812ed4..7488ac6b 100644 --- a/git/test/test_base.py +++ b/git/test/test_base.py @@ -12,10 +12,15 @@ from lib import ( ) import git.objects.base as base +from git.objects import ( + Blob, + Tree, + Commit, + TagObject + ) import git.refs as refs -import os -from git import * + from itertools import chain from git.objects.util import get_object_type_by_name from git.util import hex_to_bin @@ -23,14 +28,22 @@ import tempfile ################## -from git import * from git.util import ( NULL_BIN_SHA ) -from git.typ import ( - str_blob_type - ) +from git.typ import str_blob_type +from git.base import ( + OInfo, + OPackInfo, + ODeltaPackInfo, + OStream, + OPackStream, + ODeltaPackStream, + IStream, + ) + +import os class TestBase(TestBase): @@ -94,7 +107,7 @@ class TestBase(TestBase): assert base.Object in get_object_type_by_name(tname).mro() # END for each known type - assert_raises( ValueError, get_object_type_by_name, "doesntexist" ) + self.failUnlessRaises(ValueError, get_object_type_by_name, "doesntexist") def test_object_resolution(self): # objects must be resolved to shas so they compare equal -- cgit v1.2.3