[ARVADOS] updated: 83bcea2d5b07cfba63d3252a98d4ad75528e18f4

git at public.curoverse.com git at public.curoverse.com
Tue Sep 9 11:53:52 EDT 2014


Summary of changes:
 sdk/python/arvados/commands/put.py | 12 ++++++------
 sdk/python/tests/test_arv_put.py   | 12 +++++++++---
 2 files changed, 15 insertions(+), 9 deletions(-)

       via  83bcea2d5b07cfba63d3252a98d4ad75528e18f4 (commit)
      from  8eeb2671b0a9815345218da335731a31230ada13 (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 83bcea2d5b07cfba63d3252a98d4ad75528e18f4
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Tue Sep 9 11:53:48 2014 -0400

    3453: Rename check_project_exists to desired_project_uuid.  Now raises and
    catches distinct apiclient.errors.Error, ValueError errors for project not
    found or invalid uuid.

diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index 0645cb4..15551fa 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -348,7 +348,7 @@ def progress_writer(progress_func, outfile=sys.stderr):
 def exit_signal_handler(sigcode, frame):
     sys.exit(-sigcode)
 
-def check_project_exists(api_client, project_uuid):
+def desired_project_uuid(api_client, project_uuid):
     if project_uuid:
         if arvados.util.user_uuid_pattern.match(project_uuid):
             api_client.users().get(uuid=project_uuid).execute()
@@ -357,7 +357,7 @@ def check_project_exists(api_client, project_uuid):
             api_client.groups().get(uuid=project_uuid).execute()
             return project_uuid
         else:
-            raise Exception("Not a valid project uuid: {}".format(project_uuid))
+            raise ValueError("Not a valid project uuid: {}".format(project_uuid))
     else:
         return api_client.users().current().execute()['uuid']
 
@@ -387,9 +387,9 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
 
     # Determine the parent project
     try:
-        project_uuid = check_project_exists(api_client, args.project_uuid)
-    except Exception as error:
-        print >>stderr, "Project {} not found: {}".format(args.project_uuid, error)
+        project_uuid = desired_project_uuid(api_client, args.project_uuid)
+    except (apiclient.errors.Error, ValueError) as error:
+        print >>stderr, error
         sys.exit(1)
 
     if args.progress:
@@ -467,7 +467,7 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
 
         except apiclient.errors.Error as error:
             print >>stderr, (
-                "arv-put: Error adding Collection to project: {}.".format(
+                "arv-put: Error creating Collection on project: {}.".format(
                     error))
             status = 1
 
diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py
index 3b0ee13..c7b01bc 100644
--- a/sdk/python/tests/test_arv_put.py
+++ b/sdk/python/tests/test_arv_put.py
@@ -440,19 +440,25 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
 
     def test_check_real_project_found(self):
         self.authorize_with('active')
-        self.assertTrue(arv_put.check_project_exists(arv_put.api_client, self.PROJECT_UUID),
+        self.assertTrue(arv_put.desired_project_uuid(arv_put.api_client, self.PROJECT_UUID),
                         "did not correctly find test fixture project")
 
-    def test_check_error_finding_nonexistent_project(self):
+    def test_check_error_finding_nonexistent_uuid(self):
         BAD_UUID = 'zzzzz-zzzzz-zzzzzzzzzzzzzzz'
         self.authorize_with('active')
         try:
-            result = arv_put.check_project_exists(arv_put.api_client, BAD_UUID)
+            result = arv_put.desired_project_uuid(arv_put.api_client, BAD_UUID)
         except ValueError as error:
             self.assertIn(BAD_UUID, error.message)
         else:
             self.assertFalse(result, "incorrectly found nonexistent project")
 
+    def test_check_error_finding_nonexistent_project(self):
+        BAD_UUID = 'zzzzz-tpzed-zzzzzzzzzzzzzzz'
+        self.authorize_with('active')
+        with self.assertRaises(apiclient.errors.HttpError):
+            result = arv_put.desired_project_uuid(arv_put.api_client, BAD_UUID)
+
     def test_short_put_from_stdin(self):
         # Have to run this as an integration test since arv-put can't
         # read from the tests' stdin.

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list