Exemplo n.º 1
0
    def test_add_to_app(self, _import_module):
        foo = mock.MagicMock(__name__='foo',
                             methods=[
                                 'GET',
                             ],
                             return_value='foo')
        bar = mock.MagicMock(__name__='bar',
                             methods=[
                                 'GET',
                             ],
                             return_value='bar')

        routes = [
            default.Functional('/foo', foo, 'foo'),
            default.Functional('/bar', bar, 'bar'),
        ]

        _import_module.side_effect = [
            mock.MagicMock(routes=routes),
        ]

        route = default.Blueprint('foo', 'foo.bar')

        with mock.patch('flask.helpers.pkgutil.get_loader'):
            route.add_to_app(self.app)

        self.assertEqual(url_for('foo.foo'), '/foo')
        self.assertEqual(url_for('foo.bar'), '/bar')
Exemplo n.º 2
0
    def test_bluepint_returns_blurprint(self, _get_root_path):
        blueprint = Blueprint('foo', __name__)
        route = default.Blueprint(blueprint)

        self.assertIsInstance(route.blueprint(), Blueprint)
        self.assertEqual(route.blueprint(), blueprint)
Exemplo n.º 3
0
    def test_bluepint_creates_blurprint(self, _get_root_path):
        route = default.Blueprint('foo', 'foo.bar')

        self.assertIsInstance(route.blueprint(), Blueprint)
Exemplo n.º 4
0
    def test_routes_module_path(self):
        route = default.Blueprint('foo', 'foo.bar')

        self.assertEqual(route.routes_module, 'foo.bar.routes')
Exemplo n.º 5
0
    def test_endpoint_prefix(self, _get_root_path):
        route = default.Blueprint('bar', 'foo.bar')
        blueprint = route.blueprint(endpoint='foo.')

        self.assertEqual(blueprint.name, 'foo.bar')
Exemplo n.º 6
0
    def test_url_prefix(self, _get_root_path):
        route = default.Blueprint('foo', 'foo.bar')
        blueprint = route.blueprint(url_prefix='/foo')

        self.assertEqual(blueprint.url_prefix, '/foo')
Exemplo n.º 7
0
# -*- coding: utf-8 -*-
# Created by richie at 2018/10/15

from .main import main as blueprint_main
from flask_via.routers import default

routes = [
    default.Blueprint(blueprint_main),
]