incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [31/50] git commit: [#4691] Fixed broken SVN tests
Date Wed, 06 Feb 2013 15:42:52 GMT
[#4691] Fixed broken SVN tests

Signed-off-by: Cory Johns <johnsca@geek.net>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/3b13151e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/3b13151e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/3b13151e

Branch: refs/heads/cj/4691
Commit: 3b13151e2adf744371d8172e1a90ef237a04fce7
Parents: 69f5fcf
Author: Cory Johns <johnsca@geek.net>
Authored: Wed Jan 23 18:15:10 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Feb 5 20:22:52 2013 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/tests/model/test_repository.py |   57 ++++++++++-------
 1 files changed, 35 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3b13151e/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index af29b49..9006271 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -5,6 +5,7 @@ import pkg_resources
 from itertools import count, product
 from datetime import datetime
 
+from collections import defaultdict
 from pylons import c
 import mock
 from nose.tools import assert_equal
@@ -527,14 +528,15 @@ class TestRepo(_TestWithRepo):
             self.repo.heads = [ ming.base.Object(name='head', object_id='foo0', count=100)
]
         self.repo._impl.refresh_commit_info = refresh_commit_info
         self.repo._impl.refresh_heads = mock.Mock(side_effect=set_heads)
-        self.repo.shorthand_for_commit = lambda oid: '[' + str(oid) + ']'
-        self.repo.url_for_commit = lambda oid: '/ci/' + str(oid) + '/'
+        _id = lambda oid: getattr(oid, '_id', str(oid))
+        self.repo.shorthand_for_commit = lambda oid: '[' + _id(oid) + ']'
+        self.repo.url_for_commit = lambda oid: 'ci/' + _id(oid) + '/'
         self.repo.refresh()
         ThreadLocalORMSession.flush_all()
         notifications = M.Notification.query.find().all()
         for n in notifications:
             if '100 new commits' in n.subject:
-                assert "master,branch:  by Test Committer http://localhost/#" in n.text
+                assert "master,branch:  by Test Committer http://localhost/ci/foo99" in n.text
                 break
         else:
             assert False, 'Did not find notification'
@@ -666,12 +668,22 @@ class TestCommit(_TestWithRepo):
         rb.cleanup()
         assert self.repo.count_revisions(self.ci) == 1
 
+    def _unique_blobs(self):
+        def counter():
+            counter.i += 1
+            return counter.i
+        counter.i = 0
+        blobs = defaultdict(counter)
+        from cStringIO import StringIO
+        return lambda blob: StringIO(str(blobs[blob.path()]))
+
     def test_compute_diffs(self):
         self.repo._impl.commit = mock.Mock(return_value=self.ci)
+        self.repo._impl.open_blob = self._unique_blobs()
         M.repo_refresh.refresh_commit_trees(self.ci, {})
         M.repo_refresh.compute_diffs(self.repo._id, {}, self.ci)
         # self.ci.compute_diffs()
-        assert self.ci.diffs.added == [ 'a' ]
+        assert_equal(self.ci.diffs.added, [ 'a', 'a/a', 'a/a/a', 'a/a/b', 'a/b' ])
         assert (self.ci.diffs.copied
                 == self.ci.diffs.changed
                 == self.ci.diffs.removed
@@ -681,7 +693,7 @@ class TestCommit(_TestWithRepo):
         self._make_log(ci)
         M.repo_refresh.refresh_commit_trees(ci, {})
         M.repo_refresh.compute_diffs(self.repo._id, {}, ci)
-        assert ci.diffs.removed == [ 'a' ]
+        assert_equal(ci.diffs.removed, [ 'a', 'a/a', 'a/a/a', 'a/a/b', 'a/b' ])
         assert (ci.diffs.copied
                 == ci.diffs.changed
                 == ci.diffs.added
@@ -697,8 +709,8 @@ class TestCommit(_TestWithRepo):
         self._make_log(ci)
         M.repo_refresh.refresh_commit_trees(ci, {})
         M.repo_refresh.compute_diffs(self.repo._id, {}, ci)
-        assert ci.diffs.added == [ 'b' ]
-        assert ci.diffs.removed == [ 'a' ]
+        assert_equal(ci.diffs.added, [ 'b', 'b/a', 'b/a/a', 'b/a/b', 'b/b' ])
+        assert_equal(ci.diffs.removed, [ 'a', 'a/a', 'a/a/a', 'a/a/b', 'a/b' ])
         assert (ci.diffs.copied
                 == ci.diffs.changed
                 == [])
@@ -714,13 +726,13 @@ class TestCommit(_TestWithRepo):
                 u'/b/a/z': u'Death Star will destroy you\nALL',  # moved from /b/b and modified
             }
             from cStringIO import StringIO
-            return StringIO(blobs[blob.path()])
+            return StringIO(blobs.get(blob.path(), ''))
         self.repo._impl.open_blob = open_blob
 
         self.repo._impl.commit = mock.Mock(return_value=self.ci)
         M.repo_refresh.refresh_commit_trees(self.ci, {})
         M.repo_refresh.compute_diffs(self.repo._id, {}, self.ci)
-        assert self.ci.diffs.added == ['a']
+        assert_equal(self.ci.diffs.added, ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'])
         assert (self.ci.diffs.copied
                 == self.ci.diffs.changed
                 == self.ci.diffs.removed
@@ -737,8 +749,8 @@ class TestCommit(_TestWithRepo):
         self._make_log(ci)
         M.repo_refresh.refresh_commit_trees(ci, {})
         M.repo_refresh.compute_diffs(self.repo._id, {}, ci)
-        assert ci.diffs.added == ['b']
-        assert ci.diffs.removed == ['a']
+        assert_equal(ci.diffs.added, ['b', 'b/a', 'b/a/a', 'b/a/b', 'b/b'])
+        assert_equal(ci.diffs.removed, ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'])
         assert (ci.diffs.copied
                 == ci.diffs.changed
                 == [])
@@ -753,18 +765,19 @@ class TestCommit(_TestWithRepo):
         self._make_log(ci)
         M.repo_refresh.refresh_commit_trees(ci, {})
         M.repo_refresh.compute_diffs(self.repo._id, {}, ci)
-        assert ci.diffs.added == ci.diffs.changed == []
-        assert ci.diffs.removed == ['b/a/a']
+        assert_equal(ci.diffs.added, [])
+        assert_equal(ci.diffs.changed, [])
+        assert_equal(ci.diffs.removed, ['b/a/a'])
         # see mock for open_blob
-        assert len(ci.diffs.copied) == 2
-        assert ci.diffs.copied[0]['old'] == 'b/a/b'
-        assert ci.diffs.copied[0]['new'] == 'b/c'
-        assert ci.diffs.copied[0]['ratio'] == 1
-        assert ci.diffs.copied[0]['diff'] == ''
-        assert ci.diffs.copied[1]['old'] == 'b/b'
-        assert ci.diffs.copied[1]['new'] == 'b/a/z'
-        assert ci.diffs.copied[1]['ratio'] < 1
-        assert '+++' in ci.diffs.copied[1]['diff']
+        assert_equal(len(ci.diffs.copied), 2)
+        assert_equal(ci.diffs.copied[0]['old'], 'b/a/b')
+        assert_equal(ci.diffs.copied[0]['new'], 'b/c')
+        assert_equal(ci.diffs.copied[0]['ratio'], 1)
+        assert_equal(ci.diffs.copied[0]['diff'], '')
+        assert_equal(ci.diffs.copied[1]['old'], 'b/b')
+        assert_equal(ci.diffs.copied[1]['new'], 'b/a/z')
+        assert ci.diffs.copied[1]['ratio'] < 1, ci.diffs.copied[1]['ratio']
+        assert '+++' in ci.diffs.copied[1]['diff'], ci.diffs.copied[1]['diff']
 
     def test_context(self):
         self.ci.context()


Mime
View raw message