-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/simplify_getpost'
* closes #1 * feature/simplify_getpost: tests for catmaid neuron queries test fetching neuronnames get_compact_skeleton, get_neuron_names -> catmaid_fetch refactor all catmaid_(GET|POST)(J) to catmaid_fetch check attributes as well add tests for example get/post requests enable real tests of login using environment vars test catmaid_connectin and login Add basic test infrastructure add catmaid_fetch() to cover GET/POST requests
- Loading branch information
Showing
9 changed files
with
116 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
library(testthat) | ||
library(catmaid) | ||
|
||
test_check("catmaid") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
context("catmaid login and get/post") | ||
|
||
# set any catmaid options from environment vars | ||
# they could have been exported as follows: | ||
# do.call(Sys.setenv, options()[grep('catmaid',names(options()))]) | ||
catmaid_opnames=paste("catmaid", c("server", "username", "password", "authname", | ||
"authpassword", "authtype"), | ||
sep=".") | ||
catmaid_ops=Sys.getenv(catmaid_opnames) | ||
op=options(as.list(catmaid_ops[nzchar(catmaid_ops)])) | ||
|
||
# we can only run real tests if we can log in with default parameters | ||
conn=try(catmaid_login(), silent = TRUE) | ||
# store this in options so that we can access elsewhere | ||
options(catmaid_temp_conn=conn) | ||
|
||
test_that("can make a connection", { | ||
|
||
expect_error(catmaid_connection(server="http://somewhere.org")) | ||
conn<-catmaid_connection(server="https://somewhere.org", username = 'calvin', password = 'hobbes') | ||
expect_is(conn, "catmaid_connection") | ||
expect_is(conn$config, "config") | ||
}) | ||
|
||
test_that("can login", { | ||
if(!inherits(conn, 'try-error')){ | ||
expect_is(conn, 'catmaid_connection') | ||
expect_is(conn$authresponse, 'response') | ||
expect_equal(conn$authresponse$status, 200L) | ||
} | ||
|
||
}) | ||
|
||
test_that("can get and post data", { | ||
if(!inherits(conn, 'try-error')){ | ||
expect_is(skel<-catmaid_GET("1/10418394/0/0/compact-skeleton", conn=conn), 'response') | ||
expect_equivalent(neuronnames<-catmaid_POSTJ("/1/skeleton/neuronnames", conn=conn, | ||
body=list(pid=1, 'skids[1]'=10418394, 'skids[2]'=4453485)), | ||
list(`10418394` = "IPC10", `4453485` = "IPC1")) | ||
expect_equal(names(attributes(neuronnames)), c("names", "url", "headers")) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
context("catmaid metadata queries") | ||
|
||
# login is handled by test-connections | ||
conn=getOption('catmaid_temp_conn') | ||
|
||
test_that("get neuron names", { | ||
if(!inherits(conn, 'try-error')){ | ||
expect_equal(catmaid_get_neuronnames(pid=1, skids=c(10418394,4453485)), | ||
structure(c("IPC10", "IPC1"), .Names = c("10418394", "4453485"))) | ||
} | ||
}) | ||
|
||
context("catmaid neuron queries") | ||
|
||
test_that("get neuron", { | ||
if(!inherits(conn, 'try-error')){ | ||
expect_is(skel<-catmaid_get_compact_skeleton(pid=1, skid=10418394, conn=conn), 'list') | ||
} | ||
}) | ||
|
||
test_that("read.neron.catmaid", { | ||
if(!inherits(conn, 'try-error')){ | ||
expect_is(skel<-read.neuron.catmaid(pid=1, skid=10418394, conn=conn), 'neuron') | ||
} | ||
}) |