From a5cf1bc1d3e38ab32a20707d66b08f1bb0beae91 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sat, 17 Oct 2009 20:13:02 +0200 Subject: Removed a few diff-related test cases that fail now as the respective method is missing - these tests have to be redone in test-diff module accordingly --- test/git/test_commit.py | 150 ------------------------------------------------ 1 file changed, 150 deletions(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index 4e698ed0..c8bca564 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -20,156 +20,6 @@ class TestCommit(object): assert_equal("byronimo@gmail.com", commit.author.email) - @patch_object(Git, '_call_process') - def test_diff(self, git): - git.return_value = fixture('diff_p') - - diffs = Commit.diff(self.repo, 'master') - - assert_equal(15, len(diffs)) - - diff = diffs[0] - assert_equal('.gitignore', diff.a_blob.path) - assert_equal('.gitignore', diff.b_blob.path) - assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diff.a_blob.id) - assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diff.b_blob.id) - - assert_mode_644(diff.b_blob.mode) - - assert_equal(False, diff.new_file) - assert_equal(False, diff.deleted_file) - assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diff.diff) - - diff = diffs[5] - assert_equal('lib/grit/actor.rb', diff.b_blob.path) - assert_equal(None, diff.a_blob) - assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diff.b_blob.id) - assert_equal( None, diff.a_mode ) - assert_equal(True, diff.new_file) - - assert_true(git.called) - assert_equal(git.call_args, (('diff', '-M', 'master'), {'full_index': True})) - - @patch_object(Git, '_call_process') - def test_diff_with_rename(self, git): - git.return_value = fixture('diff_rename') - - diffs = Commit.diff(self.repo, 'rename') - - assert_equal(1, len(diffs)) - - diff = diffs[0] - assert_true(diff.renamed) - assert_equal(diff.rename_from, 'AUTHORS') - assert_equal(diff.rename_to, 'CONTRIBUTORS') - - assert_true(git.called) - assert_equal(git.call_args, (('diff', '-M', 'rename'), {'full_index': True})) - - @patch_object(Git, '_call_process') - def test_diff_with_two_commits(self, git): - git.return_value = fixture('diff_2') - - diffs = Commit.diff(self.repo, '59ddc32', '13d27d5') - - assert_equal(3, len(diffs)) - - assert_true(git.called) - assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5'), {'full_index': True})) - - @patch_object(Git, '_call_process') - def test_diff_with_files(self, git): - git.return_value = fixture('diff_f') - - diffs = Commit.diff(self.repo, '59ddc32', ['lib']) - - assert_equal(1, len(diffs)) - assert_equal('lib/grit/diff.rb', diffs[0].a_blob.path) - - assert_true(git.called) - assert_equal(git.call_args, (('diff', '-M', '59ddc32', '--', 'lib'), {'full_index': True})) - - @patch_object(Git, '_call_process') - def test_diff_with_two_commits_and_files(self, git): - git.return_value = fixture('diff_2f') - - diffs = Commit.diff(self.repo, '59ddc32', '13d27d5', ['lib']) - - assert_equal(1, len(diffs)) - assert_equal('lib/grit/commit.rb', diffs[0].a_blob.path) - - assert_true(git.called) - assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5', '--', 'lib'), {'full_index': True})) - - @patch_object(Git, '_call_process') - def test_diffs(self, git): - git.return_value = fixture('diff_p') - - commit = Commit(self.repo, id='91169e1f5fa4de2eaea3f176461f5dc784796769', parents=['038af8c329ef7c1bae4568b98bd5c58510465493']) - diffs = commit.diffs - - assert_equal(15, len(diffs)) - - diff = diffs[0] - assert_equal('.gitignore', diff.a_blob.path) - assert_equal('.gitignore', diff.b_blob.path) - assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diff.a_blob.id) - assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diff.b_blob.id) - assert_mode_644(diff.b_blob.mode) - assert_equal(False, diff.new_file) - assert_equal(False, diff.deleted_file) - assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diff.diff) - - diff = diffs[5] - assert_equal('lib/grit/actor.rb', diff.b_blob.path) - assert_equal(None, diff.a_blob) - assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diff.b_blob.id) - assert_equal(True, diff.new_file) - - assert_true(git.called) - assert_equal(git.call_args, (('diff', '-M', - '038af8c329ef7c1bae4568b98bd5c58510465493', - '91169e1f5fa4de2eaea3f176461f5dc784796769', - ), {'full_index': True})) - - def test_diffs_on_initial_import(self): - commit = Commit(self.repo, '33ebe7acec14b25c5f84f35a664803fcab2f7781') - - for diff in commit.diffs: - assert isinstance(diff, Diff) - assert isinstance(diff.a_blob, Blob) or isinstance(diff.b_blob, Blob) - - if diff.a_mode is not None: - assert isinstance(diff.a_mode, int) - if diff.b_mode is not None: - isinstance(diff.b_mode, int) - - assert diff.diff is not None # can be empty - - if diff.renamed: - assert diff.rename_from and diff.rename_to and diff.rename_from != diff.rename_to - if diff.a_blob is None: - assert diff.new_file and isinstance(diff.new_file, bool) - if diff.b_blob is None: - assert diff.deleted_file and isinstance(diff.deleted_file, bool) - # END for each diff in initial import commit - - def test_diffs_on_initial_import_without_parents(self): - commit = Commit(self.repo, id='33ebe7acec14b25c5f84f35a664803fcab2f7781') - diffs = commit.diffs - assert diffs - - def test_diffs_with_mode_only_change(self): - commit = Commit(self.repo, id='ccde80b7a3037a004a7807a6b79916ce2a1e9729') - diffs = commit.diffs - - # in case of mode-only changes, there is no blob - assert_equal(1, len(diffs)) - assert_equal(None, diffs[0].a_blob) - assert_equal(None, diffs[0].b_blob) - assert_mode_644(diffs[0].a_mode) - assert_mode_755(diffs[0].b_mode) - def test_stats(self): commit = Commit(self.repo, id='33ebe7acec14b25c5f84f35a664803fcab2f7781') stats = commit.stats -- cgit v1.2.1 From 0b3ecf2dcace76b65765ddf1901504b0b4861b08 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 19 Oct 2009 22:49:52 +0200 Subject: commit.count: is an instance method now repo: added head , tag and iter_trees methods for completeness changes: headlines now sorted chronologically --- test/git/test_commit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index c8bca564..abe16dfb 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -66,7 +66,7 @@ class TestCommit(object): assert_equal(sha1, commit.id) def test_count(self): - assert Commit.count( self.repo, '0.1.5' ) == 141 + assert self.repo.tag('0.1.5').commit.count( ) == 141 def test_str(self): commit = Commit(self.repo, id='abc') -- cgit v1.2.1 From 989671780551b7587d57e1d7cb5eb1002ade75b4 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 19 Oct 2009 23:44:18 +0200 Subject: Implemneted IterableLists for refs, commits and remote objects including simple tests --- test/git/test_commit.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index abe16dfb..3d7feb6d 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -67,6 +67,9 @@ class TestCommit(object): def test_count(self): assert self.repo.tag('0.1.5').commit.count( ) == 141 + + def test_list(self): + assert isinstance(Commit.list_items(self.repo, '0.1.5', max_count=5)['5117c9c8a4d3af19a9958677e45cda9269de1541'], Commit) def test_str(self): commit = Commit(self.repo, id='abc') -- cgit v1.2.1 From b197b2dbb527de9856e6e808339ab0ceaf0a512d Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 22 Oct 2009 16:20:24 +0200 Subject: Adjusted all remaining test suites to use the new TestBase class where appropriate --- test/git/test_commit.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index 3d7feb6d..1a74593d 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -7,13 +7,11 @@ from test.testlib import * from git import * -class TestCommit(object): - def setup(self): - self.repo = Repo(GIT_REPO) +class TestCommit(TestBase): def test_bake(self): - commit = Commit(self.repo, **{'id': '2454ae89983a4496a445ce347d7a41c0bb0ea7ae'}) + commit = Commit(self.rorepo, **{'id': '2454ae89983a4496a445ce347d7a41c0bb0ea7ae'}) commit.author # bake assert_equal("Sebastian Thiel", commit.author.name) @@ -21,7 +19,7 @@ class TestCommit(object): def test_stats(self): - commit = Commit(self.repo, id='33ebe7acec14b25c5f84f35a664803fcab2f7781') + commit = Commit(self.rorepo, id='33ebe7acec14b25c5f84f35a664803fcab2f7781') stats = commit.stats def check_entries(d): @@ -48,13 +46,13 @@ class TestCommit(object): git.return_value = fixture('rev_list_bisect_all') - revs = self.repo.git.rev_list('HEAD', + revs = self.rorepo.git.rev_list('HEAD', pretty='raw', first_parent=True, bisect_all=True) assert_true(git.called) - commits = Commit._iter_from_process_or_stream(self.repo, ListProcessAdapter(revs)) + commits = Commit._iter_from_process_or_stream(self.rorepo, ListProcessAdapter(revs)) expected_ids = ( 'cf37099ea8d1d8c7fbf9b6d12d7ec0249d3acb8b', '33ebe7acec14b25c5f84f35a664803fcab2f7781', @@ -66,29 +64,29 @@ class TestCommit(object): assert_equal(sha1, commit.id) def test_count(self): - assert self.repo.tag('0.1.5').commit.count( ) == 141 + assert self.rorepo.tag('0.1.5').commit.count( ) == 141 def test_list(self): - assert isinstance(Commit.list_items(self.repo, '0.1.5', max_count=5)['5117c9c8a4d3af19a9958677e45cda9269de1541'], Commit) + assert isinstance(Commit.list_items(self.rorepo, '0.1.5', max_count=5)['5117c9c8a4d3af19a9958677e45cda9269de1541'], Commit) def test_str(self): - commit = Commit(self.repo, id='abc') + commit = Commit(self.rorepo, id='abc') assert_equal ("abc", str(commit)) def test_repr(self): - commit = Commit(self.repo, id='abc') + commit = Commit(self.rorepo, id='abc') assert_equal('', repr(commit)) def test_equality(self): - commit1 = Commit(self.repo, id='abc') - commit2 = Commit(self.repo, id='abc') - commit3 = Commit(self.repo, id='zyx') + commit1 = Commit(self.rorepo, id='abc') + commit2 = Commit(self.rorepo, id='abc') + commit3 = Commit(self.rorepo, id='zyx') assert_equal(commit1, commit2) assert_not_equal(commit2, commit3) def test_iter_parents(self): # should return all but ourselves, even if skip is defined - c = self.repo.commit('0.1.5') + c = self.rorepo.commit('0.1.5') for skip in (0, 1): piter = c.iter_parents(skip=skip) first_parent = piter.next() -- cgit v1.2.1 From 58e2157ad3aa9d75ef4abb90eb2d1f01fba0ba2b Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 22 Oct 2009 23:20:16 +0200 Subject: Added SymbolicReference and HEAD type to better represent these special types of references and allow special handling Head.reset now is an instance method of HEAD type Concatenated all reference specific tests into test_refs started to fix tests breaking now because of changed interface --- test/git/test_commit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index 1a74593d..c4ed4b72 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -64,7 +64,7 @@ class TestCommit(TestBase): assert_equal(sha1, commit.id) def test_count(self): - assert self.rorepo.tag('0.1.5').commit.count( ) == 141 + assert self.rorepo.tag('refs/tags/0.1.5').commit.count( ) == 141 def test_list(self): assert isinstance(Commit.list_items(self.rorepo, '0.1.5', max_count=5)['5117c9c8a4d3af19a9958677e45cda9269de1541'], Commit) -- cgit v1.2.1 From 1b89f39432cdb395f5fbb9553b56595d29e2b773 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 23 Oct 2009 16:39:02 +0200 Subject: commit.name_rev property added for convenience --- test/git/test_commit.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index c4ed4b72..251387bd 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -94,3 +94,7 @@ class TestCommit(TestBase): assert first_parent == c.parents[0] # END for each + def test_base(self): + name_rev = self.rorepo.head.commit.name_rev + assert isinstance(name_rev, basestring) + -- cgit v1.2.1 From b999cae064fb6ac11a61a39856e074341baeefde Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 23 Oct 2009 23:44:49 +0200 Subject: actor: added __eq__, __ne__ and __hash__ methods including simple test commit: Fixed long-standing issue during message parsing that would fail to parse properly in case we were created from data. Also it would strip white space from the messages although it shouldn't --- test/git/test_commit.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index c4ed4b72..da636a2b 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -16,6 +16,9 @@ class TestCommit(TestBase): assert_equal("Sebastian Thiel", commit.author.name) assert_equal("byronimo@gmail.com", commit.author.email) + assert commit.author == commit.committer + assert isinstance(commit.authored_date, int) and isinstance(commit.committed_date, int) + assert commit.message == "Added missing information to docstrings of commit and stats module" def test_stats(self): @@ -37,6 +40,14 @@ class TestCommit(TestBase): check_entries(d) # END for each stated file + # assure data is parsed properly + michael = Actor._from_string("Michael Trier ") + assert commit.author == michael + assert commit.committer == michael + assert commit.authored_date == 1210193388 + assert commit.committed_date == 1210193388 + assert commit.message == "initial project" + @patch_object(Git, '_call_process') def test_rev_list_bisect_all(self, git): """ @@ -52,7 +63,7 @@ class TestCommit(TestBase): bisect_all=True) assert_true(git.called) - commits = Commit._iter_from_process_or_stream(self.rorepo, ListProcessAdapter(revs)) + commits = Commit._iter_from_process_or_stream(self.rorepo, ListProcessAdapter(revs), True) expected_ids = ( 'cf37099ea8d1d8c7fbf9b6d12d7ec0249d3acb8b', '33ebe7acec14b25c5f84f35a664803fcab2f7781', -- cgit v1.2.1 From 3cb5ba18ab1a875ef6b62c65342de476be47871b Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 3 Nov 2009 16:35:33 +0100 Subject: object: renamed id attribute to sha as it in fact is always being rewritten as sha, even if the passed in id was a ref. This is done to assure objects are uniquely identified and will compare correctly --- test/git/test_commit.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/git/test_commit.py') diff --git a/test/git/test_commit.py b/test/git/test_commit.py index af952ed1..be6d1a28 100644 --- a/test/git/test_commit.py +++ b/test/git/test_commit.py @@ -11,7 +11,7 @@ class TestCommit(TestBase): def test_bake(self): - commit = Commit(self.rorepo, **{'id': '2454ae89983a4496a445ce347d7a41c0bb0ea7ae'}) + commit = Commit(self.rorepo, **{'sha': '2454ae89983a4496a445ce347d7a41c0bb0ea7ae'}) commit.author # bake assert_equal("Sebastian Thiel", commit.author.name) @@ -22,7 +22,7 @@ class TestCommit(TestBase): def test_stats(self): - commit = Commit(self.rorepo, id='33ebe7acec14b25c5f84f35a664803fcab2f7781') + commit = Commit(self.rorepo, '33ebe7acec14b25c5f84f35a664803fcab2f7781') stats = commit.stats def check_entries(d): @@ -72,7 +72,7 @@ class TestCommit(TestBase): 'c231551328faa864848bde6ff8127f59c9566e90', ) for sha1, commit in zip(expected_ids, commits): - assert_equal(sha1, commit.id) + assert_equal(sha1, commit.sha) def test_count(self): assert self.rorepo.tag('refs/tags/0.1.5').commit.count( ) == 141 @@ -81,17 +81,17 @@ class TestCommit(TestBase): assert isinstance(Commit.list_items(self.rorepo, '0.1.5', max_count=5)['5117c9c8a4d3af19a9958677e45cda9269de1541'], Commit) def test_str(self): - commit = Commit(self.rorepo, id='abc') + commit = Commit(self.rorepo, 'abc') assert_equal ("abc", str(commit)) def test_repr(self): - commit = Commit(self.rorepo, id='abc') + commit = Commit(self.rorepo, 'abc') assert_equal('', repr(commit)) def test_equality(self): - commit1 = Commit(self.rorepo, id='abc') - commit2 = Commit(self.rorepo, id='abc') - commit3 = Commit(self.rorepo, id='zyx') + commit1 = Commit(self.rorepo, 'abc') + commit2 = Commit(self.rorepo, 'abc') + commit3 = Commit(self.rorepo, 'zyx') assert_equal(commit1, commit2) assert_not_equal(commit2, commit3) -- cgit v1.2.1