Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and test incomplete server url #119

Merged
merged 2 commits into from
May 17, 2020
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
14 changes: 13 additions & 1 deletion R/conn.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,19 @@ neuprint_connection <- function(server=NULL, token=NULL, dataset=NULL,
# Set a default server if none specified
neuprint_server <-
if(is.null(server)) unlist(getenvoroption("server")) else server
# Set a default server if none specified
pu=httr::parse_url(neuprint_server)
if(is.null(pu$scheme)) {
pu$scheme="https"
if(is.null(pu$hostname)) {
pu$hostname=pu$path
pu$path=NULL
}
neuprint_server=httr::build_url(pu)
warning("No URL scheme specified for your server! Assuming it should be:x\n",
neuprint_server,
"\nPlease specify the URL in full next time!")
}
# Set a default token if none specified
neuprint_token <- if(is.null(token)) unlist(getenvoroption("token")) else token
# collect any curl options defined as environment variables
config=neuprint_curl_options(config)
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-conn.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ skip_if(as.logical(Sys.getenv("SKIP_NP_SERVER_TESTS")))
test_that("neuprint_login works", {
expect_error(neuprint_login(server="https://neuprint.janelia.org", dataset='rhubarb'))
})

test_that("neuprint_connection works", {
expect_warning(expect_is(
neuprint_connection(server = "neuprint.janelia.org", dataset = 'rhubarb'),
"neuprint_connection"
),
regexp = "https://neuprint.janelia.org")
})