File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ use robotparser::service::RobotsTxtService;
33use reqwest:: Client ;
44use url:: Url ;
55use tokio:: runtime:: Runtime ;
6+ use url:: { Host , Origin } ;
67
78#[ test]
89fn test_reqwest_async ( ) {
@@ -13,4 +14,15 @@ fn test_reqwest_async() {
1314 let robots_txt = robots_txt_response. unwrap ( ) . get_result ( ) ;
1415 let fetch_url = Url :: parse ( "http://www.python.org/robots.txt" ) . unwrap ( ) ;
1516 assert ! ( robots_txt. can_fetch( "*" , & fetch_url) ) ;
16- }
17+ let fetch_url = Url :: parse ( "http://www.python.org/webstats/" ) . unwrap ( ) ;
18+ assert ! ( !robots_txt. can_fetch( "*" , & fetch_url) ) ;
19+ }
20+
21+ #[ test]
22+ #[ should_panic]
23+ fn test_reqwest_blocking_panic_url ( ) {
24+ let client = Client :: new ( ) ;
25+ let host = Host :: Domain ( "python.org::" . into ( ) ) ;
26+ let origin = Origin :: Tuple ( "https" . into ( ) , host, 80 ) ;
27+ client. fetch_robots_txt ( origin) ;
28+ }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ use robotparser::http::RobotsTxtClient;
22use robotparser:: service:: RobotsTxtService ;
33use reqwest:: blocking:: Client ;
44use url:: Url ;
5+ use url:: { Host , Origin } ;
56
67#[ test]
78fn test_reqwest_blocking ( ) {
@@ -10,4 +11,15 @@ fn test_reqwest_blocking() {
1011 let robots_txt = client. fetch_robots_txt ( robots_txt_url. origin ( ) ) . unwrap ( ) . get_result ( ) ;
1112 let fetch_url = Url :: parse ( "http://www.python.org/robots.txt" ) . unwrap ( ) ;
1213 assert ! ( robots_txt. can_fetch( "*" , & fetch_url) ) ;
14+ let fetch_url = Url :: parse ( "http://www.python.org/webstats/" ) . unwrap ( ) ;
15+ assert ! ( !robots_txt. can_fetch( "*" , & fetch_url) ) ;
16+ }
17+
18+ #[ test]
19+ #[ should_panic]
20+ fn test_reqwest_blocking_panic_url ( ) {
21+ let client = Client :: new ( ) ;
22+ let host = Host :: Domain ( "python.org::" . into ( ) ) ;
23+ let origin = Origin :: Tuple ( "https" . into ( ) , host, 80 ) ;
24+ client. fetch_robots_txt ( origin) . unwrap ( ) . get_result ( ) ;
1325}
You can’t perform that action at this time.
0 commit comments