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)
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))
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))
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)
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)
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)
def test_follow_redirects_filtered_by_site(): link = "/resource" with start_server() as url: assert url(link) == follow_redirects(url(link), ["other_host"])
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))
def test_follow_redirects_no_where(): link = "http://links.nowhere/" assert link == follow_redirects(link)
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))
def test_follow_redirects_unavailable(): link = "/resource" with start_server(Response(link, 404, {})) as url: assert url(link) == follow_redirects(url(link))
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))
def test_follow_redirects_direct_link(): link = "/resource" with start_server(Response(link, 200, {})) as url: assert url(link) == follow_redirects(url(link))
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))