Пример #1
0
def test_route_good_matches_with_parameter_patterns(pattern, url,
                                                    expected_values):
    route = Route(pattern, mock_handler)
    match = route.match(url)

    assert match is not None
    assert match.values == expected_values
Пример #2
0
def test_route_good_matches(pattern, url, expected_values):
    route = Route(pattern, mock_handler)
    print(route.full_pattern)
    match = route.match(url)

    assert match is not None
    assert match.values == expected_values
Пример #3
0
    def test_route_handler_can_be_anything(self):
        def request_handler():
            pass

        def auth_handler():
            pass

        handler = MockHandler(request_handler, auth_handler)

        route = Route(b'/', handler)
        match = route.match(b'/')

        assert match is not None
        assert match.handler.request_handler is request_handler
        assert match.handler.auth_handler is auth_handler
Пример #4
0
    def test_route_bad_matches(self, pattern, url):
        route = Route(pattern, mock_handler)
        match = route.match(url)

        assert match is None
Пример #5
0
def test_route_bad_matches_with_parameter_patterns(pattern, url):
    route = Route(pattern, mock_handler)
    match = route.match(url)
    assert match is None