2
from unittest import TestCase
4
from paste.fixture import TestApp
5
from paste.httpexceptions import HTTPMovedPermanently
6
from paste.registry import RegistryManager
9
from pylons.controllers import WSGIController
10
from pylons.controllers.util import etag_cache
11
from pylons.decorators import jsonify as orig_jsonify
12
from pylons.util import ContextObj
14
from __init__ import ControllerWrap, SetupCacheGlobal, TestWSGIController
16
class SimpleTestWSGIController(TestWSGIController):
18
def __init__(self, *args, **kargs):
19
TestWSGIController.__init__(self, *args, **kargs)
21
app = ControllerWrap(self.wsgi_app)
22
app = self.sap = SetupCacheGlobal(app, self.baseenviron)
23
app = RegistryManager(app)
24
self.app = TestApp(app)
27
TestWSGIController.setUp(self)
28
self.baseenviron.update(self.environ)
31
class HelpersController(WSGIController):
33
import pylons.controllers.util
34
self.helpers = pylons.controllers.util
37
self.helpers.abort(404)
40
self.helpers.etag_cache('hello')
43
def redirect_to(self):
44
self.helpers.redirect_to('/etag_cache')
46
class TestDeprecatedHelpers(SimpleTestWSGIController):
47
wsgi_app = HelpersController()
50
warnings.simplefilter('ignore', DeprecationWarning)
51
self.wsgi_app.imports()
52
warnings.simplefilter('error', DeprecationWarning)
55
warnings.simplefilter('always', DeprecationWarning)
59
class MiscLegacyController(WSGIController):
61
def legacy_httpexception(self):
62
raise HTTPMovedPermanently('/elsewhere')
64
def legacy_etag_cache(self):
66
response = etag_cache('test')
67
response.body = 'from etag_cache'
71
class TestMiscLegacy(SimpleTestWSGIController):
72
wsgi_app = MiscLegacyController
75
SimpleTestWSGIController.setUp(self)
76
warnings.simplefilter('error', DeprecationWarning)
79
SimpleTestWSGIController.tearDown(self)
80
warnings.simplefilter('always', DeprecationWarning)
82
# def test_legacy_return_etag_cache(self):
83
# warnings.simplefilter('always', DeprecationWarning)
85
# self.baseenviron['pylons.routes_dict']['action'] = 'legacy_etag_cache'
86
# response = self.app.get('/')
87
# assert 'from etag_cache' in response