Browse Source

basic pkg tests

master
boB Rudis 3 years ago
parent
commit
5a7794deba
9 changed files with 29 additions and 11 deletions
  1. +4
    -0
      NEWS.md
  2. +3
    -3
      R/docker-splash.r
  3. +1
    -1
      R/render-har.r
  4. +1
    -1
      R/splashr-package.R
  5. +1
    -1
      man/render_har.Rd
  6. +1
    -1
      man/splashr.Rd
  7. +2
    -2
      man/start_splash.Rd
  8. +1
    -1
      man/stop_splash.Rd
  9. +15
    -1
      tests/testthat/test-splash.R

+ 4
- 0
NEWS.md View File

@@ -1,5 +1,9 @@
0.3.0

* added basic pkg tests
* added mini-DSL to avoid needing to write lua scripts for some common operations
* added many tests for many types of objects
* added HAR support
* added `as_req()`
* added `as_request()`



+ 3
- 3
R/docker-splash.r View File

@@ -18,7 +18,7 @@ install_splash <- function(host = harbor::localhost) {
#' If using this in an automation context, you should consider adding a
#' `Sys.sleep(3)` (or higher) after starting the docker container.
#'
#' @param host Docker host; defauolts to `localhost`
#' @param host Docker host; defaults to `localhost`
#' @param add_tempdir This is `FALSE` initially since you could try to run
#' the splash image on a remote system. It has to be a local one for this to work.
#' If `TRUE` then a local temporary directory (made with [tempdir]())
@@ -26,7 +26,7 @@ install_splash <- function(host = harbor::localhost) {
#' ensure the necessary system temp dirs are accessible as a mounts. For
#' macOS this means adding `/private` to said Docker config.
#' @note you need Docker running on your system and have pulled the container with
#' [install_spash] for this to work. You should save the resultant `host`
#' [install_splash] for this to work. You should save the resultant `host`
#' object for use in [stop_splash].
#' @return `harbor` `container` object
#' @export
@@ -57,7 +57,7 @@ start_splash <- function(host = harbor::localhost, add_tempdir=FALSE) {
#'
#' @param splash_container Docker `container` object created by [start_splash]
#' @note you need Docker running on your system and have pulled the container with
#' [install_spash] and started the Splash container with [start_splash] for this
#' [install_splash] and started the Splash container with [start_splash] for this
#' to work. You will need the `container` object from [start_splash] for this to work.
#' @export
#' @examples \dontrun{


+ 1
- 1
R/render-har.r View File

@@ -1,7 +1,7 @@
#' Return information about Splash interaction with a website in HAR format.
#'
#' It includes information about requests made, responses received, timings, headers, etc and
#' is incredibly detailed, full of information on every componenent loaded.
#' is incredibly detailed, full of information on every component loaded.
#'
#' @md
#' @param response_body When `TRUE`, response content is included in the HAR records


+ 1
- 1
R/splashr-package.R View File

@@ -3,7 +3,7 @@
#' 'Splash' <https://github.com/scrapinghub/splash> is a javascript rendering service.
#' It’s a lightweight web browser with an 'HTTP' API, implemented in Python using
#' 'Twisted'and 'QT' and provides some of the core functionality of the 'RSelenium' or
#' 'seleniumPipes'R pacakges but with a Java-free footprint. The (twisted) 'QT' reactor is
#' 'seleniumPipes'R packages but with a Java-free footprint. The (twisted) 'QT' reactor is
#' used to make the sever fully asynchronous allowing to take advantage of 'webkit'
#' concurrency via QT main loop. Some of Splash features include the ability to process
#' multiple webpages in parallel; retrieving HTML results and/or take screenshots;


+ 1
- 1
man/render_har.Rd View File

@@ -58,7 +58,7 @@ a \code{HARtools} \code{har} object
}
\description{
It includes information about requests made, responses received, timings, headers, etc and
is incredibly detailed, full of information on every componenent loaded.
is incredibly detailed, full of information on every component loaded.
}
\references{
\href{http://splash.readthedocs.io/en/stable/index.html}{Splash docs}


+ 1
- 1
man/splashr.Rd View File

@@ -9,7 +9,7 @@
'Splash' \url{https://github.com/scrapinghub/splash} is a javascript rendering service.
It’s a lightweight web browser with an 'HTTP' API, implemented in Python using
'Twisted'and 'QT' and provides some of the core functionality of the 'RSelenium' or
'seleniumPipes'R pacakges but with a Java-free footprint. The (twisted) 'QT' reactor is
'seleniumPipes'R packages but with a Java-free footprint. The (twisted) 'QT' reactor is
used to make the sever fully asynchronous allowing to take advantage of 'webkit'
concurrency via QT main loop. Some of Splash features include the ability to process
multiple webpages in parallel; retrieving HTML results and/or take screenshots;


+ 2
- 2
man/start_splash.Rd View File

@@ -7,7 +7,7 @@
start_splash(host = harbor::localhost, add_tempdir = FALSE)
}
\arguments{
\item{host}{Docker host; defauolts to `localhost`}
\item{host}{Docker host; defaults to `localhost`}

\item{add_tempdir}{This is `FALSE` initially since you could try to run
the splash image on a remote system. It has to be a local one for this to work.
@@ -25,7 +25,7 @@ If using this in an automation context, you should consider adding a
}
\note{
you need Docker running on your system and have pulled the container with
[install_spash] for this to work. You should save the resultant `host`
[install_splash] for this to work. You should save the resultant `host`
object for use in [stop_splash].
}
\examples{


+ 1
- 1
man/stop_splash.Rd View File

@@ -14,7 +14,7 @@ Stop a running a Splash server Docker container
}
\note{
you need Docker running on your system and have pulled the container with
[install_spash] and started the Splash container with [start_splash] for this
[install_splash] and started the Splash container with [start_splash] for this
to work. You will need the `container` object from [start_splash] for this to work.
}
\examples{


+ 15
- 1
tests/testthat/test-splash.R View File

@@ -1,6 +1,20 @@
context("basic functionality")
test_that("we can do something", {

#expect_that(some_function(), is_a("data.frame"))
spact <- splash_active()

expect_that(spact, equals(TRUE))

if (spact) {

expect_that(length(splash_debug()), equals(7))
expect_that(length(splash_version()), equals(9))
expect_that(render_json(url = "https://httpbin.org/get"), is_a("splash_json"))
expect_that(render_png(url = "https://httpbin.org/get"), is_a("magick-image"))
expect_that(render_png(url = "https://httpbin.org/get"), is_a("magick-image"))
expect_that(render_html(url = "https://httpbin.org/get"), is_a("xml_document"))
expect_that(render_har(url = "https://httpbin.org/get"), is_a("har"))

}

})

Loading…
Cancel
Save