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
86 changes: 86 additions & 0 deletions data/api/rlabkey-api-experiment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,90 @@
]]>
</response>
</test>
<test name="create sample type and load data" type="post">
<url>
<![CDATA[
library(Rlabkey)
df <- data.frame(name=c("test1","test2","test3"), customInt=c(1:3), customString=c("aaa", "bbb", "ccc"))
info <- labkey.domain.createAndLoad(baseUrl=labkey.url.base, folderPath="%projectName%", domainKind="SampleSet", df=df, name="test sample type with load data")
print(paste("Create successful = ", info$success, sep=""))
print(paste("Rows via createAndLoad = ", info$rowCount, sep=""))
]]>
</url>
<response>
<![CDATA[
Create successful = TRUE
Rows via createAndLoad = 3
]]>
</response>
</test>
<test name="create data class and load data" type="post">
<url>
<![CDATA[
library(Rlabkey)
df <- data.frame(name=c("test1","test2","test3"), customInt=c(1:3), customString=c("aaa", "bbb", "ccc"))
info <- labkey.domain.createAndLoad(baseUrl=labkey.url.base, folderPath="%projectName%", domainKind="DataClass", df=df, name="test data class with load data")
print(paste("Create successful = ", info$success, sep=""))
print(paste("Rows via createAndLoad = ", info$rowCount, sep=""))
]]>
</url>
<response>
<![CDATA[
Create successful = TRUE
Rows via createAndLoad = 3
]]>
</response>
</test>
<test name="insert and merge into sample type" type="post">
<url>
<![CDATA[
library(Rlabkey)
name <- "test insert and merge into sample type"
df <- data.frame(name=c("test1","test2","test3"), customInt=c(1:3), customString=c("aaa", "bbb", "ccc"))
info <- labkey.domain.createAndLoad(baseUrl=labkey.url.base, folderPath="%projectName%", domainKind="SampleSet", df=df, name=name)
print(paste("Rows via createAndLoad = ", info$rowCount, sep=""))

# insert via labkey.query.import
df <- data.frame(name=c("test4","test5"), customInt=c(4:5), customString=c("aaa", "bbb"))
info <- labkey.query.import(
baseUrl=labkey.url.base, folderPath="%projectName%",
schemaName="samples", queryName=name, toImport=df
)
print(paste("Rows via insert = ", info$rowCount, sep=""))

# now try labkey.query.import which should fail with duplicate key message
df <- data.frame(
name=c("test1","test2","test3","test4","test5","test6","test7","test8","test9","test10"),
customInt=c(101:110)
)
info <- labkey.query.import(
baseUrl=labkey.url.base, folderPath="%projectName%",
schemaName="samples", queryName=name, toImport=df
)
print(paste("Error = ", info$exception, sep=""))

# now merge via labkey.query.import, 5 update and 5 inserts
df <- data.frame(
name=c("test1","test2","test3","test4","test5","test6","test7","test8","test9","test10"),
customInt=c(101:110)
)
info <- labkey.query.import(
baseUrl=labkey.url.base, folderPath="%projectName%",
schemaName="samples", queryName=name, toImport=df,
options=list(insertOption = "MERGE", auditBehavior = "DETAILED")
)
print(paste("Rows via merge = ", info$rowCount, sep=""))
print(paste("Has audit transaction id = ", !is.na(info$transactionAuditId), sep=""))
]]>
</url>
<response>
<![CDATA[
Rows via createAndLoad = 3
Rows via insert = 2
duplicate key
Rows via merge = 10
Has audit transaction id = TRUE
]]>
</response>
</test>
</ApiTests>
17 changes: 17 additions & 0 deletions data/api/rlabkey-api-list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,21 @@
]]>
</response>
</test>
<test name="create list and load data" type="post">
<url>
<![CDATA[
library(Rlabkey)
df <- data.frame(intKey=c(1:3), customInt=c(1:3), customString=c("aaa", "bbb", "ccc"))
info <- labkey.domain.createAndLoad(baseUrl=labkey.url.base, folderPath="%projectName%", domainKind="IntList", df=df, name="test list with load data", options=list(keyName = "intKey"))
print(paste("Create successful = ", info$success, sep=""))
print(paste("Rows via createAndLoad = ", info$rowCount, sep=""))
]]>
</url>
<response>
<![CDATA[
Create successful = TRUE
Rows via createAndLoad = 3
]]>
</response>
</test>
</ApiTests>
17 changes: 17 additions & 0 deletions data/api/rlabkey-api-study.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,21 @@
]]>
</response>
</test>
<test name="create dataset and load data" type="post">
<url>
<![CDATA[
library(Rlabkey)
df <- data.frame(ParticipantID=c(1,1,1), Visit=c(1,2,3), customInt=c(1:3), customString=c("aaa", "bbb", "ccc"))
info <- labkey.domain.createAndLoad(baseUrl=labkey.url.base, folderPath="%projectName%", domainKind="StudyDatasetVisit", df=df, name="test dataset with load data")
print(paste("Create successful = ", info$success, sep=""))
print(paste("Rows via createAndLoad = ", info$rowCount, sep=""))
]]>
</url>
<response>
<![CDATA[
Create successful = TRUE
Rows via createAndLoad = 3
]]>
</response>
</test>
</ApiTests>
2 changes: 1 addition & 1 deletion data/api/rlabkey-api-webdav.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
<![CDATA[
library(Rlabkey)
c("remote file.exists pre", file.exists("%remoteDir%/writeChecks/putMe.txt"))
c("webdav.put", labkey.webdav.put(localFile="%remoteDir%/readChecks/getMe.txt", baseUrl=labkey.url.base, folderPath="%projectName%", remoteFilePath="remote/writeChecks/putMe.txt"))
c("webdav.put", labkey.webdav.put(localFile="%remoteDir%/readChecks/getMe.txt", baseUrl=labkey.url.base, folderPath="%projectName%", remoteFilePath="remote/writeChecks/putMe.txt", description="with test description"))
c("remote file.exists post", file.exists("%remoteDir%/writeChecks/putMe.txt"))
c("remote file.info.size", file.info("%remoteDir%/writeChecks/putMe.txt")$size)
]]>
Expand Down