You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/08/16 04:07:28 UTC

[03/18] git commit: [#6506] Minor mocking cleanup

[#6506] Minor mocking cleanup

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6464
Commit: 3f6bf33c4177e1e9889950383830f9374214c3eb
Parents: 490c83e
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Aug 15 16:31:10 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Aug 15 16:31:10 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/decorators.py        | 6 +-----
 Allura/allura/tests/test_decorators.py | 7 +++----
 2 files changed, 4 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3f6bf33c/Allura/allura/lib/decorators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/decorators.py b/Allura/allura/lib/decorators.py
index 137152e..8604a92 100644
--- a/Allura/allura/lib/decorators.py
+++ b/Allura/allura/lib/decorators.py
@@ -32,10 +32,6 @@ from pylons import tmpl_context as c
 from allura.lib import helpers as h
 
 
-def _get_model():
-    from allura import model as M
-    return M
-
 def task(*args, **kw):
     """Decorator that adds a ``.post()`` function to the decorated callable.
 
@@ -62,7 +58,7 @@ def task(*args, **kw):
             cm = (h.notifications_disabled if project and
                     kw.get('notifications_disabled') else h.null_contextmanager)
             with cm(project):
-                M = _get_model()
+                from allura import model as M
                 return M.MonQTask.post(func, args, kwargs, delay=delay)
         # if decorating a class, have to make it a staticmethod
         # or it gets a spurious cls argument

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3f6bf33c/Allura/allura/tests/test_decorators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_decorators.py b/Allura/allura/tests/test_decorators.py
index 893f327..41ba631 100644
--- a/Allura/allura/tests/test_decorators.py
+++ b/Allura/allura/tests/test_decorators.py
@@ -20,8 +20,8 @@ class TestTask(TestCase):
         self.assertTrue(hasattr(func, 'post'))
 
     @patch('allura.lib.decorators.c')
-    @patch('allura.lib.decorators._get_model')
-    def test_post(self, c, _get_model):
+    @patch('allura.model.MonQTask')
+    def test_post(self, c, MonQTask):
         @task(disable_notifications=True)
         def func(s, foo=None, **kw):
             pass
@@ -34,6 +34,5 @@ class TestTask(TestCase):
             self.assertEqual(f, func)
 
         c.project.notifications_disabled = False
-        M = _get_model.return_value
-        M.MonQTask.post.side_effect = mock_post
+        MonQTask.post.side_effect = mock_post
         func.post('test', foo=2, delay=1)