()
| 38 | |
| 39 | |
| 40 | def test_get_meta_refresh(): |
| 41 | r1 = HtmlResponse( |
| 42 | "http://www.example.com", |
| 43 | body=b""" |
| 44 | <html> |
| 45 | <head><title>Dummy</title><meta http-equiv="refresh" content="5;url=http://example.org/newpage" /></head> |
| 46 | <body>blahablsdfsal&</body> |
| 47 | </html>""", |
| 48 | ) |
| 49 | r2 = HtmlResponse( |
| 50 | "http://www.example.com", |
| 51 | body=b""" |
| 52 | <html> |
| 53 | <head><title>Dummy</title><noScript> |
| 54 | <meta http-equiv="refresh" content="5;url=http://example.org/newpage" /></head> |
| 55 | </noSCRIPT> |
| 56 | <body>blahablsdfsal&</body> |
| 57 | </html>""", |
| 58 | ) |
| 59 | r3 = HtmlResponse( |
| 60 | "http://www.example.com", |
| 61 | body=b""" |
| 62 | <noscript><meta http-equiv="REFRESH" content="0;url=http://www.example.com/newpage</noscript> |
| 63 | <script type="text/javascript"> |
| 64 | if(!checkCookies()){ |
| 65 | document.write('<meta http-equiv="REFRESH" content="0;url=http://www.example.com/newpage">'); |
| 66 | } |
| 67 | </script> |
| 68 | """, |
| 69 | ) |
| 70 | r4 = HtmlResponse( |
| 71 | "http://www.example.com", |
| 72 | body=b""" |
| 73 | <html> |
| 74 | <head><title>Dummy</title> |
| 75 | <base href="http://www.another-domain.com/base/path/"> |
| 76 | <meta http-equiv="refresh" content="5;url=target.html"</head> |
| 77 | <body>blahablsdfsal&</body> |
| 78 | </html>""", |
| 79 | ) |
| 80 | assert get_meta_refresh(r1) == (5.0, "http://example.org/newpage") |
| 81 | assert get_meta_refresh(r2) == (None, None) |
| 82 | assert get_meta_refresh(r3) == (None, None) |
| 83 | assert get_meta_refresh(r4) == ( |
| 84 | 5.0, |
| 85 | "http://www.another-domain.com/base/path/target.html", |
| 86 | ) |
| 87 | |
| 88 | |
| 89 | def test_get_base_url(): |
nothing calls this directly
no test coverage detected