From 92a97480edcc0f0de787a752bf90feed0445dd39 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 9 Oct 2009 11:57:48 +0200 Subject: Blob|Tree: renamed 'name' member to 'path', updated tests and changelog as it would make existing code incompatible in some places --- test/git/test_blob.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/git/test_blob.py') diff --git a/test/git/test_blob.py b/test/git/test_blob.py index 5bd74ff7..8741fc1d 100644 --- a/test/git/test_blob.py +++ b/test/git/test_blob.py @@ -57,7 +57,7 @@ class TestBlob(object): assert_equal(git.call_args, (('cat_file', 'abc'), {'s': True})) def test_mime_type_should_return_mime_type_for_known_types(self): - blob = Blob(self.repo, **{'id': 'abc', 'name': 'foo.png'}) + blob = Blob(self.repo, **{'id': 'abc', 'path': 'foo.png'}) assert_equal("image/png", blob.mime_type) def test_mime_type_should_return_text_plain_for_unknown_types(self): -- cgit v1.2.1 From 9374a916588d9fe7169937ba262c86ad710cfa74 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Oct 2009 16:49:05 +0200 Subject: converted all spaces to tabs ( 4 spaces = 1 tab ) just to allow me and my editor to work with the files properly. Can convert it back for releaes --- test/git/test_blob.py | 158 +++++++++++++++++++++++++------------------------- 1 file changed, 79 insertions(+), 79 deletions(-) (limited to 'test/git/test_blob.py') diff --git a/test/git/test_blob.py b/test/git/test_blob.py index 8741fc1d..e2ac22e1 100644 --- a/test/git/test_blob.py +++ b/test/git/test_blob.py @@ -9,89 +9,89 @@ from test.testlib import * from git import * class TestBlob(object): - def setup(self): - self.repo = Repo(GIT_REPO) - - @patch_object(Git, '_call_process') - def test_should_return_blob_contents(self, git): - git.return_value = fixture('cat_file_blob') - blob = Blob(self.repo, **{'id': 'abc'}) - assert_equal("Hello world", blob.data) - assert_true(git.called) - assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) + def setup(self): + self.repo = Repo(GIT_REPO) + + @patch_object(Git, '_call_process') + def test_should_return_blob_contents(self, git): + git.return_value = fixture('cat_file_blob') + blob = Blob(self.repo, **{'id': 'abc'}) + assert_equal("Hello world", blob.data) + assert_true(git.called) + assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) - @patch_object(Git, '_call_process') - def test_should_return_blob_contents_with_newline(self, git): - git.return_value = fixture('cat_file_blob_nl') - blob = Blob(self.repo, **{'id': 'abc'}) - assert_equal("Hello world\n", blob.data) - assert_true(git.called) - assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) - - @patch_object(Git, '_call_process') - def test_should_cache_data(self, git): - git.return_value = fixture('cat_file_blob') - blob = Blob(self.repo, **{'id': 'abc'}) - blob.data - blob.data - assert_true(git.called) - assert_equal(git.call_count, 1) - assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) + @patch_object(Git, '_call_process') + def test_should_return_blob_contents_with_newline(self, git): + git.return_value = fixture('cat_file_blob_nl') + blob = Blob(self.repo, **{'id': 'abc'}) + assert_equal("Hello world\n", blob.data) + assert_true(git.called) + assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) + + @patch_object(Git, '_call_process') + def test_should_cache_data(self, git): + git.return_value = fixture('cat_file_blob') + blob = Blob(self.repo, **{'id': 'abc'}) + blob.data + blob.data + assert_true(git.called) + assert_equal(git.call_count, 1) + assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) - @patch_object(Git, '_call_process') - def test_should_return_file_size(self, git): - git.return_value = fixture('cat_file_blob_size') - blob = Blob(self.repo, **{'id': 'abc'}) - assert_equal(11, blob.size) - assert_true(git.called) - assert_equal(git.call_args, (('cat_file', 'abc'), {'s': True})) + @patch_object(Git, '_call_process') + def test_should_return_file_size(self, git): + git.return_value = fixture('cat_file_blob_size') + blob = Blob(self.repo, **{'id': 'abc'}) + assert_equal(11, blob.size) + assert_true(git.called) + assert_equal(git.call_args, (('cat_file', 'abc'), {'s': True})) - @patch_object(Git, '_call_process') - def test_should_cache_file_size(self, git): - git.return_value = fixture('cat_file_blob_size') - blob = Blob(self.repo, **{'id': 'abc'}) - assert_equal(11, blob.size) - assert_equal(11, blob.size) - assert_true(git.called) - assert_equal(git.call_count, 1) - assert_equal(git.call_args, (('cat_file', 'abc'), {'s': True})) + @patch_object(Git, '_call_process') + def test_should_cache_file_size(self, git): + git.return_value = fixture('cat_file_blob_size') + blob = Blob(self.repo, **{'id': 'abc'}) + assert_equal(11, blob.size) + assert_equal(11, blob.size) + assert_true(git.called) + assert_equal(git.call_count, 1) + assert_equal(git.call_args, (('cat_file', 'abc'), {'s': True})) - def test_mime_type_should_return_mime_type_for_known_types(self): - blob = Blob(self.repo, **{'id': 'abc', 'path': 'foo.png'}) - assert_equal("image/png", blob.mime_type) + def test_mime_type_should_return_mime_type_for_known_types(self): + blob = Blob(self.repo, **{'id': 'abc', 'path': 'foo.png'}) + assert_equal("image/png", blob.mime_type) - def test_mime_type_should_return_text_plain_for_unknown_types(self): - blob = Blob(self.repo, **{'id': 'abc'}) - assert_equal("text/plain", blob.mime_type) + def test_mime_type_should_return_text_plain_for_unknown_types(self): + blob = Blob(self.repo, **{'id': 'abc'}) + assert_equal("text/plain", blob.mime_type) - @patch_object(Git, '_call_process') - def test_should_display_blame_information(self, git): - git.return_value = fixture('blame') - b = Blob.blame(self.repo, 'master', 'lib/git.py') - assert_equal(13, len(b)) - assert_equal( 2, len(b[0]) ) - # assert_equal(25, reduce(lambda acc, x: acc + len(x[-1]), b)) - assert_equal(hash(b[0][0]), hash(b[9][0])) - c = b[0][0] - assert_true(git.called) - assert_equal(git.call_args, (('blame', 'master', '--', 'lib/git.py'), {'p': True})) - - assert_equal('634396b2f541a9f2d58b00be1a07f0c358b999b3', c.id) - assert_equal('Tom Preston-Werner', c.author.name) - assert_equal('tom@mojombo.com', c.author.email) - assert_equal(time.gmtime(1191997100), c.authored_date) - assert_equal('Tom Preston-Werner', c.committer.name) - assert_equal('tom@mojombo.com', c.committer.email) - assert_equal(time.gmtime(1191997100), c.committed_date) - assert_equal('initial grit setup', c.message) - - # test the 'lines per commit' entries - tlist = b[0][1] - assert_true( tlist ) - assert_true( isinstance( tlist[0], basestring ) ) - assert_true( len( tlist ) < sum( len(t) for t in tlist ) ) # test for single-char bug - + @patch_object(Git, '_call_process') + def test_should_display_blame_information(self, git): + git.return_value = fixture('blame') + b = Blob.blame(self.repo, 'master', 'lib/git.py') + assert_equal(13, len(b)) + assert_equal( 2, len(b[0]) ) + # assert_equal(25, reduce(lambda acc, x: acc + len(x[-1]), b)) + assert_equal(hash(b[0][0]), hash(b[9][0])) + c = b[0][0] + assert_true(git.called) + assert_equal(git.call_args, (('blame', 'master', '--', 'lib/git.py'), {'p': True})) + + assert_equal('634396b2f541a9f2d58b00be1a07f0c358b999b3', c.id) + assert_equal('Tom Preston-Werner', c.author.name) + assert_equal('tom@mojombo.com', c.author.email) + assert_equal(time.gmtime(1191997100), c.authored_date) + assert_equal('Tom Preston-Werner', c.committer.name) + assert_equal('tom@mojombo.com', c.committer.email) + assert_equal(time.gmtime(1191997100), c.committed_date) + assert_equal('initial grit setup', c.message) + + # test the 'lines per commit' entries + tlist = b[0][1] + assert_true( tlist ) + assert_true( isinstance( tlist[0], basestring ) ) + assert_true( len( tlist ) < sum( len(t) for t in tlist ) ) # test for single-char bug + - def test_should_return_appropriate_representation(self): - blob = Blob(self.repo, **{'id': 'abc'}) - assert_equal('', repr(blob)) + def test_should_return_appropriate_representation(self): + blob = Blob(self.repo, **{'id': 'abc'}) + assert_equal('', repr(blob)) -- cgit v1.2.1 From 101fb1df36f29469ee8f4e0b9e7846d856b87daa Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Oct 2009 17:15:07 +0200 Subject: blob tests fixed to deal with changes to the Blob type --- test/git/test_blob.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'test/git/test_blob.py') diff --git a/test/git/test_blob.py b/test/git/test_blob.py index e2ac22e1..94d3a33b 100644 --- a/test/git/test_blob.py +++ b/test/git/test_blob.py @@ -31,12 +31,13 @@ class TestBlob(object): @patch_object(Git, '_call_process') def test_should_cache_data(self, git): git.return_value = fixture('cat_file_blob') - blob = Blob(self.repo, **{'id': 'abc'}) + bid = '787b92b63f629398f3d2ceb20f7f0c2578259e84' + blob = Blob(self.repo, bid) blob.data blob.data assert_true(git.called) assert_equal(git.call_count, 1) - assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) + assert_equal(git.call_args, (('cat_file', bid), {'p': True, 'with_raw_output': True})) @patch_object(Git, '_call_process') def test_should_return_file_size(self, git): @@ -61,7 +62,7 @@ class TestBlob(object): assert_equal("image/png", blob.mime_type) def test_mime_type_should_return_text_plain_for_unknown_types(self): - blob = Blob(self.repo, **{'id': 'abc'}) + blob = Blob(self.repo, **{'id': 'abc','path': 'something'}) assert_equal("text/plain", blob.mime_type) @patch_object(Git, '_call_process') -- cgit v1.2.1 From f2834177c0fdf6b1af659e460fd3348f468b8ab0 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 12 Oct 2009 11:50:14 +0200 Subject: Reorganized package structure and cleaned up imports --- test/git/test_blob.py | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'test/git/test_blob.py') diff --git a/test/git/test_blob.py b/test/git/test_blob.py index 94d3a33b..ebb53d0c 100644 --- a/test/git/test_blob.py +++ b/test/git/test_blob.py @@ -65,34 +65,6 @@ class TestBlob(object): blob = Blob(self.repo, **{'id': 'abc','path': 'something'}) assert_equal("text/plain", blob.mime_type) - @patch_object(Git, '_call_process') - def test_should_display_blame_information(self, git): - git.return_value = fixture('blame') - b = Blob.blame(self.repo, 'master', 'lib/git.py') - assert_equal(13, len(b)) - assert_equal( 2, len(b[0]) ) - # assert_equal(25, reduce(lambda acc, x: acc + len(x[-1]), b)) - assert_equal(hash(b[0][0]), hash(b[9][0])) - c = b[0][0] - assert_true(git.called) - assert_equal(git.call_args, (('blame', 'master', '--', 'lib/git.py'), {'p': True})) - - assert_equal('634396b2f541a9f2d58b00be1a07f0c358b999b3', c.id) - assert_equal('Tom Preston-Werner', c.author.name) - assert_equal('tom@mojombo.com', c.author.email) - assert_equal(time.gmtime(1191997100), c.authored_date) - assert_equal('Tom Preston-Werner', c.committer.name) - assert_equal('tom@mojombo.com', c.committer.email) - assert_equal(time.gmtime(1191997100), c.committed_date) - assert_equal('initial grit setup', c.message) - - # test the 'lines per commit' entries - tlist = b[0][1] - assert_true( tlist ) - assert_true( isinstance( tlist[0], basestring ) ) - assert_true( len( tlist ) < sum( len(t) for t in tlist ) ) # test for single-char bug - - def test_should_return_appropriate_representation(self): blob = Blob(self.repo, **{'id': 'abc'}) assert_equal('', repr(blob)) -- cgit v1.2.1 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_blob.py | 49 ++++++------------------------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) (limited to 'test/git/test_blob.py') diff --git a/test/git/test_blob.py b/test/git/test_blob.py index ebb53d0c..266f3a23 100644 --- a/test/git/test_blob.py +++ b/test/git/test_blob.py @@ -12,51 +12,14 @@ class TestBlob(object): def setup(self): self.repo = Repo(GIT_REPO) - @patch_object(Git, '_call_process') - def test_should_return_blob_contents(self, git): - git.return_value = fixture('cat_file_blob') - blob = Blob(self.repo, **{'id': 'abc'}) - assert_equal("Hello world", blob.data) - assert_true(git.called) - assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) - - @patch_object(Git, '_call_process') - def test_should_return_blob_contents_with_newline(self, git): - git.return_value = fixture('cat_file_blob_nl') - blob = Blob(self.repo, **{'id': 'abc'}) - assert_equal("Hello world\n", blob.data) - assert_true(git.called) - assert_equal(git.call_args, (('cat_file', 'abc'), {'p': True, 'with_raw_output': True})) - - @patch_object(Git, '_call_process') - def test_should_cache_data(self, git): - git.return_value = fixture('cat_file_blob') - bid = '787b92b63f629398f3d2ceb20f7f0c2578259e84' + def test_should_cache_data(self): + bid = 'a802c139d4767c89dcad79d836d05f7004d39aac' blob = Blob(self.repo, bid) blob.data - blob.data - assert_true(git.called) - assert_equal(git.call_count, 1) - assert_equal(git.call_args, (('cat_file', bid), {'p': True, 'with_raw_output': True})) - - @patch_object(Git, '_call_process') - def test_should_return_file_size(self, git): - git.return_value = fixture('cat_file_blob_size') - blob = Blob(self.repo, **{'id': 'abc'}) - assert_equal(11, blob.size) - assert_true(git.called) - assert_equal(git.call_args, (('cat_file', 'abc'), {'s': True})) - - @patch_object(Git, '_call_process') - def test_should_cache_file_size(self, git): - git.return_value = fixture('cat_file_blob_size') - blob = Blob(self.repo, **{'id': 'abc'}) - assert_equal(11, blob.size) - assert_equal(11, blob.size) - assert_true(git.called) - assert_equal(git.call_count, 1) - assert_equal(git.call_args, (('cat_file', 'abc'), {'s': True})) - + assert blob.data + blob.size + blob.size + def test_mime_type_should_return_mime_type_for_known_types(self): blob = Blob(self.repo, **{'id': 'abc', 'path': 'foo.png'}) assert_equal("image/png", blob.mime_type) -- cgit v1.2.1