[ARVADOS] updated: 400829b3835f0a129116a2eed926d12a0636aeab

git at public.curoverse.com git at public.curoverse.com
Mon Jun 9 13:36:39 EDT 2014


Summary of changes:
 .../app/controllers/application_controller.rb      |  12 +-
 .../test/functional/application_controller_test.rb | 154 ++++++++-------------
 2 files changed, 62 insertions(+), 104 deletions(-)

       via  400829b3835f0a129116a2eed926d12a0636aeab (commit)
       via  f6e5ba4510e2072415a8d6b5369b11b8003ddafa (commit)
      from  55b94087ff4590c54cf1f43d941c6cb24153dded (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 400829b3835f0a129116a2eed926d12a0636aeab
Author: radhika <radhika at curoverse.com>
Date:   Mon Jun 9 13:24:09 2014 -0400

    2871: more tests

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 1090fc6..29b76db 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -461,9 +461,9 @@ class ApplicationController < ActionController::Base
   # helper method to get links for given object or uuid
   helper_method :links_for_object
   def links_for_object object_or_uuid
-    uuid = object_or_uuid.is_a?(String) ? object_or_uuid : object_or_uuid.uuid
+    raise ArgumentError, 'No input argument' unless object_or_uuid
     preload_links_for_objects([object_or_uuid])
-
+    uuid = object_or_uuid.is_a?(String) ? object_or_uuid : object_or_uuid.uuid
     @all_links_for[uuid] ||= []
   end
 
diff --git a/apps/workbench/test/functional/application_controller_test.rb b/apps/workbench/test/functional/application_controller_test.rb
index 3fdf65c..fbad1d7 100644
--- a/apps/workbench/test/functional/application_controller_test.rb
+++ b/apps/workbench/test/functional/application_controller_test.rb
@@ -2,6 +2,10 @@ require 'test_helper'
 
 class ApplicationControllerTest < ActionController::TestCase
 
+  setup do
+    @user_dataclass = ArvadosBase.resource_class_for_uuid(api_fixture('users')['active']['uuid'])
+  end
+
   test "links for object" do
     use_token :active
 
@@ -29,25 +33,17 @@ class ApplicationControllerTest < ActionController::TestCase
     assert links.size == 0, 'Expected no links'
   end
 
-  test "preload links for given uuids" do
+  test "links for nil object" do
     use_token :active
 
     ac = ApplicationController.new
 
-    link_head_uuid1 = api_fixture('links')['foo_file_readable_by_active']['head_uuid']
-    link_head_uuid2 = api_fixture('links')['bar_file_readable_by_active']['head_uuid']
-
-    uuids = [link_head_uuid1, link_head_uuid2]
-    links = ac.send :preload_links_for_objects, uuids
-
-    assert links, 'Expected links'
-    assert links.is_a?(Hash), 'Expected a hash'
-    assert links.size == 2, 'Expected two objects in the preloaded links hash'
-    assert links[link_head_uuid1], 'Expected links for the passed in head_uuid'
-    assert links[link_head_uuid2], 'Expected links for the passed in head_uuid'
+    assert_raise ArgumentError do
+      ac.send :links_for_object, nil
+    end
   end
 
-  test "preload links for object and uuids" do
+  test "preload links for objects and uuids" do
     use_token :active
 
     ac = ApplicationController.new
@@ -77,26 +73,6 @@ class ApplicationControllerTest < ActionController::TestCase
     assert links[link1_head_uuid], 'Expected links for the passed in link head_uuid'
   end
 
-  test "preload links for wrong typed input" do
-    use_token :active
-
-    ac = ApplicationController.new
-
-    assert_raise ArgumentError do
-      ac.send :preload_links_for_objects, 'input not an array'
-    end
-  end
-
-  test "preload links for nil input" do
-    use_token :active
-
-    ac = ApplicationController.new
-
-    assert_raise ArgumentError do
-      ac.send :preload_links_for_objects, nil
-    end
-  end
-
   test "preload links for empty array input" do
     use_token :active
 
@@ -109,15 +85,32 @@ class ApplicationControllerTest < ActionController::TestCase
     assert links.size == 0, 'Expected no objects in the preloaded links hash'
   end
 
+  [ [:preload_links_for_objects, 'input not an array'],
+    [:preload_links_for_objects, nil],
+    [:preload_collections_for_objects, 'input not an array'],
+    [:preload_collections_for_objects, nil],
+    [:preload_log_collections_for_objects, 'input not an array'],
+    [:preload_log_collections_for_objects, nil],
+    [:preload_objects_for_dataclass, 'input not an array'],
+    [:preload_objects_for_dataclass, nil],    
+  ].each do |input|
+    test "preload links for wrong type input #{input}" do
+      use_token :active
+
+      ac = ApplicationController.new
+
+      assert_raise ArgumentError do
+        ac.send input[0], input[1]
+      end
+    end
+  end
+
   test "get 10 objects of data class user" do
     use_token :active
 
     ac = ApplicationController.new
 
-    uuid = api_fixture('users')['active']['uuid']
-
-    dataclass = ArvadosBase.resource_class_for_uuid(uuid)
-    objects = ac.send :get_n_objects_of_class, dataclass, 10
+    objects = ac.send :get_n_objects_of_class, @user_dataclass, 10
 
     assert objects, 'Expected objects'
     assert objects.is_a?(ArvadosResourceList), 'Expected an ArvadosResourceList'
@@ -127,54 +120,24 @@ class ApplicationControllerTest < ActionController::TestCase
     assert_equal 'User', first_object.class.name, 'Expected user object'
 
     # invoke it again. this time, the preloaded info will be returned
-    objects = ac.send :get_n_objects_of_class, dataclass, 10
+    objects = ac.send :get_n_objects_of_class, @user_dataclass, 10
     assert objects, 'Expected objects'
     assert_equal 'User', objects.first.class.name, 'Expected user object'
   end
 
-  test "get objects for incorrect input" do
-    use_token :active
+  [ ['User', 10],
+    [nil, 10],
+    [@user_dataclass, 0],
+    [@user_dataclass, -1],
+    [@user_dataclass, nil] ].each do |input|
+    test "get_n_objects for incorrect input #{input}" do
+      use_token :active
 
-    ac = ApplicationController.new
+      ac = ApplicationController.new
 
-    assert_raise ArgumentError do
-      ac.send :get_n_objects_of_class, 'User', 10
-    end
-  end
-
-  test "get objects for nil data class" do
-    use_token :active
-
-    ac = ApplicationController.new
-
-    assert_raise ArgumentError do
-      ac.send :get_n_objects_of_class, nil, 10
-    end
-  end
-
-  test "get objects of data class user with no limit specified" do
-    use_token :active
-
-    ac = ApplicationController.new
-
-    uuid = api_fixture('users')['active']['uuid']
-
-    dataclass = ArvadosBase.resource_class_for_uuid(uuid)
-    assert_raise ArgumentError do
-      ac.send :get_n_objects_of_class, dataclass
-    end
-  end
-
-  test "get objects of data class user with incorrect limit size" do
-    use_token :active
-
-    ac = ApplicationController.new
-
-    uuid = api_fixture('users')['active']['uuid']
-
-    dataclass = ArvadosBase.resource_class_for_uuid(uuid)
-    assert_raise ArgumentError do
-      ac.send :get_n_objects_of_class, dataclass, 0
+      assert_raise ArgumentError do
+        ac.send :get_n_objects_of_class, input[0], input[1]
+      end
     end
   end
 
@@ -202,7 +165,7 @@ class ApplicationControllerTest < ActionController::TestCase
 
     assert collections, 'Expected collections'
     assert collections.is_a?(Array), 'Expected an array'
-    assert collections.size == 0, 'Expected no collection'
+    assert collections.size == 0, 'Expected no collections in response'
   end
 
   test "preload collections for given uuids" do
@@ -232,26 +195,6 @@ class ApplicationControllerTest < ActionController::TestCase
     assert collections[uuid1], 'Expected collections for the passed in uuid'
   end
 
-  test "preload collections for wrong typed input" do
-    use_token :active
-
-    ac = ApplicationController.new
-
-    assert_raise ArgumentError do
-      ac.send :preload_collections_for_objects, 'input not an array'
-    end
-  end
-
-  test "preload collections for nil input" do
-    use_token :active
-
-    ac = ApplicationController.new
-
-    assert_raise ArgumentError do
-      ac.send :preload_collections_for_objects, nil
-    end
-  end
-
   test "preload collections for empty array input" do
     use_token :active
 
@@ -263,4 +206,5 @@ class ApplicationControllerTest < ActionController::TestCase
     assert collections.is_a?(Hash), 'Expected a hash'
     assert collections.size == 0, 'Expected no objects in the preloaded collections hash'
   end
+
 end

commit f6e5ba4510e2072415a8d6b5369b11b8003ddafa
Author: radhika <radhika at curoverse.com>
Date:   Mon Jun 9 12:09:56 2014 -0400

    2871: test invoking methods a second time to retrieve preloaded data

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 3b8aa9a..1090fc6 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -479,7 +479,7 @@ class ApplicationController < ActionController::Base
 
     # if already preloaded for all of these uuids, return
     if not uuids.select { |x| @all_links_for[x].nil? }.any?
-      return
+      return @all_links_for
     end
 
     uuids.each do |x|
@@ -531,7 +531,7 @@ class ApplicationController < ActionController::Base
 
     # if already preloaded for all of these uuids, return
     if not uuids.select { |x| @all_collections_for[x].nil? }.any?
-      return
+      return @all_collections_for
     end
 
     uuids.each do |x|
@@ -579,7 +579,7 @@ class ApplicationController < ActionController::Base
 
     # if already preloaded for all of these uuids, return
     if not uuids.select { |x| @all_log_collections_for[x].nil? }.any?
-      return
+      return @all_log_collections_for
     end
 
     uuids.each do |x|
@@ -610,7 +610,7 @@ class ApplicationController < ActionController::Base
 
     # if already preloaded for all of these uuids, return
     if not uuids.select { |x| @objects_for[x].nil? }.any?
-      return
+      return @objects_for
     end
 
     dataclass.where(uuid: uuids).each do |obj|
diff --git a/apps/workbench/test/functional/application_controller_test.rb b/apps/workbench/test/functional/application_controller_test.rb
index 8b6270d..3fdf65c 100644
--- a/apps/workbench/test/functional/application_controller_test.rb
+++ b/apps/workbench/test/functional/application_controller_test.rb
@@ -68,6 +68,13 @@ class ApplicationControllerTest < ActionController::TestCase
     assert links[link1_head_uuid], 'Expected links for the passed in link head_uuid'
     assert links[link2_object_uuid], 'Expected links for the passed in object uuid'
     assert links[link3_head_uuid], 'Expected links for the passed in link head_uuid'
+
+    # invoke again for this same input. this time, the preloaded data will be returned
+    links = ac.send :preload_links_for_objects, uuids
+    assert links, 'Expected links'
+    assert links.is_a?(Hash), 'Expected a hash'
+    assert links.size == 3, 'Expected two objects in the preloaded links hash'
+    assert links[link1_head_uuid], 'Expected links for the passed in link head_uuid'
   end
 
   test "preload links for wrong typed input" do
@@ -216,6 +223,13 @@ class ApplicationControllerTest < ActionController::TestCase
     assert_equal collections[uuid1].size, 1, 'Expected one collection for the passed in uuid'
     assert collections[uuid2], 'Expected collections for the passed in uuid'
     assert_equal collections[uuid2].size, 1, 'Expected one collection for the passed in uuid'
+
+    # invoke again for this same input. this time, the preloaded data will be returned
+    collections = ac.send :preload_collections_for_objects, uuids
+    assert collections, 'Expected collection'
+    assert collections.is_a?(Hash), 'Expected a hash'
+    assert collections.size == 2, 'Expected two objects in the preloaded collection hash'
+    assert collections[uuid1], 'Expected collections for the passed in uuid'
   end
 
   test "preload collections for wrong typed input" do

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list