Example #1
0
 def test_module_static_path_subdomain(self):
     app = flask.Flask(__name__)
     app.config['SERVER_NAME'] = 'example.com'
     from subdomaintestmodule import mod
     app.register_module(mod)
     c = app.test_client()
     rv = c.get('/static/hello.txt', 'http://foo.example.com/')
     assert rv.data.strip() == 'Hello Subdomain'
Example #2
0
 def test_module_static_path_subdomain(self):
     app = flask.Flask(__name__)
     app.config['SERVER_NAME'] = 'example.com'
     from subdomaintestmodule import mod
     app.register_module(mod)
     c = app.test_client()
     rv = c.get('/static/hello.txt', 'http://foo.example.com/')
     assert rv.data.strip() == 'Hello Subdomain'
Example #3
0
    def test_module_static_path_subdomain(self):
        app = flask.Flask(__name__)
        app.config["SERVER_NAME"] = "example.com"
        from subdomaintestmodule import mod

        app.register_module(mod)
        c = app.test_client()
        rv = c.get("/static/hello.txt", "http://foo.example.com/")
        assert rv.data.strip() == "Hello Subdomain"
Example #4
0
 def test_static_path_without_url_prefix(self):
     app = flask.Flask(__name__)
     app.config['SERVER_NAME'] = 'example.com'
     from testmodule import mod
     app.register_module(mod)
     c = app.test_client()
     f = 'hello.txt'
     rv = c.get('/static/' + f, 'http://example.com/')
     assert rv.data.strip() == 'Hello Maindomain'
     with app.test_request_context(base_url='http://example.com'):
         assert flask.url_for('static', filename=f) == '/static/' + f
         assert flask.url_for('static', filename=f, _external=True) \
             == 'http://example.com/static/' + f
Example #5
0
    def test_module_subdomain_support(self):
        app = flask.Flask(__name__)
        mod = flask.Module(__name__, 'test', subdomain='testing')
        app.config['SERVER_NAME'] = 'localhost'

        @mod.route('/test')
        def test():
            return 'Test'

        @mod.route('/outside', subdomain='xtesting')
        def bar():
            return 'Outside'

        app.register_module(mod)

        c = app.test_client()
        rv = c.get('/test', 'http://testing.localhost/')
        assert rv.data == 'Test'
        rv = c.get('/outside', 'http://xtesting.localhost/')
        assert rv.data == 'Outside'
Example #6
0
    def test_module_subdomain_support(self):
        app = flask.Flask(__name__)
        mod = flask.Module(__name__, "test", subdomain="testing")
        app.config["SERVER_NAME"] = "localhost"

        @mod.route("/test")
        def test():
            return "Test"

        @mod.route("/outside", subdomain="xtesting")
        def bar():
            return "Outside"

        app.register_module(mod)

        c = app.test_client()
        rv = c.get("/test", "http://testing.localhost/")
        assert rv.data == "Test"
        rv = c.get("/outside", "http://xtesting.localhost/")
        assert rv.data == "Outside"
Example #7
0
    def test_module_subdomain_support(self):
        app = flask.Flask(__name__)
        mod = flask.Module(__name__, 'test', subdomain='testing')
        app.config['SERVER_NAME'] = 'localhost'

        @mod.route('/test')
        def test():
            return 'Test'

        @mod.route('/outside', subdomain='xtesting')
        def bar():
            return 'Outside'

        app.register_module(mod)

        c = app.test_client()
        rv = c.get('/test', 'http://testing.localhost/')
        assert rv.data == 'Test'
        rv = c.get('/outside', 'http://xtesting.localhost/')
        assert rv.data == 'Outside'
Example #8
0
    def test_endpoint_decorator(self):
        from werkzeug.routing import Submount, Rule
        from flask import Module

        app = flask.Flask(__name__)
        app.url_map.add(Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")]))
        module = Module(__name__, __name__)

        @module.endpoint("bar")
        def bar():
            return "bar"

        @module.endpoint("index")
        def index():
            return "index"

        app.register_module(module)

        c = app.test_client()
        assert c.get("/foo/").data == "index"
        assert c.get("/foo/bar").data == "bar"
Example #9
0
    def test_endpoint_decorator(self):
        from werkzeug.routing import Submount, Rule
        from flask import Module

        app = flask.Flask(__name__)
        app.url_map.add(Submount('/foo', [
            Rule('/bar', endpoint='bar'),
            Rule('/', endpoint='index')
        ]))
        module = Module(__name__, __name__)

        @module.endpoint('bar')
        def bar():
            return 'bar'

        @module.endpoint('index')
        def index():
            return 'index'

        app.register_module(module)

        c = app.test_client()
        assert c.get('/foo/').data == 'index'
        assert c.get('/foo/bar').data == 'bar'