incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [05/50] git commit: [#5998] Switched newrelic to use-if-present and added test
Date Fri, 03 May 2013 21:57:35 GMT
[#5998] Switched newrelic to use-if-present and added test

Signed-off-by: Cory Johns <cjohns@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/c0629be4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c0629be4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c0629be4

Branch: refs/heads/db/6007
Commit: c0629be43185e8b9b389645fe9abc25605e6795f
Parents: 57fadd1
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Fri Apr 26 19:49:30 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Fri Apr 26 20:00:28 2013 +0000

----------------------------------------------------------------------
 Allura/allura/config/middleware.py          |    6 +++++-
 Allura/allura/tests/functional/test_root.py |   13 +++++++++++++
 2 files changed, 18 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c0629be4/Allura/allura/config/middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/config/middleware.py b/Allura/allura/config/middleware.py
index 09849a1..5bcb32b 100644
--- a/Allura/allura/config/middleware.py
+++ b/Allura/allura/config/middleware.py
@@ -84,7 +84,11 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
         [pkg_resources.resource_filename('allura', 'etc/mime.types')]
         + mimetypes.knownfiles)
     patches.apply()
-    if asbool(app_conf.get('newrelic')):
+    try:
+        import newrelic
+    except ImportError:
+        pass
+    else:
         patches.newrelic()
     # Configure MongoDB
     ming.configure(**app_conf)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c0629be4/Allura/allura/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_root.py b/Allura/allura/tests/functional/test_root.py
index c38710f..707fb12 100644
--- a/Allura/allura/tests/functional/test_root.py
+++ b/Allura/allura/tests/functional/test_root.py
@@ -31,6 +31,8 @@ Please read http://pythonpaste.org/webtest/ for more information.
 from tg import config
 from nose.tools import assert_equal
 from ming.orm.ormsession import ThreadLocalORMSession
+import mock
+from IPython.testing.decorators import module_not_available, skipif
 
 from allura.tests import decorators as td
 from allura.tests import TestController
@@ -146,3 +148,14 @@ class TestRootController(TestController):
     def test_slash_redirect(self):
         r = self.app.get('/p',status=301)
         r = self.app.get('/p/',status=302)
+
+    @skipif(module_not_available('newrelic'))
+    def test_newrelic_set_transaction_name(self):
+        from allura.controllers.project import NeighborhoodController
+        with mock.patch('newrelic.agent.callable_name') as callable_name,\
+             mock.patch('newrelic.agent.set_transaction_name') as set_transaction_name:
+            callable_name.return_value = 'foo'
+            r = self.app.get('/p/')
+            arg = callable_name.call_args[0][0]
+            assert_equal(arg.undecorated, NeighborhoodController.index.undecorated)
+            set_transaction_name.assert_called_with('foo')


Mime
View raw message