-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from ropensci/testthat-3e
Update to `testthat` 3e
- Loading branch information
Showing
13 changed files
with
428 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
# This file is part of the standard setup for testthat. | ||
# It is recommended that you do not modify it. | ||
# | ||
# Where should you do additional test configuration? | ||
# Learn more about the roles of various files in: | ||
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview | ||
# * https://testthat.r-lib.org/articles/special-files.html | ||
|
||
library(testthat) | ||
if(curl::has_internet()){ | ||
library(robotstxt) | ||
if (curl::has_internet()) { | ||
test_check("robotstxt") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# non www redirects are handled non silently | ||
|
||
Code | ||
domain_change <- readRDS(system.file("http_requests/http_domain_change.rds", | ||
package = "robotstxt")) | ||
suppressMessages(get_robotstxt("http://google.com", rt_robotstxt_http_getter = function( | ||
...) { | ||
domain_change | ||
}, warn = TRUE)) | ||
Condition | ||
Warning in `request_handler_handler()`: | ||
Event: on_file_type_mismatch | ||
Warning in `request_handler_handler()`: | ||
Event: on_suspect_content | ||
Output | ||
[robots.txt] | ||
-------------------------------------- | ||
# robots.txt overwrite by: on_suspect_content | ||
User-agent: * | ||
Allow: / | ||
[events] | ||
-------------------------------------- | ||
requested: www.petermeissner.de | ||
downloaded: https://petermeissner.de/ | ||
$on_redirect | ||
$on_redirect[[1]] | ||
$on_redirect[[1]]$status | ||
[1] 301 | ||
$on_redirect[[1]]$location | ||
[1] "https://www.petermeissner.de/" | ||
$on_redirect[[2]] | ||
$on_redirect[[2]]$status | ||
[1] 301 | ||
$on_redirect[[2]]$location | ||
[1] "https://petermeissner.de/" | ||
$on_redirect[[3]] | ||
$on_redirect[[3]]$status | ||
[1] 200 | ||
$on_redirect[[3]]$location | ||
NULL | ||
$on_file_type_mismatch | ||
$on_file_type_mismatch$content_type | ||
[1] "text/html" | ||
$on_suspect_content | ||
$on_suspect_content$parsable | ||
[1] FALSE | ||
$on_suspect_content$content_suspect | ||
[1] TRUE | ||
[attributes] | ||
-------------------------------------- | ||
problems, cached, request, class | ||
|
||
# client error | ||
|
||
Code | ||
http_client_error <- readRDS(system.file("http_requests/http_client_error.rds", | ||
package = "robotstxt")) | ||
suppressMessages(get_robotstxt("httpbin.org", rt_robotstxt_http_getter = function( | ||
...) { | ||
http_client_error | ||
})) | ||
Condition | ||
Warning in `request_handler_handler()`: | ||
Event: on_client_error | ||
Warning in `request_handler_handler()`: | ||
Event: on_file_type_mismatch | ||
Output | ||
[robots.txt] | ||
-------------------------------------- | ||
# robots.txt overwrite by: on_client_error | ||
User-agent: * | ||
Allow: / | ||
[events] | ||
-------------------------------------- | ||
requested: https://httpbin.org/status/400 | ||
downloaded: https://httpbin.org/status/400 | ||
$on_client_error | ||
$on_client_error$status_code | ||
[1] 400 | ||
$on_file_type_mismatch | ||
$on_file_type_mismatch$content_type | ||
[1] "text/html; charset=utf-8" | ||
[attributes] | ||
-------------------------------------- | ||
problems, cached, request, class | ||
|
||
# server error | ||
|
||
Code | ||
res <- suppressMessages(get_robotstxt("httpbin.org", rt_robotstxt_http_getter = f, | ||
on_server_error = list(signal = "warning"), force = TRUE)) | ||
Condition | ||
Warning in `request_handler_handler()`: | ||
Event: on_server_error | ||
Warning in `request_handler_handler()`: | ||
Event: on_file_type_mismatch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# paths_allowed() works also with 'downloaded' robots.txt files | ||
|
||
Code | ||
domain_change <- readRDS(system.file("http_requests/http_domain_change.rds", | ||
package = "robotstxt")) | ||
suppressMessages(paths_allowed(paths = "https://github.io/index.html", | ||
rt_robotstxt_http_getter = function(...) { | ||
domain_change | ||
}, warn = FALSE)) | ||
Output | ||
[1] TRUE | ||
|
||
--- | ||
|
||
Code | ||
domain_change <- readRDS(system.file("http_requests/http_domain_change.rds", | ||
package = "robotstxt")) | ||
suppressMessages(paths_allowed(paths = "https://github.io/index.html", | ||
rt_robotstxt_http_getter = function(...) { | ||
domain_change | ||
})) | ||
Condition | ||
Warning in `request_handler_handler()`: | ||
Event: on_domain_change | ||
Warning in `request_handler_handler()`: | ||
Event: on_file_type_mismatch | ||
Warning in `request_handler_handler()`: | ||
Event: on_suspect_content | ||
Output | ||
[1] TRUE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.