def test_it_raises_if_no_routes_found(self):
        with pytest.raises(ImportError):
            # trying to import this.should.fail prints the zen of python!
            list(include('should.not.exist'))

        with pytest.raises(AttributeError):
            list(include('tests.bundles.controller.fixtures.routes'))

        with pytest.raises(AttributeError):
            list(include('tests.bundles.controller.fixtures.routes', attr='fail'))
 def test_it_does_not_include_excludes(self):
     routes = list(
         include('tests.bundles.controller.fixtures.other_routes',
                 exclude=['views.three']))
     assert len(routes) == 2
     assert routes[0].endpoint == 'views.one'
     assert routes[1].endpoint == 'views.two'
 def test_it_only_includes_only(self):
     routes = list(
         include('tests.bundles.controller.fixtures.other_routes',
                 only=['views.one']))
     assert len(routes) == 1
     assert routes[0].endpoint == 'views.one'
Exemple #4
0
from flask_unchained.bundles.controller.routes import func, include

from .views import view_one, view_two


routes = lambda: [
    func(view_one),
    func(view_two),
    include('tests.bundles.controller.fixtures.vendor_bundle.routes'),
    include('tests.bundles.controller.fixtures.warning_bundle.routes'),
]