[ARVADOS] updated: 1.1.2-188-g64aee8c

Git user git at public.curoverse.com
Tue Jan 23 06:39:14 EST 2018


Summary of changes:
 sdk/R/R/Arvados.R                            |   1 -
 sdk/R/R/HttpRequest.R                        |   3 +-
 sdk/R/README                                 |   8 ++
 sdk/R/tests/testthat/fakes/FakeRESTService.R |  35 +++++++-
 sdk/R/tests/testthat/test-Arvados.R          | 123 ++++++++++++++++++++++++++-
 5 files changed, 161 insertions(+), 9 deletions(-)

       via  64aee8cfd4164f3c0dae26fe62cc9ee22b16782b (commit)
      from  c2a07597440e4db06481d2532adc317331df441b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 64aee8cfd4164f3c0dae26fe62cc9ee22b16782b
Author: Fuad Muhic <fmuhic at capeannenterprises.com>
Date:   Tue Jan 23 12:38:18 2018 +0100

    Added additional unit tests to Arvados class
    
    Arvados-DCO-1.1-Signed-off-by: Fuad Muhic <fmuhic at capeannenterprises.com>

diff --git a/sdk/R/R/Arvados.R b/sdk/R/R/Arvados.R
index cb36e49..a22ff73 100644
--- a/sdk/R/R/Arvados.R
+++ b/sdk/R/R/Arvados.R
@@ -79,7 +79,6 @@ Arvados <- R6::R6Class(
         updateCollection = function(uuid, newContent)
         {
             body <- list(list())
-            #test if this is needed
             names(body) <- c("collection")
             body$collection <- newContent
 
diff --git a/sdk/R/R/HttpRequest.R b/sdk/R/R/HttpRequest.R
index cc4d868..5cee567 100644
--- a/sdk/R/R/HttpRequest.R
+++ b/sdk/R/R/HttpRequest.R
@@ -64,7 +64,6 @@ HttpRequest <- R6::R6Class(
             h <- curl::new_handle()
             curl::handle_setopt(h, customrequest = "MOVE")
             curl::handle_setheaders(h, .list = headers)
-            print(url)
 
             propfindResponse <- curl::curl_fetch_memory(url, h)
         }
@@ -76,7 +75,7 @@ HttpRequest <- R6::R6Class(
         {
             finalQuery <- NULL
 
-            if(!is.null(filters))
+        if(!is.null(filters))
             {
                 filters <- sapply(filters, function(filter)
                 {
diff --git a/sdk/R/README b/sdk/R/README
index cc073d5..6b8cd3f 100644
--- a/sdk/R/README
+++ b/sdk/R/README
@@ -43,6 +43,10 @@ collectionList <- arv$listCollections(list(list("name", "like", "Test%")), limit
 collectionList$items_available # count of total number of items (may be more than returned due to paging)
 collectionList$items # items which match the filter criteria
 
+#Next example will list all collections even when the number of items is greater than maximum API limit
+
+collectionList <- arv$listAllCollections(list(list("name", "like", "Test%")))
+
 --------------------------------------------------------------------------------------------------------------------------------
 
 #Delete a collection:
@@ -203,6 +207,10 @@ arv$getProject("uuid")
 projects <- arv$listProjects(list(list("owner_uuid", "=", "aaaaa-j7d0g-ccccccccccccccc"))) # list subprojects of a project
 arv$listProjects(list(list("name","like","Example%"))) # list projects which have names beginning with Example
 
+#Next example will list all projects even when the number of items is greater than maximum API limit
+
+collectionList <- arv$listAllProjects(list(list("name","like","Example%")))
+
 --------------------------------------------------------------------------------------------------------------------------------
 
 #Delete a project:
diff --git a/sdk/R/tests/testthat/fakes/FakeRESTService.R b/sdk/R/tests/testthat/fakes/FakeRESTService.R
index c71a3ef..9c7203f 100644
--- a/sdk/R/tests/testthat/fakes/FakeRESTService.R
+++ b/sdk/R/tests/testthat/fakes/FakeRESTService.R
@@ -19,11 +19,15 @@ FakeRESTService <- R6::R6Class(
         readCallCount                 = NULL,
         writeCallCount                = NULL,
         writeBuffer                   = NULL,
+        filtersAreConfiguredCorrectly = NULL,
+        bodyIsConfiguredCorrectly     = NULL,
+        expectedFilterContent         = NULL,
 
         collectionContent = NULL,
-        returnContent = NULL,
+        returnContent     = NULL,
 
-        initialize = function(collectionContent = NULL, returnContent = NULL)
+        initialize = function(collectionContent = NULL, returnContent = NULL, 
+                              expectedFilterContent = NULL)
         {
             self$getResourceCallCount    <- 0
             self$createResourceCallCount <- 0
@@ -39,9 +43,12 @@ FakeRESTService <- R6::R6Class(
             self$getResourceSizeCallCount      <- 0
             self$readCallCount                 <- 0
             self$writeCallCount                <- 0
+            self$filtersAreConfiguredCorrectly <- FALSE
+            self$bodyIsConfiguredCorrectly     <- FALSE
 
-            self$collectionContent <- collectionContent
-            self$returnContent <- returnContent
+            self$collectionContent     <- collectionContent
+            self$returnContent         <- returnContent
+            self$expectedFilterContent <- expectedFilterContent
         },
 
         getWebDavHostName = function()
@@ -57,12 +64,22 @@ FakeRESTService <- R6::R6Class(
         listResources = function(resource, filters = NULL, limit = 100, offset = 0)
         {
             self$listResourcesCallCount <- self$listResourcesCallCount + 1
+
+            if(!is.null(self$expectedFilterContent) && !is.null(filters))
+               if(all.equal(filters, self$expectedFilterContent))
+                    self$filtersAreConfiguredCorrectly <- TRUE
+
             self$returnContent
         },
 
         fetchAllItems = function(resourceURL, filters)
         {
             self$fetchAllItemsCallCount <- self$fetchAllItemsCallCount + 1
+
+            if(!is.null(self$expectedFilterContent) && !is.null(filters))
+               if(all.equal(filters, self$expectedFilterContent))
+                    self$filtersAreConfiguredCorrectly <- TRUE
+
             self$returnContent
         },
 
@@ -75,12 +92,22 @@ FakeRESTService <- R6::R6Class(
         updateResource = function(resource, uuid, newContent)
         {
             self$updateResourceCallCount <- self$updateResourceCallCount + 1
+
+            if(!is.null(self$returnContent) && !is.null(newContent))
+               if(all.equal(newContent, self$returnContent))
+                    self$bodyIsConfiguredCorrectly <- TRUE
+
             self$returnContent
         },
 
         createResource = function(resource, content)
         {
             self$createResourceCallCount <- self$createResourceCallCount + 1
+
+            if(!is.null(self$returnContent) && !is.null(content))
+               if(all.equal(content, self$returnContent))
+                    self$bodyIsConfiguredCorrectly <- TRUE
+
             self$returnContent
         },
 
diff --git a/sdk/R/tests/testthat/test-Arvados.R b/sdk/R/tests/testthat/test-Arvados.R
index 8ebad95..25cf88f 100644
--- a/sdk/R/tests/testthat/test-Arvados.R
+++ b/sdk/R/tests/testthat/test-Arvados.R
@@ -56,7 +56,7 @@ test_that("getCollection delegates operation to RESTService class", {
     expect_that(fakeREST$getResourceCallCount, equals(1))
 }) 
 
-test_that("listCollection delegates operation to RESTService class", {
+test_that("listCollections delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
     fakeREST <- FakeRESTService$new()
@@ -67,7 +67,20 @@ test_that("listCollection delegates operation to RESTService class", {
     expect_that(fakeREST$listResourcesCallCount, equals(1))
 }) 
 
-test_that("listAllCollection delegates operation to RESTService class", {
+test_that("listCollections filter paramerter must be named 'collection'", {
+
+    filters <- list(list("name", "like", "MyCollection"))
+    names(filters) <- c("collection")
+    fakeREST <- FakeRESTService$new(expectedFilterContent = filters)
+    arv <- Arvados$new("token", "hostName")
+    arv$setRESTService(fakeREST)
+
+    arv$listCollections(list(list("name", "like", "MyCollection")))
+
+    expect_that(fakeREST$filtersAreConfiguredCorrectly, is_true())
+}) 
+
+test_that("listAllCollections delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
     fakeREST <- FakeRESTService$new()
@@ -78,6 +91,19 @@ test_that("listAllCollection delegates operation to RESTService class", {
     expect_that(fakeREST$fetchAllItemsCallCount, equals(1))
 }) 
 
+test_that("listAllCollections filter paramerter must be named 'collection'", {
+
+    filters <- list(list("name", "like", "MyCollection"))
+    names(filters) <- c("collection")
+    fakeREST <- FakeRESTService$new(expectedFilterContent = filters)
+    arv <- Arvados$new("token", "hostName")
+    arv$setRESTService(fakeREST)
+
+    arv$listAllCollections(list(list("name", "like", "MyCollection")))
+
+    expect_that(fakeREST$filtersAreConfiguredCorrectly, is_true())
+}) 
+
 test_that("deleteCollection delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
@@ -103,6 +129,22 @@ test_that("updateCollection delegates operation to RESTService class", {
     expect_that(fakeREST$updateResourceCallCount, equals(1))
 }) 
 
+test_that("updateCollection adds content to request parameter named 'collection'", {
+
+    collectionUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    body <- list(list())
+    names(body) <- c("collection")
+    body$collection <- list(name = "MyCollection", desc = "No description")
+    fakeREST <- FakeRESTService$new(returnContent = body)
+    arv <- Arvados$new("token", "hostName")
+    arv$setRESTService(fakeREST)
+
+    arv$updateCollection(collectionUUID, 
+                         list(name = "MyCollection", desc = "No description"))
+
+    expect_that(fakeREST$bodyIsConfiguredCorrectly, is_true())
+}) 
+
 test_that("createCollection delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
@@ -115,6 +157,20 @@ test_that("createCollection delegates operation to RESTService class", {
     expect_that(fakeREST$createResourceCallCount, equals(1))
 }) 
 
+test_that("createCollection adds content to request parameter named 'collection'", {
+
+    body <- list(list())
+    names(body) <- c("collection")
+    body$collection <- list(name = "MyCollection", desc = "No description")
+    fakeREST <- FakeRESTService$new(returnContent = body)
+    arv <- Arvados$new("token", "hostName")
+    arv$setRESTService(fakeREST)
+
+    arv$createCollection(list(name = "MyCollection", desc = "No description"))
+
+    expect_that(fakeREST$bodyIsConfiguredCorrectly, is_true())
+}) 
+
 test_that("getProject delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
@@ -138,6 +194,21 @@ test_that("listProjects delegates operation to RESTService class", {
     expect_that(fakeREST$listResourcesCallCount, equals(1))
 }) 
 
+test_that("listProjects filter contains additional 'group_class' field by default", {
+
+    filters <- list(list("name", "like", "MyProject"))
+    names(filters) <- c("groups")
+    filters[[length(filters) + 1]] <- list("group_class", "=", "project")
+
+    fakeREST <- FakeRESTService$new(expectedFilterContent = filters)
+    arv <- Arvados$new("token", "hostName")
+    arv$setRESTService(fakeREST)
+
+    arv$listProjects(list(list("name", "like", "MyProject")))
+
+    expect_that(fakeREST$filtersAreConfiguredCorrectly, is_true())
+}) 
+
 test_that("listAllProjects delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
@@ -149,6 +220,21 @@ test_that("listAllProjects delegates operation to RESTService class", {
     expect_that(fakeREST$fetchAllItemsCallCount, equals(1))
 }) 
 
+test_that("listAllProjects filter contains additional 'group_class' field by default", {
+
+    filters <- list(list("name", "like", "MyProject"))
+    names(filters) <- c("groups")
+    filters[[length(filters) + 1]] <- list("group_class", "=", "project")
+
+    fakeREST <- FakeRESTService$new(expectedFilterContent = filters)
+    arv <- Arvados$new("token", "hostName")
+    arv$setRESTService(fakeREST)
+
+    arv$listAllProjects(list(list("name", "like", "MyProject")))
+
+    expect_that(fakeREST$filtersAreConfiguredCorrectly, is_true())
+}) 
+
 test_that("deleteProject delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
@@ -174,6 +260,23 @@ test_that("updateProject delegates operation to RESTService class", {
     expect_that(fakeREST$updateResourceCallCount, equals(1))
 }) 
 
+test_that("updateProject adds content to request parameter named 'group'", {
+
+    projectUUID <- "aaaaa-j7d0g-ccccccccccccccc"
+    body <- list(list())
+    names(body) <- c("group")
+    body$group <- list(name = "MyProject", desc = "No description")
+
+    fakeREST <- FakeRESTService$new(returnContent = body)
+    arv <- Arvados$new("token", "hostName")
+    arv$setRESTService(fakeREST)
+
+    arv$updateProject(projectUUID,
+                      list(name = "MyProject", desc = "No description"))
+
+    expect_that(fakeREST$bodyIsConfiguredCorrectly, is_true())
+}) 
+
 test_that("createProject delegates operation to RESTService class", {
 
     arv <- Arvados$new("token", "hostName")
@@ -185,3 +288,19 @@ test_that("createProject delegates operation to RESTService class", {
 
     expect_that(fakeREST$createResourceCallCount, equals(1))
 }) 
+
+test_that("createProject request body contains 'goup_class' filed", {
+
+    body <- list(list())
+    names(body) <- c("group")
+    body$group <- c("group_class" = "project",
+                    list(name = "MyProject", desc = "No description"))
+
+    fakeREST <- FakeRESTService$new(returnContent = body)
+    arv <- Arvados$new("token", "hostName")
+    arv$setRESTService(fakeREST)
+
+    arv$createProject(list(name = "MyProject", desc = "No description"))
+
+    expect_that(fakeREST$bodyIsConfiguredCorrectly, is_true())
+}) 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list