def test_auto_copy(): env.clear() make_wsgi('AutoCopyStatic') # make sure at least one file is there from the static copies assert_contents('newlayout', path.join('newlayout', 'static', 'app', 'statictest.txt')) env.clear()
def test_component_settings(): make_wsgi() assert settings.components.news.foo == 1 eq_(settings.components.news.bar, 3) assert settings.components.pnoroutes.noroutes is True assert "<Rule '/fake/route' -> news:notthere>" in str(ag.route_map), ag.route_map
def test_component_settings(): make_wsgi() assert settings.components.news.foo == 1 eq_(settings.components.news.bar, 3) assert settings.components.pnoroutes.noroutes is True assert "<Rule '/fake/route' -> news:notthere>" in str( ag.route_map), ag.route_map
def test_bad_settings_profile(): try: make_wsgi('notthere') assert False except ValueError as e: assert 'settings profile "notthere" not found in this application' == str(e), e try: make_wsgi('AttributeErrorInSettings') assert False except AttributeError as e: assert "has no attribute 'notthere'" in str(e), e
def test_bad_settings_profile(): try: make_wsgi('notthere') assert False except ValueError as e: assert 'settings profile "notthere" not found in this application' == str( e), e try: make_wsgi('AttributeErrorInSettings') assert False except AttributeError as e: assert "has no attribute 'notthere'" in str(e), e
def test_environ_hooks(): tracker = [] class TestMiddleware(object): def __init__(self, app): self.app = app def __call__(self, environ, start_response): def request_setup(): rg.testattr = 'foo' tracker.append('reqs') def request_teardown(): tracker.append('reqt') def response_setup(): tracker.append('resps') def response_teardown(): tracker.append('respt') environ.setdefault('blazeweb.request_setup', []) environ.setdefault('blazeweb.request_teardown', []) environ.setdefault('blazeweb.response_cycle_setup', []) environ.setdefault('blazeweb.response_cycle_teardown', []) environ['blazeweb.request_setup'].append(request_setup) environ['blazeweb.request_teardown'].append(request_teardown) environ['blazeweb.response_cycle_setup'].append(response_setup) environ['blazeweb.response_cycle_teardown'].append( response_teardown) return self.app(environ, start_response) app = TestMiddleware(make_wsgi()) ta = TestApp(app) r = ta.get('/news') r.mustcontain('news index') eq_(tracker, ['reqs', 'resps', 'respt', 'reqt']) tracker = [] r = ta.get('/news/reqsetupattr') r.mustcontain('foo')
def test_environ_hooks(): tracker = [] class TestMiddleware(object): def __init__(self, app): self.app = app def __call__(self, environ, start_response): def request_setup(): rg.testattr = 'foo' tracker.append('reqs') def request_teardown(): tracker.append('reqt') def response_setup(): tracker.append('resps') def response_teardown(): tracker.append('respt') environ.setdefault('blazeweb.request_setup', []) environ.setdefault('blazeweb.request_teardown', []) environ.setdefault('blazeweb.response_cycle_setup', []) environ.setdefault('blazeweb.response_cycle_teardown', []) environ['blazeweb.request_setup'].append(request_setup) environ['blazeweb.request_teardown'].append(request_teardown) environ['blazeweb.response_cycle_setup'].append(response_setup) environ['blazeweb.response_cycle_teardown'].append(response_teardown) return self.app(environ, start_response) app = TestMiddleware(make_wsgi()) ta = TestApp(app) r = ta.get('/news') r.mustcontain('news index') eq_(tracker, ['reqs', 'resps', 'respt', 'reqt']) tracker = [] r = ta.get('/news/reqsetupattr') r.mustcontain('foo')
def setup_class(cls): cls.app = make_wsgi() cls.ta = TestApp(cls.app) env.clear()
def setup_module(): make_wsgi()
def setup_class(cls): make_wsgi('WithTestSettings')
def setup_class(cls): cls.app = make_wsgi('WithTestSettings') cls.ta = TestApp(cls.app) env.clear()
def setup_class(cls): cls.app = make_wsgi('ForStaticFileTesting') cls.ta = TestApp(cls.app)
def setup_class(cls): make_wsgi()
def setup_module(): global ta wsgiapp = make_wsgi('WithTestSettings') ta = TestApp(wsgiapp)