Merge branch 'master' of git.curoverse.com:arvados into 13076-r-autogen-api
[arvados.git] / sdk / R / tests / testthat / test-Collection.R
index ec00ca3c66dbcc66d875abee3d810a9ba06b9cd9..56e09f85ce80a095088cb0a7dcf05a1f01761881 100644 (file)
@@ -8,9 +8,8 @@ test_that(paste("constructor creates file tree from text content",
     collectionContent <- c("animal", "animal/fish", "ball")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     root <- collection$get("")
 
@@ -24,9 +23,8 @@ test_that(paste("add raises exception if passed argumet is not",
     collectionContent <- c("animal", "animal/fish", "ball")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     newNumber <- 10
 
@@ -40,9 +38,8 @@ test_that("add raises exception if relative path is not valid", {
     collectionContent <- c("animal", "animal/fish", "ball")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     newPen <- ArvadosFile$new("pen")
 
@@ -56,9 +53,8 @@ test_that("add raises exception if content name is empty string", {
     collectionContent <- c("animal", "animal/fish")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     rootFolder <- Subcollection$new("")
 
@@ -72,9 +68,8 @@ test_that(paste("add adds ArvadosFile or Subcollection",
     collectionContent <- c("animal", "animal/fish", "ball")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     newDog <- ArvadosFile$new("dog")
     collection$add(newDog, "animal")
@@ -91,9 +86,8 @@ test_that("create raises exception if passed argumet is not character vector", {
     collectionContent <- c("animal", "animal/fish", "ball")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     expect_that(collection$create(10),
                 throws_error("Expected character vector, got (numeric).", 
@@ -108,9 +102,8 @@ test_that("create raises exception if relative path is not valid", {
 
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     newPen <- ArvadosFile$new("pen")
 
@@ -125,9 +118,8 @@ test_that(paste("create adds files specified by fileNames",
     collectionContent <- c("animal", "animal/fish", "ball")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     files <- c("dog", "cat")
     collection$create(files, "animal")
@@ -147,9 +139,8 @@ test_that("remove raises exception if passed argumet is not character vector", {
     collectionContent <- c("animal", "animal/fish", "ball")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     expect_that(collection$remove(10),
                 throws_error("Expected character vector, got (numeric).", 
@@ -161,9 +152,8 @@ test_that("remove raises exception if user tries to remove root folder", {
     collectionContent <- c("animal", "animal/fish")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     expect_that(collection$remove(""),
                 throws_error("You can't delete root folder.", fixed = TRUE))
@@ -175,9 +165,8 @@ test_that(paste("remove removes files specified by paths",
     collectionContent <- c("animal", "animal/fish", "animal/dog", "animal/cat", "ball")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     collection$remove(c("animal/dog", "animal/cat"))
 
@@ -197,9 +186,8 @@ test_that(paste("move moves content to a new location inside file tree",
     collectionContent <- c("animal", "animal/dog", "ball")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     collection$move("animal/dog", "dog")
 
@@ -216,9 +204,8 @@ test_that("move raises exception if new location is not valid", {
     collectionContent <- c("animal", "animal/fish", "ball")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     expect_that(collection$move("fish", "object"),
                 throws_error("Content you want to move doesn't exist in the collection.",
@@ -230,9 +217,8 @@ test_that("getFileListing returns sorted collection content received from REST s
     collectionContent <- c("animal", "animal/fish", "ball")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     contentMatchExpected <- all(collection$getFileListing() == 
                                 c("animal", "animal/fish", "ball"))
@@ -248,9 +234,8 @@ test_that("get returns arvados file or subcollection from internal tree structur
     collectionContent <- c("animal", "animal/fish", "ball")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    api <- Arvados$new("myToken", "myHostName")
-    api$setRESTService(fakeREST)
-    collection <- Collection$new(api, "myUUID")
+    collection <- Collection$new("fakeUUID")
+    collection$setRESTService(fakeREST)
 
     fish <- collection$get("animal/fish")
     fishIsNotNull <- !is.null(fish)