You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2015/11/03 20:30:54 UTC

[2/4] allura git commit: [#7919] make tests more robust (particularly, running various test_neighborhood.py tests on their own)

[#7919] make tests more robust (particularly, running various test_neighborhood.py tests on their own)


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

Branch: refs/heads/db/7919
Commit: 245413a9d9fd7962f7cf540ec3e83b71eccc8fc7
Parents: 9637c4e
Author: Dave Brondsema <da...@brondsema.net>
Authored: Tue Nov 3 11:44:10 2015 -0500
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Tue Nov 3 11:44:33 2015 -0500

----------------------------------------------------------------------
 Allura/allura/lib/utils.py                        | 8 +++++++-
 Allura/allura/tests/functional/test_admin.py      | 5 ++++-
 AlluraTest/alluratest/controller.py               | 2 +-
 ForgeBlog/forgeblog/tests/functional/test_rest.py | 4 ++--
 4 files changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/245413a9/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index eb273d2..b2dd0c2 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -383,7 +383,13 @@ class AntiSpam(object):
                 new_params = cls.validate_request(params=params)
                 params.update(new_params)
             except (ValueError, TypeError, binascii.Error):
-                raise Invalid(error_msg, params, None)
+                testing = pylons.request.environ.get('paste.testing', False)
+                if testing:
+                    # re-raise so we can see problems more easily
+                    raise
+                else:
+                    # regular antispam failure handling
+                    raise Invalid(error_msg, params, None)
         return before_validate(antispam_hook)
 
 

http://git-wip-us.apache.org/repos/asf/allura/blob/245413a9/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 16590d7..0b9a857 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -39,6 +39,7 @@ from alluratest.controller import TestRestApiBase, setup_trove_categories
 from allura import model as M
 from allura.app import SitemapEntry
 from allura.lib.plugin import AdminExtension
+from allura.lib import helpers as h
 from allura.ext.admin.admin_main import AdminApp
 
 from forgetracker.tracker_main import ForgeTrackerApp
@@ -1284,7 +1285,9 @@ class TestRestInstallTool(TestRestApiBase):
                 'mount_point': 'ticketsmount1',
                 'mount_label': 'tickets_label1'
             }
-            c.project.install_app('tickets', mount_point=data['mount_point'])
+            project = M.Project.query.get(shortname='test')
+            with h.push_config(c, user=M.User.query.get()):
+                project.install_app('tickets', mount_point=data['mount_point'])
             r = self.api_post('/rest/p/test/admin/install_tool/', **data)
             assert_equals(r.json['success'], False)
             assert_equals(r.json['info'], 'Mount point already exists.')

http://git-wip-us.apache.org/repos/asf/allura/blob/245413a9/AlluraTest/alluratest/controller.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/controller.py b/AlluraTest/alluratest/controller.py
index babf262..6ce1b71 100644
--- a/AlluraTest/alluratest/controller.py
+++ b/AlluraTest/alluratest/controller.py
@@ -155,6 +155,7 @@ class TestController(object):
         """Method called by nose before running each test"""
         self.app = ValidatingTestApp(
             setup_functional_test(app_name=self.application_under_test))
+        self.app.extra_environ = {'REMOTE_ADDR': '127.0.0.1'}  # remote_addr needed by AntiSpam
         if self.validate_skip:
             self.app.validate_skip = self.validate_skip
         if asbool(tg.config.get('smtp.mock')):
@@ -196,7 +197,6 @@ class TestRestApiBase(TestController):
 
     def setUp(self):
         super(TestRestApiBase, self).setUp()
-        setup_global_objects()
         self._use_token = None
         self._token_cache = {}
 

http://git-wip-us.apache.org/repos/asf/allura/blob/245413a9/ForgeBlog/forgeblog/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/functional/test_rest.py b/ForgeBlog/forgeblog/tests/functional/test_rest.py
index e7a9d7b..ed3e9fc 100644
--- a/ForgeBlog/forgeblog/tests/functional/test_rest.py
+++ b/ForgeBlog/forgeblog/tests/functional/test_rest.py
@@ -18,7 +18,7 @@
 #       under the License.
 from datetime import date
 
-from nose.tools import assert_equal
+from nose.tools import assert_equal, assert_in
 from allura.lib import helpers as h
 from allura.tests import decorators as td
 from allura import model as M
@@ -51,7 +51,7 @@ class TestBlogApi(TestRestApiBase):
         url = '/rest' + BM.BlogPost.query.find().first().url()
         r = self.api_get('/rest/p/test/blog/')
         assert_equal(r.json['posts'][0]['title'], 'test')
-        assert_equal(r.json['posts'][0]['url'], h.absurl(url))
+        assert_in(url, r.json['posts'][0]['url'])
 
         r = self.api_get(url)
         assert_equal(r.json['title'], data['title'])