From ff3d142387e1f38b0ed390333ea99e2e23d96e35 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 12 Oct 2009 18:02:07 +0200 Subject: test_base: Improved basic object creation as well as set hash tests --- test/git/test_base.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'test/git/test_base.py') diff --git a/test/git/test_base.py b/test/git/test_base.py index a153eb83..aff0947d 100644 --- a/test/git/test_base.py +++ b/test/git/test_base.py @@ -24,14 +24,14 @@ class TestBase(object): def test_base_object(self): # test interface of base object classes - fcreators = (self.repo.blob, self.repo.tree, self.repo.commit, lambda id: TagObject(self.repo,id) ) - assert len(fcreators) == len(self.type_tuples) + types = (Blob, Tree, Commit, TagObject) + assert len(types) == len(self.type_tuples) s = set() num_objs = 0 num_index_objs = 0 - for fcreator, (typename, hexsha) in zip(fcreators, self.type_tuples): - item = fcreator(hexsha) + for obj_type, (typename, hexsha) in zip(types, self.type_tuples): + item = obj_type(self.repo,hexsha) num_objs += 1 assert item.id == hexsha assert item.type == typename @@ -53,6 +53,7 @@ class TestBase(object): # each has a unique sha assert len(s) == num_objs + assert len(s|s) == num_objs assert num_index_objs == 2 @@ -70,6 +71,7 @@ class TestBase(object): s.add(ref) # END for each ref assert len(s) == ref_count + assert len(s|s) == ref_count def test_get_object_type_by_name(self): for tname in base.Object.TYPES: -- cgit v1.2.3 From 5eb0f2c241718bc7462be44e5e8e1e36e35f9b15 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 13 Oct 2009 17:50:26 +0200 Subject: unified name of utils module, recently it was named util and utils in different packages --- test/git/test_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/git/test_base.py') diff --git a/test/git/test_base.py b/test/git/test_base.py index aff0947d..97dfc255 100644 --- a/test/git/test_base.py +++ b/test/git/test_base.py @@ -10,7 +10,7 @@ from git import * import git.objects.base as base import git.refs as refs from itertools import chain -from git.objects.util import get_object_type_by_name +from git.objects.utils import get_object_type_by_name class TestBase(object): -- cgit v1.2.3 From 6745f4542cfb74bbf3b933dba7a59ef2f54a4380 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 14 Oct 2009 19:34:45 +0200 Subject: test_blob: removed many redundant tests that would fail now as the mock cannot handle the complexity of the command backend All objects but Tree now use the persistent command to read their object information - Trees get binary data and would need their own pretty-printing or they need to parse the data themselves which is my favorite --- test/git/test_base.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/git/test_base.py') diff --git a/test/git/test_base.py b/test/git/test_base.py index 97dfc255..6e3aad7f 100644 --- a/test/git/test_base.py +++ b/test/git/test_base.py @@ -73,6 +73,16 @@ class TestBase(object): assert len(s) == ref_count assert len(s|s) == ref_count + def test_heads(self): + # see how it dynmically updates its object + for head in self.repo.heads: + head.name + head.path + cur_obj = head.object + del( head.object ) + assert cur_obj == head.object + # END for each head + def test_get_object_type_by_name(self): for tname in base.Object.TYPES: assert base.Object in get_object_type_by_name(tname).mro() -- cgit v1.2.3 From 832b56394b079c9f6e4c777934447a9e224facfe Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 14 Oct 2009 19:46:24 +0200 Subject: Refs are now truly dynamic - this costs a little bit of (persistent command) work, but assures refs behave as expected --- test/git/test_base.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'test/git/test_base.py') diff --git a/test/git/test_base.py b/test/git/test_base.py index 6e3aad7f..402cdba3 100644 --- a/test/git/test_base.py +++ b/test/git/test_base.py @@ -78,9 +78,10 @@ class TestBase(object): for head in self.repo.heads: head.name head.path - cur_obj = head.object - del( head.object ) - assert cur_obj == head.object + prev_object = head.object + cur_object = head.object + assert prev_object == cur_object # represent the same git object + assert prev_object is not cur_object # but are different instances # END for each head def test_get_object_type_by_name(self): -- cgit v1.2.3