From b377c07200392ac35a6ed668673451d3c9b1f5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20Fr=C3=A9cinaux?= Date: Fri, 5 Sep 2008 21:51:14 +0200 Subject: Use a dictionnary for tree contents It seems more natural to use a dictionnary for directories, since we usually want to access them by name, and entry order is not relevant. Also, finding a particular blob given its name is O(1) instead of O(N). --- test/git/test_repo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/git/test_repo.py') diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 7550e1d6..c7a4c01b 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -96,8 +96,8 @@ class TestRepo(object): tree = self.repo.tree('master') - assert_equal(4, len([c for c in tree.contents if isinstance(c, Blob)])) - assert_equal(3, len([c for c in tree.contents if isinstance(c, Tree)])) + assert_equal(4, len([c for c in tree.contents.values() if isinstance(c, Blob)])) + assert_equal(3, len([c for c in tree.contents.values() if isinstance(c, Tree)])) assert_true(git.called) assert_equal(git.call_args, (('ls_tree', 'master'), {})) -- cgit v1.2.1 From 0425bc64384fe9a6a22edb7831d6e8c1756e2c7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20Fr=C3=A9cinaux?= Date: Sat, 6 Sep 2008 00:10:12 +0200 Subject: Implement dict protocol for trees. It is rather intuitive to consider trees as a dict of objects (like a directory could be seen as a dict of files). --- test/git/test_repo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/git/test_repo.py') diff --git a/test/git/test_repo.py b/test/git/test_repo.py index c7a4c01b..3c323878 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -96,8 +96,8 @@ class TestRepo(object): tree = self.repo.tree('master') - assert_equal(4, len([c for c in tree.contents.values() if isinstance(c, Blob)])) - assert_equal(3, len([c for c in tree.contents.values() if isinstance(c, Tree)])) + assert_equal(4, len([c for c in tree.values() if isinstance(c, Blob)])) + assert_equal(3, len([c for c in tree.values() if isinstance(c, Tree)])) assert_true(git.called) assert_equal(git.call_args, (('ls_tree', 'master'), {})) -- cgit v1.2.1 From befb617d0c645a5fa3177a1b830a8c9871da4168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20Fr=C3=A9cinaux?= Date: Sun, 7 Sep 2008 21:49:14 +0200 Subject: Make daemon export a property of git.Repo Now you can do this: >>> exported = repo.daemon_export >>> repo.daemon_export = True --- test/git/test_repo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test/git/test_repo.py') diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 3c323878..036ae1e9 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -194,10 +194,12 @@ class TestRepo(object): @patch('git.utils', 'touch') def test_enable_daemon_serve(self, touch): - self.repo.enable_daemon_serve + self.repo.daemon_serve = False + assert_false(self.repo.daemon_serve) def test_disable_daemon_serve(self): - self.repo.disable_daemon_serve + self.repo.daemon_serve = True + assert_true(self.repo.daemon_serve) # @patch(os.path, 'exists') # @patch('__builtin__', 'open') -- cgit v1.2.1 From 5d3e2f7f57620398df896d9569c5d7c5365f823d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20Fr=C3=A9cinaux?= Date: Sun, 7 Sep 2008 21:55:13 +0200 Subject: Allow modifying the project description Do this: >>> repo.description = "Foo Bar" >>> repo.description 'Foo Bar' --- test/git/test_repo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/git/test_repo.py') diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 036ae1e9..29ba463b 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -25,7 +25,9 @@ class TestRepo(object): Repo("repos/foobar") def test_description(self): - assert_equal("Unnamed repository; edit this file to name it for gitweb.", self.repo.description) + txt = "Test repository" + self.repo.description = txt + assert_equal(self.repo.description, txt) def test_heads_should_return_array_of_head_objects(self): for head in self.repo.heads: -- cgit v1.2.1