allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject allura git commit: Run monkey patches earlier, so they won't get missed due to earlier imports. Fix corresponding tests
Date Thu, 10 Dec 2015 12:10:22 GMT
Repository: allura
Updated Branches:
  refs/heads/master cb0f29396 -> 47b6504ea


Run monkey patches earlier, so they won't get missed due to earlier imports.  Fix corresponding
tests


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

Branch: refs/heads/master
Commit: 47b6504ea0a0af95cc255e4743c948f01261024e
Parents: cb0f293
Author: Dave Brondsema <dave@brondsema.net>
Authored: Mon Dec 7 20:36:08 2015 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Thu Dec 10 13:37:21 2015 +0200

----------------------------------------------------------------------
 Allura/allura/config/middleware.py              | 20 ++++++++++++--------
 .../forgeblog/tests/functional/test_root.py     |  6 +++---
 .../tests/functional/test_controllers.py        |  2 +-
 .../forgetracker/tests/functional/test_root.py  | 10 +++++-----
 .../forgewiki/tests/functional/test_root.py     | 16 ++++++++--------
 5 files changed, 29 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/47b6504e/Allura/allura/config/middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/config/middleware.py b/Allura/allura/config/middleware.py
index fd137c2..7f2fb4c 100644
--- a/Allura/allura/config/middleware.py
+++ b/Allura/allura/config/middleware.py
@@ -37,6 +37,17 @@ import formencode
 import ming
 from ming.orm.middleware import MingMiddleware
 
+# Must apply patches before other Allura imports to ensure all the patches are effective.
+# This file gets imported from paste/deploy/loadwsgi.py pretty early in the app execution
+from allura.lib import patches
+patches.apply()
+try:
+    import newrelic
+except ImportError:
+    pass
+else:
+    patches.newrelic()
+
 from allura.config.app_cfg import base_config
 from allura.config.environment import load_environment
 from allura.config.app_cfg import ForgeConfig
@@ -47,7 +58,6 @@ from allura.lib.custom_middleware import CSRFMiddleware
 from allura.lib.custom_middleware import CORSMiddleware
 from allura.lib.custom_middleware import LoginRedirectMiddleware
 from allura.lib.custom_middleware import RememberLoginMiddleware
-from allura.lib import patches
 from allura.lib import helpers as h
 
 __all__ = ['make_app']
@@ -87,13 +97,7 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
     mimetypes.init(
         [pkg_resources.resource_filename('allura', 'etc/mime.types')]
         + mimetypes.knownfiles)
-    patches.apply()
-    try:
-        import newrelic
-    except ImportError:
-        pass
-    else:
-        patches.newrelic()
+
     # Configure MongoDB
     ming.configure(**app_conf)
 

http://git-wip-us.apache.org/repos/asf/allura/blob/47b6504e/ForgeBlog/forgeblog/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/functional/test_root.py b/ForgeBlog/forgeblog/tests/functional/test_root.py
index 6bc530e..ca6dc03 100644
--- a/ForgeBlog/forgeblog/tests/functional/test_root.py
+++ b/ForgeBlog/forgeblog/tests/functional/test_root.py
@@ -102,7 +102,7 @@ class Test(TestController):
 
     def test_root_new_search(self):
         self._post()
-        response = self.app.get('/blog/search?q=see')
+        response = self.app.get('/blog/search/?q=see')
         assert 'Search' in response
 
     def test_paging(self):
@@ -178,8 +178,8 @@ class Test(TestController):
         # two revisions are shown
         assert '2 by Test Admin' in response
         assert '1 by Test Admin' in response
-        self.app.get('/blog/%s/my-post?version=1' % d)
-        self.app.get('/blog/%s/my-post?version=foo' % d, status=404)
+        self.app.get('/blog/%s/my-post/?version=1' % d)
+        self.app.get('/blog/%s/my-post/?version=foo' % d, status=404)
 
     def test_post_diff(self):
         self._post()

http://git-wip-us.apache.org/repos/asf/allura/blob/47b6504e/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 173a82a..5f68409 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -625,7 +625,7 @@ class TestFork(_TestCase):
 
     def test_merge_request_detail_noslash(self):
         self._request_merge()
-        r = self.app.get('/p/test/src-git/merge-requests/1', status=302)
+        r = self.app.get('/p/test/src-git/merge-requests/1', status=301)
         assert_equal(r.location, 'http://localhost/p/test/src-git/merge-requests/1/')
 
     def test_merge_request_with_deleted_repo(self):

http://git-wip-us.apache.org/repos/asf/allura/blob/47b6504e/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 9cbfd74..46e6316 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1353,7 +1353,7 @@ class TestFunctionalController(TrackerTestController):
         ThreadLocalORMSession.flush_all()
         for ext in ['', '.rss', '.atom']:
             assert '<title>test first ticket</title>' in \
-                   self.app.get('/p/test/bugs/search_feed%s?q=test' % ext)
+                   self.app.get('/p/test/bugs/search_feed%s/?q=test' % ext)
 
     def test_search_current_user(self):
         self.new_ticket(summary='test first ticket')
