Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
Package: PallasExplorer
Type: Package
Title: Sparql Graph construction and object Auto-suggestion
Version: 0.0.0.9000
Authors@R: c(
person(
"Ata", "Badr Barzegar",
email = "atabadrbarzegar@gmail.com",
role = c("aut", "cre")
)
)
Description: The main goal is to connect to SPARQL endpoints and bering their structure into the R world. This package would enable R developers to make a graph of RDF schemas in different endpoints and also access classes and properties with auto-suggestion mechanism enabled in R.
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
LazyData: true
Imports:
S7,
tools,
httr2,
stats
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
Depends:
R (>= 4.3)
Config/roxygen2/version: 8.0.0
Package: PallasExplorer
Type: Package
Title: Sparql Graph construction and object Auto-suggestion
Version: 0.0.0.9000
Authors@R: c(
person(
"Ata", "Badr Barzegar",
email = "atabadrbarzegar@gmail.com",
role = c("aut", "cre")
)
)
Description: The main goal is to connect to SPARQL endpoints and bering their structure into the R world. This package would enable R developers to make a graph of RDF schemas in different endpoints and also access classes and properties with auto-suggestion mechanism enabled in R.
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
LazyData: true
Imports:
S7,
tools,
httr2,
stats
Suggests:
testthat (>= 3.0.0),
withr
Config/testthat/edition: 3
Depends:
R (>= 4.3)
Config/roxygen2/version: 8.0.0
20 changes: 19 additions & 1 deletion tests/testthat/test-cache.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
test_that("pallas_graph_cache_dir returns an existing directory", {
dir <- pallas_graph_cache_dir()
dir <- pallas_graph_cache_dir("PallasTestDefault")
withr::defer(unlink(dir, recursive = TRUE))

expect_type(dir, "character")
expect_true(dir.exists(dir))
})

test_that("pallas_graph_cache_dir respects a custom dir_name", {
dir <- pallas_graph_cache_dir("PallasTestCustom")
withr::defer(unlink(dir, recursive = TRUE))

expect_true(grepl("PallasTestCustom", dir, fixed = TRUE))
})

test_that("pallas_graph_cache_dir is idempotent", {
dir1 <- pallas_graph_cache_dir("PallasTestIdempotent")
withr::defer(unlink(dir1, recursive = TRUE))

dir2 <- pallas_graph_cache_dir("PallasTestIdempotent")

expect_equal(dir1, dir2)
expect_true(dir.exists(dir2))
})
65 changes: 62 additions & 3 deletions tests/testthat/test-endpoint_class.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,63 @@
test_that("sparql_endpoint validator rejects a bad url", {
expect_error(sparql_endpoint(url = ""))
expect_error(sparql_endpoint(url = c("a", "b")))
test_that("sparql_endpoint stores valid custom property values", {
example_url <- "https://example.org/sparql"
example_name <- "example"
example_headers <- list(Accept = "application/json")
example_timeout <- 30

ep <- sparql_endpoint(
url = example_url,
name = example_name,
headers = example_headers,
timeout = example_timeout
)

expect_equal(ep@url, example_url)
expect_equal(ep@name, example_name)
expect_equal(ep@headers, example_headers)
expect_equal(ep@timeout, example_timeout)
})

test_that("sparql_endpoint has the right defaults", {
ep <- sparql_endpoint(url = "https://example.org/sparql")

expect_true(is.na(ep@name))
expect_equal(ep@headers, list())
expect_equal(ep@timeout, 60)
})

test_that("sparql_endpoint@url validator rejects bad values", {
expect_error(sparql_endpoint(url = ""), regexp = "non-empty")
expect_error(sparql_endpoint(url = c("a", "b")), regexp = "single")
})

test_that("sparql_endpoint@name validator rejects non-scalar values", {
expect_error(
sparql_endpoint(url = "https://example.org", name = c("a", "b")),
regexp = "single"
)
})

test_that("sparql_endpoint@headers validator rejects unnamed lists", {
expect_error(
sparql_endpoint(url = "https://example.org", headers = list("application/json")),
regexp = "named"
)
expect_error(
sparql_endpoint(url = "https://example.org", headers = list(Accept = "a", "b")),
regexp = "named"
)
})

test_that("sparql_endpoint@timeout validator rejects non-positive or NA values", {
expect_error(sparql_endpoint(url = "https://example.org", timeout = 0), regexp = "positive")
expect_error(sparql_endpoint(url = "https://example.org", timeout = -5), regexp = "positive")
expect_error(sparql_endpoint(url = "https://example.org", timeout = NA_real_), regexp = "positive")
expect_error(sparql_endpoint(url = "https://example.org", timeout = c(1, 2)), regexp = "positive")
})

test_that("generic_endpoint inherits from sparql_endpoint", {
ep <- generic_endpoint(url = "https://example.org/sparql")

expect_true(S7::S7_inherits(ep, generic_endpoint))
expect_true(S7::S7_inherits(ep, sparql_endpoint))
})