예제 #1
0
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()
예제 #2
0
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
예제 #3
0
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()
예제 #4
0
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
예제 #5
0
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
예제 #6
0
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
예제 #7
0
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')
예제 #8
0
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')
예제 #9
0
 def setup_class(cls):
     cls.app = make_wsgi()
     cls.ta = TestApp(cls.app)
     env.clear()
예제 #10
0
def setup_module():
    make_wsgi()
예제 #11
0
def setup_module():
    make_wsgi()
예제 #12
0
 def setup_class(cls):
     make_wsgi('WithTestSettings')
예제 #13
0
 def setup_class(cls):
     cls.app = make_wsgi('WithTestSettings')
     cls.ta = TestApp(cls.app)
     env.clear()
예제 #14
0
 def setup_class(cls):
     make_wsgi('WithTestSettings')
예제 #15
0
 def setup_class(cls):
     cls.app = make_wsgi('ForStaticFileTesting')
     cls.ta = TestApp(cls.app)
예제 #16
0
 def setup_class(cls):
     cls.app = make_wsgi('WithTestSettings')
     cls.ta = TestApp(cls.app)
     env.clear()
예제 #17
0
 def setup_class(cls):
     make_wsgi()
예제 #18
0
def setup_module():
    global ta
    wsgiapp = make_wsgi('WithTestSettings')
    ta = TestApp(wsgiapp)
예제 #19
0
 def setup_class(cls):
     cls.app = make_wsgi()
     cls.ta = TestApp(cls.app)
     env.clear()
예제 #20
0
 def setup_class(cls):
     cls.app = make_wsgi('ForStaticFileTesting')
     cls.ta = TestApp(cls.app)
예제 #21
0
 def setup_class(cls):
     make_wsgi()
예제 #22
0
def setup_module():
    global ta
    wsgiapp = make_wsgi('WithTestSettings')
    ta = TestApp(wsgiapp)