Skip to content

Commit

Permalink
Skip long running tests at request of CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
FvD committed Dec 11, 2017
1 parent 1f025fe commit 15be5d6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 31 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Description:
government Open Data initiatives in Latin America and the USA. This package
is a wrapper to make it easier to access data made public through the 'Junar'
API.
Version: 0.1.2
Version: 0.1.3
Date: 2017-08-08
Authors@R: c(person("Frans", "van Dunné", ,
"[email protected]",
Expand Down
2 changes: 2 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
## R CMD check results
There were no ERRORS and no WARNINGS

Changed tests at the request of Uwe Ligges to reduce test time on CRAN machines

## Downstream dependencies
I have run R CMD check on downstream dependencies of junr
(https://github.com/FvD/junr/blob/master/revdep/summary.md).
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/helper-data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
library(junr)
library(httr)

base_url <- "http://api.datosabiertos.presidencia.go.cr/api/v2/datastreams/"
api_key <- "0bd55e858409eefabc629b28b2e7916361ef20ff"
8 changes: 2 additions & 6 deletions tests/testthat/test-getdata.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
library(junr)
library(httr)

context("Get data")

base_url <- "http://api.datosabiertos.presidencia.go.cr/api/v2/datastreams/"
api_key <- "0bd55e858409eefabc629b28b2e7916361ef20ff"

# get_index
test_that("The connection to the test url gets a response", {
skip_on_cran()
r <- GET(paste(base_url, "?auth_key=", api_key, sep = ""), accept_json(),
config = httr::config(ssl_verifypeer = FALSE))
expect_true(r$status_code %in% c(200, 403, 500))
Expand Down Expand Up @@ -49,6 +44,7 @@ test_that("We geta warning when there is no api_key", {

# get_data
guid <- list_guid(base_url, api_key)[1]

test_that("We geta warning when there is no url", {
expect_warning(get_data(api_key = api_key, guid = guid), "Please add a valid base URL")
})
Expand Down
24 changes: 9 additions & 15 deletions tests/testthat/test-inspectdata.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
library(junr)
context("inspect data")

base_url <- "http://api.datosabiertos.presidencia.go.cr/api/v2/datastreams/"
api_key <- "0bd55e858409eefabc629b28b2e7916361ef20ff"
test_that("The dimensions are correct and the dimensions are numeric columns", {
skip("long running test")
skip_on_cran()
test_dimensions <- get_dimensions(base_url, api_key)
expect_that(as.numeric(test_dimensions$NROW[1])*as.numeric(test_dimensions$NCOL[1]),
equals(as.numeric(test_dimensions$DIM[1])))

test_dimensions <- get_dimensions(base_url, api_key)

# get_dimensions
test_that("The dimensions are correct", {
expect_that(as.numeric(test_dimensions$NROW[1])*as.numeric(test_dimensions$NCOL[1]),
equals(as.numeric(test_dimensions$DIM[1])))
})

test_that("The dimensions are numeric columns", {
expect_true(is.numeric(test_dimensions$NROW[1]))
expect_true(is.numeric(test_dimensions$NCOL[1]))
expect_true(is.numeric(test_dimensions$DIM[1]))
expect_true(is.numeric(test_dimensions$NROW[1]))
expect_true(is.numeric(test_dimensions$NCOL[1]))
expect_true(is.numeric(test_dimensions$DIM[1]))
})

test_that("We geta warning when there is no url", {
Expand Down
15 changes: 6 additions & 9 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
library(junr)

context("Utilities")

base_url <- "http://api.datosabiertos.presidencia.go.cr/api/v2/datastreams/"
api_key <- "0bd55e858409eefabc629b28b2e7916361ef20ff"

currency_data <- get_data(base_url, api_key, "LICIT-ADJUD-POR-LOS-MINIS")

test_that("The test endpoint is still valid", {
expect_true(nrow(currency_data)>0)
expect_true(!is.null(currency_data$`Monto Adjudicado`))
skip_on_cran()
currency_data <- get_data(base_url, api_key, "LICIT-ADJUD-POR-LOS-MINIS")
expect_true(nrow(currency_data)>0)
expect_true(!is.null(currency_data$`Monto Adjudicado`))
})

test_that("Currency values are converted to numeric", {
skip_on_cran()
currency_data <- get_data(base_url, api_key, "LICIT-ADJUD-POR-LOS-MINIS")
numeric_currency <- clean_currency(currency_data$`Monto Adjudicado`)
expect_true(is.numeric(numeric_currency))
})

0 comments on commit 15be5d6

Please sign in to comment.