Beispiel #1
0
 def test_deep_routes(self):
     routes = list(_reduce_routes(test_routes.deep()))
     for i, expected in enumerate(EXPECTED_DEEP_RESULTS):
         route = routes[i]
         assert route.endpoint == expected[0], route.endpoint
         assert route.full_rule == expected[1], route.endpoint
         assert route.methods == expected[2], route.endpoint
Beispiel #2
0
 def test_explicit_routes(self):
     routes = list(_reduce_routes(test_routes.explicit_routes()))
     for i, expected in enumerate(t for t in EXPECTED_RESULTS
                                  if 'foobar' not in t[0]):
         route = routes[i]
         assert route.endpoint == expected[0], (route.endpoint, expected[0])
         assert route.full_rule == expected[1], route.endpoint
         assert route.methods == expected[2], route.endpoint
    def test_get_explicit_routes(self, app, hook: RegisterRoutesHook):
        hook.run_hook(app, [AppBundle()])
        discovered_routes = list(
            _reduce_routes(hook.get_explicit_routes(AppBundle())))
        assert len(discovered_routes) == 5
        for route in discovered_routes:
            assert isinstance(route, Route)

        registered_routes = hook.bundle.endpoints.values()
        assert len(registered_routes) == len(app.url_map._rules) == 4

        with pytest.raises(AttributeError) as e:
            hook.get_explicit_routes(EmptyBundle())
        assert 'Could not find a variable named `routes`' in str(e)