allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [6/7] allura git commit: [#7866] ticket:754 Rewrite can_merge tests
Date Mon, 20 Apr 2015 10:45:44 GMT
[#7866] ticket:754 Rewrite can_merge tests


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

Branch: refs/heads/ib/7866
Commit: ee6f0bb8facc6499442f1181e192e0e6668582d2
Parents: 7b60d50
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Sat Apr 18 12:23:37 2015 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Sat Apr 18 12:23:37 2015 +0000

----------------------------------------------------------------------
 Allura/allura/tests/model/test_repo.py | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ee6f0bb8/Allura/allura/tests/model/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_repo.py b/Allura/allura/tests/model/test_repo.py
index 54a30a6..d083675 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -760,15 +760,22 @@ class TestMergeRequest(object):
         self.mr.set_can_merge_cache(False)
         assert_equal(self.mr.can_merge_cache, {key: True, '123-123': False})
 
-    def test_can_merge(self):
-        assert_equal(self.mr.can_merge(),
-                     self.mr.app.repo.can_merge.return_value)
-        self.mr.app.repo.can_merge.assert_called_once_with(self.mr)
+    def test_can_merge_merged(self):
+        self.mr.status = 'merged'
+        assert_equal(self.mr.can_merge(), True)
 
-        self.mr.app.reset_mock()
-        self.mr.app.forkable = False
+    @mock.patch('allura.tasks.repo_tasks.can_merge', autospec=True)
+    def test_can_merge_cached(self, can_merge_task):
+        self.mr.set_can_merge_cache(False)
         assert_equal(self.mr.can_merge(), False)
-        assert_equal(self.mr.app.repo.can_merge.called, False)
+        self.mr.set_can_merge_cache(True)
+        assert_equal(self.mr.can_merge(), True)
+        assert_equal(can_merge_task.post.call_count, 0)
+
+    @mock.patch('allura.tasks.repo_tasks.can_merge', autospec=True)
+    def test_can_merge_not_cached(self, can_merge_task):
+        assert_equal(self.mr.can_merge(), None)
+        can_merge_task.post.assert_called_once_with(self.mr._id)
 
     @mock.patch('allura.tasks.repo_tasks.merge', autospec=True)
     def test_merge(self, merge_task):
@@ -788,3 +795,11 @@ class TestMergeRequest(object):
         assert_equal(self.mr.merge_task_status(), 'ready')
         M.MonQTask.run_ready()
         assert_equal(self.mr.merge_task_status(), 'complete')
+
+    def test_can_merge_task_status(self):
+        from allura.tasks import repo_tasks
+        assert_equal(self.mr.can_merge_task_status(), None)
+        repo_tasks.can_merge.post(self.mr._id)
+        assert_equal(self.mr.can_merge_task_status(), 'ready')
+        M.MonQTask.run_ready()
+        assert_equal(self.mr.can_merge_task_status(), 'complete')


Mime
View raw message