@@ -2768,7 +2768,7 @@ class TestHelpTextOptions(TrackerTestController):
             search_txt='*bar*')
         r = self.app.get('/bugs/')
         assert '<em>bar</em>' in r
-        r = self.app.get('/bugs/search', params=dict(q='test'))
+        r = self.app.get('/bugs/search/', params=dict(q='test'))
         assert '<em>bar</em>' in r
         r = self.app.get('/bugs/milestone/1.0/')
         assert '<em>bar</em>' in r
@@ -2779,7 +2779,7 @@ class TestHelpTextOptions(TrackerTestController):
         r = self.app.get('/bugs/')
         assert len(
             r.html.findAll(attrs=dict(id='search-ticket-help-msg'))) == 0
-        r = self.app.get('/bugs/search', params=dict(q='test'))
+        r = self.app.get('/bugs/search/', params=dict(q='test'))
         assert len(
             r.html.findAll(attrs=dict(id='search-ticket-help-msg'))) == 0
         r = self.app.get('/bugs/milestone/1.0/')
@@ -2803,12 +2803,12 @@ class test_show_default_fields(TrackerTestController):
         assert '<td>Labels</td> <td><input type="checkbox" name="labels"
></td>' in r
         self.new_ticket(summary='test')
         M.MonQTask.run_ready()
-        r = self.app.get('/bugs/search', params=dict(q='test'))
+        r = self.app.get('/bugs/search/', params=dict(q='test'))
         assert '<td><a href="/p/test/bugs/1/">1</a></td>' in r
         p = M.Project.query.get(shortname='test')
         app = p.app_instance('bugs')
         app.globals.show_in_search['ticket_num'] = False
-        r = self.app.get('/bugs/search', params=dict(q='test'))
+        r = self.app.get('/bugs/search/', params=dict(q='test'))
         assert '<td><a href="/p/test/bugs/1/">1</a></td>' not in
r
         self.app.post('/admin/bugs/allow_default_field',
                       params={'status': 'on'})

http://git-wip-us.apache.org/repos/asf/allura/blob/47b6504e/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index c1886cf..9a88fd1 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -78,7 +78,7 @@ class TestRootController(TestController):
 
     def test_root_new_search(self):
         self.app.get(h.urlquote(u'/wiki/tést/'))
-        response = self.app.get('/wiki/search?q=' + h.urlquote(u'tést'))
+        response = self.app.get('/wiki/search/?q=' + h.urlquote(u'tést'))
         assert u'Search wiki: tést' in response
 
     def test_feed(self):
@@ -87,14 +87,14 @@ class TestRootController(TestController):
 
     @patch('allura.lib.search.search')
     def test_search(self, search):
-        r = self.app.get('/wiki/search?q=test')
+        r = self.app.get('/wiki/search/?q=test')
         assert_in(
-            '<a href="/wiki/search?q=test&amp;sort=score+asc" class="strong">relevance</a>',
r)
+            '<a href="/wiki/search/?q=test&amp;sort=score+asc" class="strong">relevance</a>',
r)
         assert_in(
-            '<a href="/wiki/search?q=test&amp;sort=mod_date_dt+desc" class="">date</a>',
r)
+            '<a href="/wiki/search/?q=test&amp;sort=mod_date_dt+desc" class="">date</a>',
r)
 
         p = M.Project.query.get(shortname='test')
-        r = self.app.get('/wiki/search?q=test&sort=score+asc')
+        r = self.app.get('/wiki/search/?q=test&sort=score+asc')
         solr_query = {
             'short_timeout': True,
             'ignore_errors': False,
@@ -118,14 +118,14 @@ class TestRootController(TestController):
         search.assert_called_with('test', **solr_query)
 
         r = self.app.get(
-            '/wiki/search?q=test&search_comments=on&history=on&sort=mod_date_dt+desc')
+            '/wiki/search/?q=test&search_comments=on&history=on&sort=mod_date_dt+desc')
         solr_query['fq'][
             3] = 'type_s:("WikiPage" OR "WikiPage Snapshot" OR "Post")'
         solr_query['fq'].remove('is_history_b:False')
         solr_query['sort'] = 'mod_date_dt desc'
         search.assert_called_with('test', **solr_query)
 
-        r = self.app.get('/wiki/search?q=test&parser=standard')
+        r = self.app.get('/wiki/search/?q=test&parser=standard')
         solr_query['sort'] = 'score desc'
         solr_query['fq'][3] = 'type_s:("WikiPage" OR "WikiPage Snapshot")'
         solr_query['fq'].append('is_history_b:False')
@@ -135,7 +135,7 @@ class TestRootController(TestController):
         search.assert_called_with('test', **solr_query)
 
     def test_search_help(self):
-        r = self.app.get('/wiki/search?q=test')
+        r = self.app.get('/wiki/search/?q=test')
         btn = r.html.find('a', attrs={'class': 'icon btn search_help_modal'})
         assert btn is not None, "Can't find a help button"
         div = r.html.find('div', attrs={'id': 'lightbox_search_help_modal'})


Mime
View raw message