def test_redirection_full_path(): url_full2_plain = 'http://google.de/index' url = URL(url_full) updated = url.redirect(url_full2_plain) url_full2 = URL(url_full2_plain) for attr in URL.__slots__: assert getattr(updated, attr) == getattr(url_full2, attr) assert str(url_full2) == url_full2_plain
def test_redirection_abs_path(): url = URL(url_full) updated = url.redirect('/test.html') assert updated.host == url.host assert updated.port == url.port assert updated.path == '/test.html' assert updated.query == {} assert updated.fragment == ''
def test_redirection_rel_path(): url = URL(url_full) for redir in ('test.html?key=val', 'folder/test.html?key=val'): updated = url.redirect(redir) assert updated.host == url.host assert updated.port == url.port assert updated.path.startswith('/subdir/') assert updated.path.endswith(redir.split('?', 1)[0]) assert updated.query == {'key': 'val'} assert updated.fragment == ''