[ARVADOS] updated: 369724b0dce040664d3d84b40029c6c1f426fa8e

git at public.curoverse.com git at public.curoverse.com
Thu Oct 8 13:37:38 EDT 2015


Summary of changes:
 sdk/python/arvados/__init__.py             |  8 +++----
 sdk/python/tests/test_task_output_retry.py | 38 +++++++++---------------------
 2 files changed, 14 insertions(+), 32 deletions(-)

       via  369724b0dce040664d3d84b40029c6c1f426fa8e (commit)
      from  db79733caa09c2ecaae16c4661a9a38fcf41ef1f (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 369724b0dce040664d3d84b40029c6c1f426fa8e
Author: Bryan Cosca <bcosc at curoverse.com>
Date:   Thu Oct 8 13:37:31 2015 -0400

    6600: Fail test works

diff --git a/sdk/python/arvados/__init__.py b/sdk/python/arvados/__init__.py
index 9ac0bc8..1367ccd 100644
--- a/sdk/python/arvados/__init__.py
+++ b/sdk/python/arvados/__init__.py
@@ -53,15 +53,13 @@ def task_set_output(self,s,api_client=None,num_retries=5):
                                                       'progress':1.0
                                                      }).execute()
         except errors.ApiError as error:
-            print "we threw the error"
-            print dir(error)
-            print error.resp
+            print "we raised"
+            print error
             if retry.check_http_response_success(error.resp.status) is None and tries_left > 0: #status_code for HttpError
+                print "task_set_output: job_tasks().update() raised {}, retrying with {} tries left".format(repr(error),tries_left)
                 logger.debug("task_set_output: job_tasks().update() raised {}, retrying with {} tries left".format(repr(error),tries_left))
             else:
                 raise
-        except:
-            print "sup"
 
 _current_task = None
 def current_task(api_client=None, num_retries=5):
diff --git a/sdk/python/tests/test_task_output_retry.py b/sdk/python/tests/test_task_output_retry.py
index 4b3af13..d75ba50 100644
--- a/sdk/python/tests/test_task_output_retry.py
+++ b/sdk/python/tests/test_task_output_retry.py
@@ -41,39 +41,25 @@ class ApiClientRetrytestMixin(object):
     def run_method(self, *args, **kwargs):
         raise NotImplementedError("test subclasses must define run_method")        
 
-    def check_success(self, expected=None, api_client=None, *args, **kwargs):
+    def check_success(self, expected=None, *args, **kwargs):
         if expected is None:
             expected = self.DEFAULT_EXPECT
-        self.assertEqual(expected, self.run_method(api_client=api_client, *args, **kwargs))
+        self.assertEqual(expected, self.run_method)
 
-    def check_exception(self, error_class=None, api_client=None, *args, **kwargs):
+    def check_exception(self, error_class=None, *args, **kwargs):
         if error_class is None:
             error_class = self.DEFAULT_EXCEPTION
-        #print error_class.failureException
-        #self.run_method(api_client=api_client)
+        print "we raised error class"
         print error_class
-        self.assertRaises(error_class, self.run_method(api_client=api_client), *args, **kwargs)
+        self.assertRaises(error_class, self.run_method)
 
-#    def test_immediate_success(self):
-#        with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 200) as api_client:
-#            self.check_success(api_client=api_client)
+    def test_immediate_success(self):
+        with tutil.mock_responses('', 200):
+            self.check_success()
 
     def test_immediate_failure(self):
-        api_client = mock.MagicMock()
-#        with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 400), tutil.skip_sleep, \
-#                            self.assertRaises(arvados.errors.HttpError) as err_check:
-        with tutil.mock_responses('', 500, 400) as req_mock:
-            print dir(req_mock)
-            print req_mock
-            #api_client.job_tasks().update().execute.side_effect = arvados.errors.HttpError(400, "{}")
-            #self.check_exception(api_client=api_client)
-            #print dir(err_check)
+        with tutil.mock_responses('', 500, 400):
             self.check_exception()
-            #self.run_method(api_client=api_client)
-            #print err_check.failureException
-            #self.assertEqual(400, err_check.exception.request_errors())
-            #self.assertRaises(error_class, self.run_method(api_client=api_client), *args, **kwargs)
-        
 
 #    def test_retry_then_success(self):
 #        with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 500, 200):
@@ -97,10 +83,8 @@ class TaskSetOutputTestCase(ApiClientRetrytestMixin, unittest.TestCase):
     ERROR_HEADERS = {'Content-Type': mimetypes.types_map['.json']}
     DEFAULT_EXPECT = None
     DEFAULT_RETURN = True
-    DEFAULT_EXCEPTION = arvados.errors.HttpError
-    TEST_API_PATCHER = staticmethod(tutil.mock_api_responses)
+    DEFAULT_EXCEPTION = arvados.errors.ApiError
+    #TEST_API_PATCHER = staticmethod(tutil.mock_api_responses)
 
     def run_method(self, locator=ApiClientRetrytestMixin.TEST_LOCATOR, api_client=None, *args, **kwargs):
-        # Have some way to change api_client to use api_client.job_tasks().update().side_effect changes to httplib2 calls
         arvados.task_set_output({'uuid':self.TEST_UUID},s=locator,api_client=api_client)
-        # If this returns none, we are successful, if it throws an HttpError, see error check.

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list