5011: Fix run_and_find_collection so it works without --portable-data-hash.
authorTom Clegg <tom@curoverse.com>
Fri, 30 Jan 2015 23:34:26 +0000 (18:34 -0500)
committerTom Clegg <tom@curoverse.com>
Sun, 1 Feb 2015 01:35:10 +0000 (20:35 -0500)
sdk/python/tests/test_arv_put.py

index d8768778ec96df593775272343465f00079ef785..9d19e8d79a52471a21a6084cff11f44de27dcb86 100644 (file)
@@ -523,8 +523,10 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
             stdin=subprocess.PIPE, stdout=subprocess.PIPE,
             stderr=subprocess.PIPE, env=self.ENVIRON)
         stdout, stderr = pipe.communicate(text)
+        search_key = ('portable_data_hash'
+                      if '--portable-data-hash' in extra_args else 'uuid')
         collection_list = arvados.api('v1').collections().list(
-            filters=[['portable_data_hash', '=', stdout.strip()]]).execute().get('items', [])
+            filters=[[search_key, '=', stdout.strip()]]).execute().get('items', [])
         self.assertEqual(1, len(collection_list))
         return collection_list[0]
 
@@ -536,12 +538,13 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
         self.assertEqual(4, collection['redundancy'])
 
     def test_put_collection_with_default_redundancy(self):
-        collection = self.run_and_find_collection("", [])
+        collection = self.run_and_find_collection("")
         self.assertEqual(2, collection['redundancy'])
 
     def test_put_collection_with_unnamed_project_link(self):
-        link = self.run_and_find_collection("Test unnamed collection",
-                                      ['--portable-data-hash', '--project-uuid', self.PROJECT_UUID])
+        link = self.run_and_find_collection(
+            "Test unnamed collection",
+            ['--portable-data-hash', '--project-uuid', self.PROJECT_UUID])
         username = pwd.getpwuid(os.getuid()).pw_name
         self.assertRegexpMatches(
             link['name'],
@@ -549,8 +552,9 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
 
     def test_put_collection_with_name_and_no_project(self):
         link_name = 'Test Collection Link in home project'
-        collection = self.run_and_find_collection("Test named collection in home project",
-                                      ['--portable-data-hash', '--name', link_name])
+        collection = self.run_and_find_collection(
+            "Test named collection in home project",
+            ['--portable-data-hash', '--name', link_name])
         self.assertEqual(link_name, collection['name'])
         my_user_uuid = self.current_user()['uuid']
         self.assertEqual(my_user_uuid, collection['owner_uuid'])