Пример #1
0
def test_follow_redirects_filtered_by_site_allowed():
    redirected = "/redirected"
    link = "/resource"
    with start_server(Response(link, 301, {"Location": redirected}),
                      Response(redirected, 200, {})) as url:
        hosts = [socket.gethostname()]
        assert url(redirected) == follow_redirects(url(link), hosts)
Пример #2
0
def test_follow_redirects_link_to_last_available():
    unavailable = "/unavailable"
    link = "/resource"
    with start_server(
        Response(link, 301, {"Location": unavailable}),
        Response(unavailable, 404, {})) as url:
        assert url(unavailable) == follow_redirects(url(link))
Пример #3
0
def test_follow_redirects_redirected_link():
    redirected = "/redirected"
    link = "/resource"
    with start_server(
        Response(link, 301, {"Location": redirected}),
        Response(redirected, 200, {})) as url:
        assert url(redirected) == follow_redirects(url(link))
Пример #4
0
def test_follow_redirects_filtered_by_site_allowed():
    redirected = "/redirected"
    link = "/resource"
    with start_server(
        Response(link, 301, {"Location": redirected}),
        Response(redirected, 200, {})) as url:
        hosts = [socket.gethostname()]
        assert url(redirected) == follow_redirects(url(link), hosts)
Пример #5
0
def test_follow_redirects_filtered_by_site_after_redirect():
    link = "/resource"
    redirected = "/redirected"
    filtered = "http://dont-follow/"
    with start_server(Response(link, 301, {"Location": redirected}),
                      Response(redirected, 301,
                               {"Location": filtered})) as url:
        hosts = [socket.gethostname()]
        assert filtered == follow_redirects(url(link), hosts)
Пример #6
0
def test_follow_redirects_filtered_by_site_after_redirect():
    link = "/resource"
    redirected = "/redirected"
    filtered = "http://dont-follow/"
    with start_server(
        Response(link, 301, {"Location": redirected}),
        Response(redirected, 301, {"Location": filtered})) as url:
        hosts = [socket.gethostname()]
        assert filtered == follow_redirects(url(link), hosts)
Пример #7
0
def test_follow_redirects_filtered_by_site():
    link = "/resource"
    with start_server() as url:
        assert url(link) == follow_redirects(url(link), ["other_host"])
Пример #8
0
def test_follow_redirects_link_to_nowhere():
    unavailable = "http://links.nowhere/"
    link = "/resource"
    with start_server(Response(link, 301, {"Location": unavailable})) as url:
        assert unavailable == follow_redirects(url(link))
Пример #9
0
def test_follow_redirects_no_where():
    link = "http://links.nowhere/"
    assert link == follow_redirects(link)
Пример #10
0
def test_follow_redirects_link_to_last_available():
    unavailable = "/unavailable"
    link = "/resource"
    with start_server(Response(link, 301, {"Location": unavailable}),
                      Response(unavailable, 404, {})) as url:
        assert url(unavailable) == follow_redirects(url(link))
Пример #11
0
def test_follow_redirects_unavailable():
    link = "/resource"
    with start_server(Response(link, 404, {})) as url:
        assert url(link) == follow_redirects(url(link))
Пример #12
0
def test_follow_redirects_redirected_link():
    redirected = "/redirected"
    link = "/resource"
    with start_server(Response(link, 301, {"Location": redirected}),
                      Response(redirected, 200, {})) as url:
        assert url(redirected) == follow_redirects(url(link))
Пример #13
0
def test_follow_redirects_direct_link():
    link = "/resource"
    with start_server(Response(link, 200, {})) as url:
        assert url(link) == follow_redirects(url(link))
Пример #14
0
def test_follow_redirects_unavailable():
    link = "/resource"
    with start_server(Response(link, 404, {})) as url:
        assert url(link) == follow_redirects(url(link))
Пример #15
0
def test_follow_redirects_direct_link():
    link = "/resource"
    with start_server(Response(link, 200, {})) as url:
        assert url(link) == follow_redirects(url(link))
Пример #16
0
def test_follow_redirects_filtered_by_site():
    link = "/resource"
    with start_server() as url:
        assert url(link) == follow_redirects(url(link), ["other_host"])
Пример #17
0
def test_follow_redirects_link_to_nowhere():
    unavailable = "http://links.nowhere/"
    link = "/resource"
    with start_server(
        Response(link, 301, {"Location": unavailable})) as url:
        assert unavailable == follow_redirects(url(link))
Пример #18
0
def test_follow_redirects_no_where():
    link = "http://links.nowhere/"
    assert link == follow_redirects(link)