• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

修訂047b5d1abd2d9d561085d9d4d14952978115561b (tree)
時間2011-04-30 02:08:35
作者Rick Copeland <rcopeland@geek...>
CommiterRick Copeland

Log Message

[#1831] Still fixing tests

Signed-off-by: Rick Copeland <rcopeland@geek.net>

Change Summary

差異

--- a/Allura/allura/lib/patches.py
+++ /dev/null
@@ -1,40 +0,0 @@
1-import webob
2-import tg.decorators
3-from pylons import request
4-
5-from allura.lib import helpers as h
6-
7-def apply():
8- old_lookup_template_engine = tg.decorators.Decoration.lookup_template_engine
9-
10- @h.monkeypatch(tg.decorators.Decoration)
11- def lookup_template_engine(self, request):
12- '''Wrapper to handle totally borked-up HTTP-ACCEPT headers'''
13- try:
14- return old_lookup_template_engine(self, request)
15- except:
16- pass
17- environ = dict(request.environ, HTTP_ACCEPT='*/*')
18- request = webob.Request(environ)
19- return old_lookup_template_engine(self, request)
20-
21- @h.monkeypatch(tg, tg.decorators)
22- def override_template(controller, template):
23- '''Copy-pasted patch to allow multiple colons in a template spec'''
24- if hasattr(controller, 'decoration'):
25- decoration = controller.decoration
26- else:
27- return
28- if hasattr(decoration, 'engines'):
29- engines = decoration.engines
30- else:
31- return
32-
33- for content_type, content_engine in engines.iteritems():
34- template = template.split(':', 1)
35- template.extend(content_engine[2:])
36- try:
37- override_mapping = request._override_mapping
38- except AttributeError:
39- override_mapping = request._override_mapping = {}
40- override_mapping[controller.im_func] = {content_type: template}
--- a/Allura/tg/__init__.py
+++ b/Allura/tg/__init__.py
@@ -1,3 +1,3 @@
1-from shim import *
2-from tg_globals import c, g, response, request, config, session, environ
3-from decorators import expose, validate
1+from .tg_globals import c, g, response, request, config, session, environ
2+from .shim import redirect, url
3+from .decorators import expose, validate
--- a/Allura/tg/shim.py
+++ b/Allura/tg/shim.py
@@ -6,12 +6,13 @@ import urllib
66 import tg
77 import pkg_resources
88 import pyramid.response
9-from webob import exc
109 from formencode import Invalid
10+from webob import exc
1111
1212 from decorators import Decoration
1313
1414 from . import tg_globals
15+from .traversal import Resource
1516
1617 __all__ = [ 'redirect', 'url' ]
1718
@@ -42,33 +43,6 @@ class RootFactory(object):
4243 if hasattr(root_obj, '_cleanup_request'):
4344 root_obj._cleanup_request()
4445
45-class Resource(object):
46-
47- def __init__(self, controller):
48- self._controller = controller
49- sec = getattr(controller, '_check_security', lambda:None)
50- sec()
51-
52- def __getitem__(self, name):
53- name = name.encode('utf-8')
54- try:
55- remainder = []
56- next = getattr(self._controller, name, None)
57- if next is None:
58- next, remainder = self._controller._lookup(name)
59- assert not remainder, 'Weird _lookup not supported'
60- return Resource(next)
61- except exc.HTTPNotFound:
62- return None
63-
64- def get_deco(self):
65- func = self._controller
66- deco = Decoration.get(func, False)
67- if deco is None:
68- func = getattr(func, 'index', None)
69- deco = Decoration.get(func, False)
70- return deco, func
71-
7246 def tg_view(context, request):
7347 deco, func = context.get_deco()
7448 try:
--- /dev/null
+++ b/Allura/tg/traversal.py
@@ -0,0 +1,46 @@
1+'''Code to support pylons-style traversal on top of TG-style _lookup'''
2+from decorators import Decoration
3+
4+class Resource(object):
5+
6+ def __init__(self, controller):
7+ self._controller = controller
8+ sec = getattr(controller, '_check_security', lambda:None)
9+ sec()
10+
11+ def __getitem__(self, name):
12+ name = name.encode('utf-8')
13+ remainder = []
14+ next = getattr(self._controller, name, None)
15+ if next is None:
16+ try:
17+ next, remainder = self._controller._lookup(name)
18+ except TypeError, te:
19+ if 'takes at least' not in te.args[0]: raise
20+ return CurriedResource(self._controller, [name])
21+ assert not remainder, 'Weird _lookup not supported'
22+ return Resource(next)
23+
24+ def get_deco(self):
25+ func = self._controller
26+ deco = Decoration.get(func, False)
27+ if deco is None:
28+ func = getattr(func, 'index', None)
29+ deco = Decoration.get(func, False)
30+ return deco, func
31+
32+class CurriedResource(object):
33+
34+ def __init__(self, controller, path):
35+ self._controller = controller
36+ self._path = path
37+
38+ def __getitem__(self, name):
39+ new_path = self._path + [name]
40+ try:
41+ next, remainder = self._controller._lookup(*new_path)
42+ assert not remainder, 'Weird _lookup not supported'
43+ return Resource(next)
44+ except TypeError, te:
45+ if 'takes at least' not in te.args[0]: raise
46+ return CurriedResource(self._controller, new_path)
--- a/AlluraTesting/alluratest/test_syntax.py
+++ b/AlluraTesting/alluratest/test_syntax.py
@@ -50,6 +50,8 @@ def test_pyflakes():
5050
5151 if error:
5252 raise Exception('pyflakes failure, see stdout')
53+ if run(find_py + " | grep -v '/migrations/' | xargs pyflakes | grep -v '" + "' | grep -v '".join(skips) + "'") != 1:
54+ raise Exception('pyflakes failure')
5355
5456 def test_no_now():
5557 if run(find_py + " | xargs grep '\.now(' ") not in [1,123]:
--- a/ForgeBlog/forgeblog/tests/functional/test_root.py
+++ b/ForgeBlog/forgeblog/tests/functional/test_root.py
@@ -56,8 +56,8 @@ class TestRootController(TestController):
5656 # two revisions are shown
5757 assert '2 by Test Admin' in response
5858 assert '1 by Test Admin' in response
59- self.app.get('/blog/2010/08/my-post?version=1')
60- self.app.get('/blog/2010/08/my-post?version=foo', status=404)
59+ self.app.get('/blog/2010/08/my-post/?version=1')
60+ self.app.get('/blog/2010/08/my-post/?version=foo', status=404)
6161
6262 def test_post_diff(self):
6363 self._post()
--- a/ForgeBlog/forgeblog/tests/test_roles.py
+++ b/ForgeBlog/forgeblog/tests/test_roles.py
@@ -1,4 +1,4 @@
1-from pylons import c, g
1+from tg import c, g
22
33 from alluratest.controller import setup_basic_test, setup_global_objects
44 from allura import model as M
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -6,7 +6,7 @@ from email.mime.image import MIMEImage
66 from email.mime.multipart import MIMEMultipart
77
88 import pkg_resources
9-from pylons import g, c
9+from tg import c
1010 from nose.tools import assert_equal
1111
1212 from allura import model as M
--- a/ForgeDiscussion/forgediscussion/tests/test_forum_roles.py
+++ b/ForgeDiscussion/forgediscussion/tests/test_forum_roles.py
@@ -1,4 +1,4 @@
1-from pylons import c, g
1+from tg import c, g
22
33 from alluratest.controller import setup_basic_test, setup_global_objects
44 from allura import model as M
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -1,6 +1,6 @@
11 import tg
22 import pkg_resources
3-from pylons import c
3+from tg import c
44 from ming.orm import ThreadLocalORMSession
55
66 from allura import model as M
--- a/ForgeGit/forgegit/tests/test_git_app.py
+++ b/ForgeGit/forgegit/tests/test_git_app.py
@@ -1,7 +1,7 @@
11 import unittest
22 from nose.tools import assert_equals
33
4-from pylons import c, g
4+from tg import c
55 from ming.orm import ThreadLocalORMSession
66
77 from alluratest.controller import setup_basic_test, setup_global_objects
--- a/ForgeHg/forgehg/tests/functional/test_controllers.py
+++ b/ForgeHg/forgehg/tests/functional/test_controllers.py
@@ -1,7 +1,5 @@
1-import os
2-
31 import pkg_resources
4-from pylons import c
2+from tg import c
53 from ming.orm import ThreadLocalORMSession
64
75 from allura.lib import helpers as h
--- a/ForgeHg/forgehg/tests/test_hg_app.py
+++ b/ForgeHg/forgehg/tests/test_hg_app.py
@@ -1,7 +1,7 @@
11 import unittest
22 from nose.tools import assert_equals
33
4-from pylons import c
4+from tg import c
55 from ming.orm import ThreadLocalORMSession
66
77 from alluratest.controller import setup_basic_test, setup_global_objects
--- a/ForgeHg/forgehg/tests/test_tasks.py
+++ b/ForgeHg/forgehg/tests/test_tasks.py
@@ -1,7 +1,5 @@
11 import unittest
22
3-from pylons import c, g
4-
53 from ming.orm import ThreadLocalORMSession
64
75 from alluratest.controller import setup_basic_test, setup_global_objects
--- a/ForgeSVN/forgesvn/tests/functional/test_controllers.py
+++ b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
@@ -1,7 +1,5 @@
1-import os
2-
31 import pkg_resources
4-from pylons import c
2+from tg import c
53 from ming.orm import ThreadLocalORMSession
64
75 from allura.lib import helpers as h
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -3,8 +3,6 @@ import shutil
33 import unittest
44 import pkg_resources
55
6-from pylons import c
7-
86 from ming.orm import ThreadLocalORMSession
97
108 from alluratest.controller import setup_basic_test, setup_global_objects
--- a/ForgeSVN/forgesvn/tests/test_svn_app.py
+++ b/ForgeSVN/forgesvn/tests/test_svn_app.py
@@ -1,15 +1,11 @@
1-import os
2-import shutil
31 import unittest
4-import pkg_resources
52 from nose.tools import assert_equals
63
7-from pylons import c, g
4+from tg import c
85 from ming.orm import ThreadLocalORMSession
96
107 from alluratest.controller import setup_basic_test, setup_global_objects
118 from allura.lib import helpers as h
12-from forgesvn import model as SM
139
1410
1511 class TestSVNApp(unittest.TestCase):
--- a/ForgeTracker/forgetracker/tests/functional/test_rest.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_rest.py
@@ -1,11 +1,7 @@
1-from pylons import c
2-from ming.orm import session
1+from tg import c
32
4-from allura import model as M
53 from allura.lib import helpers as h
6-from alluratest.controller import TestController, TestRestApiBase
7-from forgetracker import model as TM
8-
4+from alluratest.controller import TestRestApiBase
95
106 class TestTrackerApiBase(TestRestApiBase):
117
--- a/ForgeTracker/forgetracker/tests/test_tracker_roles.py
+++ b/ForgeTracker/forgetracker/tests/test_tracker_roles.py
@@ -1,4 +1,4 @@
1-from pylons import c, g
1+from tg import c, g
22
33 from alluratest.controller import setup_basic_test, setup_global_objects
44 from allura import model as M
--- a/ForgeTracker/forgetracker/tests/unit/__init__.py
+++ b/ForgeTracker/forgetracker/tests/unit/__init__.py
@@ -1,4 +1,4 @@
1-from pylons import c
1+from tg import c
22 from ming.orm.ormsession import ThreadLocalORMSession
33
44 from allura.websetup import bootstrap
--- a/ForgeTracker/forgetracker/tests/unit/test_globals_model.py
+++ b/ForgeTracker/forgetracker/tests/unit/test_globals_model.py
@@ -1,6 +1,6 @@
11 from forgetracker.model import Globals
22 from forgetracker.tests.unit import TrackerTestWithModel
3-from pylons import c
3+from tg import c
44 from allura.lib import helpers as h
55
66 from ming.orm.ormsession import ThreadLocalORMSession
--- a/ForgeTracker/forgetracker/tests/unit/test_root_controller.py
+++ b/ForgeTracker/forgetracker/tests/unit/test_root_controller.py
@@ -3,7 +3,7 @@ from ming.orm.ormsession import session
33
44 from allura.lib import helpers as h
55 from allura.model import User
6-from pylons import c
6+from tg import c
77 from forgetracker.tests.unit import TrackerTestWithModel
88 from forgetracker.model import Ticket, Globals
99 from forgetracker import tracker_main
--- a/ForgeTracker/forgetracker/tests/unit/test_ticket_custom_fields_form.py
+++ b/ForgeTracker/forgetracker/tests/unit/test_ticket_custom_fields_form.py
@@ -1,7 +1,7 @@
11 from ming.orm.ormsession import ThreadLocalORMSession
22 from ming.base import Object
33
4-from pylons import c
4+from tg import c
55
66 from forgetracker.tests.unit import TrackerTestWithModel
77 from forgetracker.widgets import ticket_form
--- a/ForgeTracker/forgetracker/tests/unit/test_ticket_form.py
+++ b/ForgeTracker/forgetracker/tests/unit/test_ticket_form.py
@@ -1,7 +1,7 @@
11 from mock import patch
22 from ming.orm.ormsession import ThreadLocalORMSession
33
4-from pylons import c
4+from tg import c
55
66 from forgetracker.tests.unit import TrackerTestWithModel
77 from forgetracker.widgets import ticket_form