Merge branch 'master' into 7478-anm-spot-instances
[arvados.git] / sdk / R / tests / testthat / test-ArvadosFile.R
index 67ed0f6240938562ff5cb7894201205926c3c494..fb14888aab91b982d88dbdddca0be9589f757fb8 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
 source("fakes/FakeRESTService.R")
 
 context("ArvadosFile")
@@ -45,8 +49,9 @@ test_that(paste("getSizeInBytes delegates size calculation",
     returnSize <- 100
     fakeREST <- FakeRESTService$new(collectionContent, returnSize)
 
-    collection <- Collection$new("fakeUUID")
-    collection$setRESTService(fakeREST)
+    api <- Arvados$new("myToken", "myHostName")
+    api$setRESTService(fakeREST)
+    collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
 
     resourceSize <- fish$getSizeInBytes()
@@ -80,8 +85,9 @@ test_that("read raises exception offset or length is negative number", {
     collectionContent <- c("animal", "animal/fish")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    collection <- Collection$new("fakeUUID")
-    collection$setRESTService(fakeREST)
+    api <- Arvados$new("myToken", "myHostName")
+    api$setRESTService(fakeREST)
+    collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
 
     expect_that(fish$read(contentType = "text", offset = -1),
@@ -98,8 +104,9 @@ test_that("read delegates reading operation to REST service class", {
     readContent <- "my file"
     fakeREST <- FakeRESTService$new(collectionContent, readContent)
 
-    collection <- Collection$new("fakeUUID")
-    collection$setRESTService(fakeREST)
+    api <- Arvados$new("myToken", "myHostName")
+    api$setRESTService(fakeREST)
+    collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
     
     fileContent <- fish$read("text")
@@ -115,8 +122,9 @@ test_that(paste("connection delegates connection creation ro RESTService class",
     collectionContent <- c("animal", "animal/fish")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    collection <- Collection$new("fakeUUID")
-    collection$setRESTService(fakeREST)
+    api <- Arvados$new("myToken", "myHostName")
+    api$setRESTService(fakeREST)
+    collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
 
     connection <- fish$connection("r")
@@ -130,8 +138,9 @@ test_that(paste("connection returns textConnection opened",
     collectionContent <- c("animal", "animal/fish")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    collection <- Collection$new("fakeUUID")
-    collection$setRESTService(fakeREST)
+    api <- Arvados$new("myToken", "myHostName")
+    api$setRESTService(fakeREST)
+    collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
 
     connection <- fish$connection("w")
@@ -151,8 +160,9 @@ test_that("flush sends data stored in a connection to a REST server", {
     collectionContent <- c("animal", "animal/fish")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    collection <- Collection$new("fakeUUID")
-    collection$setRESTService(fakeREST)
+    api <- Arvados$new("myToken", "myHostName")
+    api$setRESTService(fakeREST)
+    collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
 
     connection <- fish$connection("w")
@@ -178,8 +188,9 @@ test_that("write delegates writing operation to REST service class", {
     collectionContent <- c("animal", "animal/fish")
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    collection <- Collection$new("fakeUUID")
-    collection$setRESTService(fakeREST)
+    api <- Arvados$new("myToken", "myHostName")
+    api$setRESTService(fakeREST)
+    collection <- Collection$new(api, "myUUID")
     fish <- collection$get("animal/fish")
     
     fileContent <- fish$write("new file content")
@@ -208,8 +219,10 @@ test_that(paste("move raises exception if newLocationInCollection",
 
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    collection <- Collection$new("fakeUUID")
-    collection$setRESTService(fakeREST)
+    api <- Arvados$new("myToken", "myHostName")
+    api$setRESTService(fakeREST)
+
+    collection <- Collection$new(api, "myUUID")
     dog <- collection$get("animal/dog")
 
     expect_that(dog$move("objects/dog"),
@@ -227,8 +240,9 @@ test_that("move raises exception if new location contains content with the same
 
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    collection <- Collection$new("fakeUUID")
-    collection$setRESTService(fakeREST)
+    api <- Arvados$new("myToken", "myHostName")
+    api$setRESTService(fakeREST)
+    collection <- Collection$new(api, "myUUID")
     dog <- collection$get("animal/dog")
 
     expect_that(dog$move("dog"),
@@ -247,8 +261,9 @@ test_that("move moves arvados file inside collection tree", {
 
     fakeREST <- FakeRESTService$new(collectionContent)
 
-    collection <- Collection$new("fakeUUID")
-    collection$setRESTService(fakeREST)
+    api <- Arvados$new("myToken", "myHostName")
+    api$setRESTService(fakeREST)
+    collection <- Collection$new(api, "myUUID")
     dog <- collection$get("animal/dog")
 
     dog$move("dog")
@@ -257,4 +272,4 @@ test_that("move moves arvados file inside collection tree", {
 
     expect_that(dogIsNullOnOldLocation, is_true())
     expect_that(dogExistsOnNewLocation, is_true())
-}) 
+})