aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/diff_rename12
-rw-r--r--test/git/test_commit.py39
-rw-r--r--test/git/test_diff.py14
-rw-r--r--test/git/test_repo.py16
4 files changed, 61 insertions, 20 deletions
diff --git a/test/fixtures/diff_rename b/test/fixtures/diff_rename
new file mode 100644
index 00000000..13abae0e
--- /dev/null
+++ b/test/fixtures/diff_rename
@@ -0,0 +1,12 @@
+commit 2524c44334a8ba6b2ab8f3f0a478f04c5b073cc8
+tree e126e7b4203dadf083f5eb8e2f34c255b51d8bee
+parent d789e23b9ea8d90221d13c46f7c228d729385f92
+author Michael Trier <mtrier@gmail.com> 1229389391 -0500
+committer Michael Trier <mtrier@gmail.com> 1229389391 -0500
+
+ Renamed AUTHORS to CONTRIBUTORS because it's cooler.
+
+diff --git a/AUTHORS b/CONTRIBUTORS
+similarity index 100%
+rename from AUTHORS
+rename to CONTRIBUTORS
diff --git a/test/git/test_commit.py b/test/git/test_commit.py
index e9336f2c..da7236c8 100644
--- a/test/git/test_commit.py
+++ b/test/git/test_commit.py
@@ -22,7 +22,7 @@ class TestCommit(object):
assert_equal("tom@mojombo.com", commit.author.email)
assert_true(git.called)
- assert_equal(git.call_args, (('rev_list', '4c8124ffcf4039d292442eeccabdeca5af5c5017'), {'pretty': 'raw', 'max_count': 1}))
+ assert_equal(git.call_args, (('rev_list', '4c8124ffcf4039d292442eeccabdeca5af5c5017', '--', ''), {'pretty': 'raw', 'max_count': 1}))
@patch_object(Git, '_call_process')
def test_id_abbrev(self, git):
@@ -52,7 +52,23 @@ class TestCommit(object):
assert_equal(True, diffs[5].new_file)
assert_true(git.called)
- assert_equal(git.call_args, (('diff', 'master'), {'full_index': True}))
+ 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):
@@ -63,7 +79,7 @@ class TestCommit(object):
assert_equal(3, len(diffs))
assert_true(git.called)
- assert_equal(git.call_args, (('diff', '59ddc32', '13d27d5'), {'full_index': True}))
+ assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5'), {'full_index': True}))
@patch_object(Git, '_call_process')
def test_diff_with_files(self, git):
@@ -75,7 +91,7 @@ class TestCommit(object):
assert_equal('lib/grit/diff.rb', diffs[0].a_path)
assert_true(git.called)
- assert_equal(git.call_args, (('diff', '59ddc32', '--', 'lib'), {'full_index': True}))
+ 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):
@@ -87,7 +103,7 @@ class TestCommit(object):
assert_equal('lib/grit/commit.rb', diffs[0].a_path)
assert_true(git.called)
- assert_equal(git.call_args, (('diff', '59ddc32', '13d27d5', '--', 'lib'), {'full_index': True}))
+ assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5', '--', 'lib'), {'full_index': True}))
@patch_object(Git, '_call_process')
def test_diffs(self, git):
@@ -113,7 +129,8 @@ class TestCommit(object):
assert_equal(True, diffs[5].new_file)
assert_true(git.called)
- assert_equal(git.call_args, (('diff', '038af8c329ef7c1bae4568b98bd5c58510465493',
+ assert_equal(git.call_args, (('diff', '-M',
+ '038af8c329ef7c1bae4568b98bd5c58510465493',
'91169e1f5fa4de2eaea3f176461f5dc784796769',
), {'full_index': True}))
@@ -130,7 +147,7 @@ class TestCommit(object):
assert_equal('History.txt', diffs[0].a_path)
assert_equal('History.txt', diffs[0].b_path)
assert_equal(None, diffs[0].a_commit)
- assert_equal(None, diffs[0].b_mode)
+ assert_equal('100644', diffs[0].b_mode)
assert_equal('81d2c27608b352814cbe979a6acd678d30219678', diffs[0].b_commit.id)
assert_equal(True, diffs[0].new_file)
assert_equal(False, diffs[0].deleted_file)
@@ -142,7 +159,7 @@ class TestCommit(object):
assert_equal(True, diffs[5].new_file)
assert_true(git.called)
- assert_equal(git.call_args, (('show', '634396b2f541a9f2d58b00be1a07f0c358b999b3'), {'full_index': True, 'pretty': 'raw'}))
+ assert_equal(git.call_args, (('show', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '-M'), {'full_index': True, 'pretty': 'raw'}))
@patch_object(Git, '_call_process')
def test_diffs_on_initial_import_with_empty_commit(self, git):
@@ -154,7 +171,7 @@ class TestCommit(object):
assert_equal([], diffs)
assert_true(git.called)
- assert_equal(git.call_args, (('show', '634396b2f541a9f2d58b00be1a07f0c358b999b3'), {'full_index': True, 'pretty': 'raw'}))
+ assert_equal(git.call_args, (('show', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '-M'), {'full_index': True, 'pretty': 'raw'}))
@patch_object(Git, '_call_process')
def test_diffs_with_mode_only_change(self, git):
@@ -169,7 +186,7 @@ class TestCommit(object):
assert_equal('100755', diffs[0].b_mode)
assert_true(git.called)
- assert_equal(git.call_args, (('show', '91169e1f5fa4de2eaea3f176461f5dc784796769'), {'full_index': True, 'pretty': 'raw'}))
+ assert_equal(git.call_args, (('show', '91169e1f5fa4de2eaea3f176461f5dc784796769', '-M'), {'full_index': True, 'pretty': 'raw'}))
@patch_object(Git, '_call_process')
def test_stats(self, git):
@@ -184,7 +201,7 @@ class TestCommit(object):
assert_equal(["a.txt", "b.txt"], keys)
assert_true(git.called)
- assert_equal(git.call_args, (('diff', '634396b2f541a9f2d58b00be1a07f0c358b999b3'), {'numstat': True}))
+ assert_equal(git.call_args, (('diff', '634396b2f541a9f2d58b00be1a07f0c358b999b3', '--'), {'numstat': True}))
@patch_object(Git, '_call_process')
def test_rev_list_bisect_all(self, git):
diff --git a/test/git/test_diff.py b/test/git/test_diff.py
index 9b7e9c73..94ac03e0 100644
--- a/test/git/test_diff.py
+++ b/test/git/test_diff.py
@@ -10,9 +10,21 @@ from git import *
class TestDiff(object):
def setup(self):
self.repo = Repo(GIT_REPO)
-
+
def test_list_from_string_new_mode(self):
output = fixture('diff_new_mode')
diffs = Diff.list_from_string(self.repo, output)
assert_equal(1, len(diffs))
assert_equal(10, len(diffs[0].diff.splitlines()))
+
+ def test_diff_with_rename(self):
+ output = fixture('diff_rename')
+ diffs = Diff.list_from_string(self.repo, output)
+
+ assert_equal(1, len(diffs))
+
+ diff = diffs[0]
+ assert_true(diff.renamed)
+ assert_equal(diff.rename_from, 'AUTHORS')
+ assert_equal(diff.rename_to, 'CONTRIBUTORS')
+
diff --git a/test/git/test_repo.py b/test/git/test_repo.py
index 79c2dd8c..8b767744 100644
--- a/test/git/test_repo.py
+++ b/test/git/test_repo.py
@@ -48,7 +48,7 @@ class TestRepo(object):
def test_commits(self, git):
git.return_value = fixture('rev_list')
- commits = self.repo.commits('master', 10)
+ commits = self.repo.commits('master', max_count=10)
c = commits[0]
assert_equal('4c8124ffcf4039d292442eeccabdeca5af5c5017', c.id)
@@ -67,10 +67,10 @@ class TestRepo(object):
c = commits[2]
assert_equal(["6e64c55896aabb9a7d8e9f8f296f426d21a78c2c", "7f874954efb9ba35210445be456c74e037ba6af2"], map(lambda p: p.id, c.parents))
- assert_equal("Merge branch 'site'", c.message)
+ assert_equal("Merge branch 'site'", c.summary)
assert_true(git.called)
- assert_equal(git.call_args, (('rev_list', 'master'), {'skip': 0, 'pretty': 'raw', 'max_count': 10}))
+ assert_equal(git.call_args, (('rev_list', 'master', '--', ''), {'skip': 0, 'pretty': 'raw', 'max_count': 10}))
@patch_object(Git, '_call_process')
def test_commit_count(self, git):
@@ -79,7 +79,7 @@ class TestRepo(object):
assert_equal(655, self.repo.commit_count('master'))
assert_true(git.called)
- assert_equal(git.call_args, (('rev_list', 'master'), {}))
+ assert_equal(git.call_args, (('rev_list', 'master', '--', ''), {}))
@patch_object(Git, '_call_process')
def test_commit(self, git):
@@ -90,7 +90,7 @@ class TestRepo(object):
assert_equal("4c8124ffcf4039d292442eeccabdeca5af5c5017", commit.id)
assert_true(git.called)
- assert_equal(git.call_args, (('rev_list', '4c8124ffcf4039d292442eeccabdeca5af5c5017'), {'pretty': 'raw', 'max_count': 1}))
+ assert_equal(git.call_args, (('rev_list', '4c8124ffcf4039d292442eeccabdeca5af5c5017', '--', ''), {'pretty': 'raw', 'max_count': 1}))
@patch_object(Git, '_call_process')
def test_tree(self, git):
@@ -269,7 +269,7 @@ class TestRepo(object):
assert_equal('ab25fd8483882c3bda8a458ad2965d2248654335', self.repo.log()[-1].id)
assert_true(git.called)
assert_equal(git.call_count, 2)
- assert_equal(git.call_args, (('log', 'master'), {'pretty': 'raw'}))
+ assert_equal(git.call_args, (('log', 'master', '--'), {'pretty': 'raw'}))
@patch_object(Git, '_call_process')
def test_log_with_path_and_options(self, git):
@@ -314,14 +314,14 @@ class TestRepo(object):
self.repo.bare = False
git.return_value = ''
assert_false(self.repo.is_dirty)
- assert_equal(git.call_args, (('diff', 'HEAD'), {}))
+ assert_equal(git.call_args, (('diff', 'HEAD', '--'), {}))
@patch_object(Git, '_call_process')
def test_is_dirty_with_dirty_working_dir(self, git):
self.repo.bare = False
git.return_value = '''-aaa\n+bbb'''
assert_true(self.repo.is_dirty)
- assert_equal(git.call_args, (('diff', 'HEAD'), {}))
+ assert_equal(git.call_args, (('diff', 'HEAD', '--'), {}))
@patch_object(Git, '_call_process')
def test_active_branch(self, git):