File tree 2 files changed +25
-1
lines changed
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;
3
3
use reqwest:: Client ;
4
4
use url:: Url ;
5
5
use tokio:: runtime:: Runtime ;
6
+ use url:: { Host , Origin } ;
6
7
7
8
#[ test]
8
9
fn test_reqwest_async ( ) {
@@ -13,4 +14,15 @@ fn test_reqwest_async() {
13
14
let robots_txt = robots_txt_response. unwrap ( ) . get_result ( ) ;
14
15
let fetch_url = Url :: parse ( "http://www.python.org/robots.txt" ) . unwrap ( ) ;
15
16
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;
2
2
use robotparser:: service:: RobotsTxtService ;
3
3
use reqwest:: blocking:: Client ;
4
4
use url:: Url ;
5
+ use url:: { Host , Origin } ;
5
6
6
7
#[ test]
7
8
fn test_reqwest_blocking ( ) {
@@ -10,4 +11,15 @@ fn test_reqwest_blocking() {
10
11
let robots_txt = client. fetch_robots_txt ( robots_txt_url. origin ( ) ) . unwrap ( ) . get_result ( ) ;
11
12
let fetch_url = Url :: parse ( "http://www.python.org/robots.txt" ) . unwrap ( ) ;
12
13
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 ( ) ;
13
25
}
You can’t perform that action at this time.
0 commit comments