示例#1
0
    def test_it_requires_a_callable(self):
        with pytest.raises(ValueError):
            list(func('/fail'))

        with pytest.raises(ValueError):
            list(func('/fail', None))

        with pytest.raises(ValueError):
            list(func(None))

        with pytest.raises(ValueError):
            list(func(None, undecorated_view))
示例#2
0
 def test_it_works_with_decorated_view(self):
     route = list(func(decorated_view))[0]
     assert route.view_func == decorated_view
     assert route.rule == '/decorated-view'
     assert route.blueprint is None
     assert route.endpoint == 'tests.test_routes.decorated_view'
     assert route.defaults is None
     assert route.methods == ['GET']
     assert route.only_if is None
示例#3
0
 def test_override_rule_options_with_decorated_view(self):
     route = list(func('/b/<id>', decorated_view, blueprint=bp,
                       endpoint='overridden.endpoint',
                       defaults={'id': 1}, methods=['GET', 'POST'],
                       only_if='only_if'))[0]
     assert route.rule == '/b/<id>'
     assert route.view_func == decorated_view
     assert route.blueprint == bp
     assert route.endpoint == 'overridden.endpoint'
     assert route.defaults == {'id': 1}
     assert route.methods == ['GET', 'POST']
     assert route.only_if == 'only_if'
示例#4
0
 def test_it_does_not_mutate_existing_routes(self):
     route = list(func('/foo', decorated_view))[0]
     orig_route = getattr(decorated_view, FN_ROUTES_ATTR)[0]
     assert orig_route.endpoint == route.endpoint
     assert orig_route.rule == '/decorated-view'
     assert route.rule == '/foo'
示例#5
0
 def test_it_reuses_route_url_implicitly_matches(self):
     route = list(func(implicit_multi_route_view))[0]
     assert route.endpoint == 'default'
示例#6
0
 def test_it_reuses_route_if_url_matches_a_decorated_route(self):
     route = list(func('/first', multi_route_view, methods=['PUT']))[0]
     assert route.methods == ['PUT']
     assert route.endpoint == 'first'
示例#7
0
 def test_it_makes_new_route_if_decorated_with_multiple_other_routes(self):
     route = list(func(multi_route_view))[0]
     assert route.endpoint == 'tests.test_routes.multi_route_view'