Skip to content

Commit

Permalink
Merge pull request #116 from frictionlessdata/fix-cran-issues
Browse files Browse the repository at this point in the history
Fix CRAN issues
  • Loading branch information
peterdesmet authored Nov 16, 2022
2 parents b6d3308 + 0ca101b commit 92205d5
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "frictionless: Read and Write Frictionless Data Packages",
"version": "1.0.0",
"version": "1.0.2",
"description": "Read and write Frictionless Data Packages. A 'Data Package' (<https://specs.frictionlessdata.io/data-package/>) is a simple container format and standard to describe and package a collection of (tabular) data. It is typically used to publish FAIR (<https://www.go-fair.org/fair-principles/>) and open datasets.",
"creators": [
{
Expand All @@ -14,7 +14,7 @@
],
"upload_type": "software",
"access_right": "open",
"license": "MIT",
"license": "MIT + file LICENSE",
"communities": [
{
"identifier": "inbo"
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: frictionless
Title: Read and Write Frictionless Data Packages
Version: 1.0.1.9000
Version: 1.0.2
Authors@R: c(
person("Peter", "Desmet", email = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-8442-8025")),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# frictionless (development version)

# frictionless 1.0.2

- Add `testthat::skip_if_offline()` to selected tests and verbosely include
output in vignette examples, to avoid CRAN errors caused by timeouts (#116).

# frictionless 1.0.1

- Rebuild documentation for compatibility with HTML5 on request of CRAN.
Expand Down
6 changes: 3 additions & 3 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/frictionlessdata/frictionless-r",
"issueTracker": "https://github.com/frictionlessdata/frictionless-r/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "1.0.1",
"version": "1.0.2",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -226,7 +226,7 @@
},
"SystemRequirements": null
},
"fileSize": "178.01KB",
"fileSize": "183.204KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand All @@ -250,7 +250,7 @@
"name": "Read and Write Frictionless Data Packages",
"identifier": "10.5281/zenodo.5815355",
"url": "https://cran.r-project.org/package=frictionless",
"description": "R package version 1.0.1",
"description": "R package version 1.0.2",
"@id": "https://doi.org/10.5281/zenodo.5815355",
"sameAs": "https://doi.org/10.5281/zenodo.5815355"
}
Expand Down
12 changes: 7 additions & 5 deletions tests/testthat/test-add_resource.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ test_that("add_resource() returns error on invalid or empty data frame", {
})

test_that("add_resource() returns error if CSV file cannot be found", {
testthat::skip_if_offline()
p <- example_package
df_csv <- test_path("data/df.csv")
schema <- create_schema(data.frame("col_1" = c(1, 2), "col_2" = c("a", "b")))
Expand All @@ -98,11 +99,6 @@ test_that("add_resource() returns error if CSV file cannot be found", {
"Can't find file at `no_such_file.csv`.",
fixed = TRUE
)
expect_error(
add_resource(p, "new", "http://example.com/no_such_file.csv"),
"Can't find file at `http://example.com/no_such_file.csv`.",
fixed = TRUE
)
expect_error(
add_resource(p, "new", c(df_csv, "no_such_file.csv")),
"Can't find file at `no_such_file.csv`.",
Expand All @@ -118,6 +114,11 @@ test_that("add_resource() returns error if CSV file cannot be found", {
"Can't find file at `no_such_file_1.csv`.",
fixed = TRUE
)
expect_error(
add_resource(p, "new", "http://example.com/no_such_file.csv"),
"Can't find file at `http://example.com/no_such_file.csv`.",
fixed = TRUE
)
})

test_that("add_resource() returns error on mismatching schema and data", {
Expand Down Expand Up @@ -226,6 +227,7 @@ test_that("add_resource() can add resource from data frame, readable by

test_that("add_resource() can add resource from local, relative, absolute,
remote or compressed CSV file, readable by read_resource()", {
testthat::skip_if_offline()
p <- example_package
schema <- get_schema(p, "deployments")

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-check_schema.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test_that("check_schema() returns TRUE on valid Table Schema", {
testthat::skip_if_offline()
p <- example_package
# Can't obtain df using read_resource(), because that function uses
# check_schema() (in get_schema()) internally, which is what we want to test
Expand Down
44 changes: 29 additions & 15 deletions tests/testthat/test-read_package.R
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
test_that("read_package() returns a valid Data Package, whether reading path or
url", {
# Load example package (locally and remotely) and a valid minimal one
test_that("read_package() returns a valid Data Package reading from path", {
# Load example package locally and a valid minimal one
p_path <- system.file("extdata", "datapackage.json", package = "frictionless")
p_url <- file.path("https://raw.githubusercontent.com/frictionlessdata/",
"frictionless-r/main/inst/extdata/datapackage.json")
minimal_path <- test_path("data/valid_minimal.json")
p_local <- suppressMessages(read_package(p_path))
p_remote <- suppressMessages(read_package(p_url))
p_minimal <- suppressMessages(read_package(minimal_path))

# Returns a list with required properties
expect_true(check_package(p_local))
expect_true(check_package(p_remote))
expect_true(check_package(p_minimal))

# Package has correct resources
resource_names <- c("deployments", "observations", "media")
expect_identical(resources(p_local), resource_names)
expect_identical(resources(p_remote), resource_names)
expect_identical(resources(p_minimal), resource_names)

# Package has correct "directory", containing root dir of datapackage.json
expect_identical(p_local$directory, gsub("/datapackage.json", "", p_path))
expect_identical(p_remote$directory, gsub("/datapackage.json", "", p_url))
expect_identical(p_minimal$directory, "data")
})

test_that("read_package() returns a valid Data Package reading from url", {
testthat::skip_if_offline()
# Load example package remotely
p_url <- file.path("https://raw.githubusercontent.com/frictionlessdata/",
"frictionless-r/main/inst/extdata/datapackage.json")
p_remote <- suppressMessages(read_package(p_url))

# Returns a list with required properties
expect_true(check_package(p_remote))

# Package has correct resources
resource_names <- c("deployments", "observations", "media")
expect_identical(resources(p_remote), resource_names)

# Package has correct "directory", containing root dir of datapackage.json
expect_identical(p_remote$directory, gsub("/datapackage.json", "", p_url))
})

test_that("read_package() shows message about usage norms", {
# Load example package and a minimal valid one a URL in "id"
p_path <- system.file("extdata", "datapackage.json", package = "frictionless")
Expand Down Expand Up @@ -55,24 +66,20 @@ test_that("read_package() shows message about usage norms", {
})

test_that("read_package() returns error on missing file and properties", {
testthat::skip_if_offline()
# Incorrect type
expect_error(
read_package(list()),
"`file` must be a path or URL to a `datapackage.json` file.",
fixed = TRUE
)

# No file
# No file locally
expect_error(
read_package("nofile.json"),
"Can't find file at `nofile.json`",
fixed = TRUE
)
expect_error(
read_package("http://example.com/nofile.json"),
"Can't find file at `http://example.com/nofile.json`.",
fixed = TRUE
)

# Not a json file
expect_error(
Expand Down Expand Up @@ -111,6 +118,13 @@ test_that("read_package() returns error on missing file and properties", {
),
fixed = TRUE
)

# No file remotely
expect_error(
read_package("http://example.com/nofile.json"),
"Can't find file at `http://example.com/nofile.json`.",
fixed = TRUE
)
})

test_that("read_package() allows descriptor at absolute or relative parent
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-read_resource.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test_that("read_resource() returns a tibble", {
testthat::skip_if_offline()
p <- example_package
df <- data.frame("col_1" = c(1, 2), "col_2" = c("a", "b"))
p <- add_resource(p, "new", df)
Expand All @@ -20,6 +21,7 @@ test_that("read_resource() returns error on incorrect Data Package", {
})

test_that("read_resource() returns error on incorrect resource", {
testthat::skip_if_offline()
p <- example_package

# No such resource
Expand Down Expand Up @@ -178,6 +180,7 @@ test_that("read_resource() can read inline data (ignoring schema)", {
})

test_that("read_resource() can read local files", {
testthat::skip_if_offline()
p <- example_package
resource <- read_resource(p, "deployments") # local resource, remote package

Expand All @@ -188,6 +191,7 @@ test_that("read_resource() can read local files", {
})

test_that("read_resource() can read remote files", {
testthat::skip_if_offline()
p <- example_package
resource <- read_resource(p, "deployments") # local resource, remote package

Expand All @@ -201,6 +205,7 @@ test_that("read_resource() can read remote files", {

test_that("read_resource() can read safe local and remote Table Schema,
including YAML", {
testthat::skip_if_offline()
p <- example_package
resource <- read_resource(p, "deployments")
p$directory <- "."
Expand Down Expand Up @@ -255,6 +260,7 @@ test_that("read_resource() can read safe local and remote Table Schema,
})

test_that("read_resource() can read safe local and remote CSV dialect", {
testthat::skip_if_offline()
p <- example_package
resource <- read_resource(p, "deployments")
p$directory <- "."
Expand Down Expand Up @@ -307,6 +313,7 @@ test_that("read_resource() can read safe local and remote CSV dialect", {
})

test_that("read_resource() understands CSV dialect", {
testthat::skip_if_offline()
p <- example_package
resource <- read_resource(p, "deployments")

Expand Down Expand Up @@ -336,6 +343,7 @@ test_that("read_resource() understands CSV dialect", {
})

test_that("read_resource() understands missing values", {
testthat::skip_if_offline()
p <- example_package
resource <- read_resource(p, "deployments")

Expand All @@ -350,6 +358,7 @@ test_that("read_resource() understands missing values", {
})

test_that("read_resource() understands encoding", {
testthat::skip_if_offline()
p <- example_package
resource <- read_resource(p, "deployments")

Expand Down Expand Up @@ -438,6 +447,7 @@ test_that("read_resource() handles LF and CRLF line terminator characters", {
#
# read_delim() however only handles 2 line terminator characters (LF and CRLF)
# without explicitly indicating them, so dialect$lineTerminator is ignored
testthat::skip_if_offline()
p <- example_package
resource <- read_resource(p, "deployments") # This file has LF

Expand All @@ -449,6 +459,7 @@ test_that("read_resource() handles LF and CRLF line terminator characters", {
})

test_that("read_resource() can read compressed files", {
testthat::skip_if_offline()
p <- example_package
resource <- read_resource(p, "deployments")

Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-remove_resource.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test_that("remove_resource() returns a valid Data Package", {
testthat::skip_if_offline()
p <- example_package
expect_true(check_package(remove_resource(p, "deployments")))
})
Expand All @@ -15,6 +16,7 @@ test_that("remove_resource() returns error on incorrect Data Package", {
})

test_that("remove_resource() returns error when resource not found", {
testthat::skip_if_offline()
p <- example_package
expect_error(
remove_resource(p, "no_such_resource"),
Expand All @@ -27,6 +29,7 @@ test_that("remove_resource() returns error when resource not found", {
})

test_that("remove_resource() removes resource", {
testthat::skip_if_offline()
p <- example_package

# Remove "deployments", keep "observations" and "media
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-resources.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test_that("resources() returns a character vector of resource names", {
testthat::skip_if_offline()
p <- example_package
expect_identical(resources(p), c("deployments", "observations", "media"))

Expand Down
Loading

0 comments on commit 92205d5

Please sign in to comment.