[ARVADOS] updated: 629ea34aca61475f3d551644127028769fc0928c
git at public.curoverse.com
git at public.curoverse.com
Mon Sep 21 00:02:12 EDT 2015
Summary of changes:
sdk/python/arvados/__init__.py | 1 +
sdk/python/tests/test_task_output_retry.py | 28 ++++++++++++++++------------
2 files changed, 17 insertions(+), 12 deletions(-)
via 629ea34aca61475f3d551644127028769fc0928c (commit)
from 111db6f3f99d7209c850d623139142529dc90c9f (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 629ea34aca61475f3d551644127028769fc0928c
Author: Bryan Cosca <bcosc at curoverse.com>
Date: Mon Sep 21 00:02:07 2015 -0400
6600: flailing, trying to figure out how to queue up responses to the mock api_client
diff --git a/sdk/python/arvados/__init__.py b/sdk/python/arvados/__init__.py
index 77e4138..736f41f 100644
--- a/sdk/python/arvados/__init__.py
+++ b/sdk/python/arvados/__init__.py
@@ -44,6 +44,7 @@ def task_set_output(self,s,api_client=None,num_retries=5):
api_client = api('v1')
for tries_left in RetryLoop(num_retries=num_retries, backoff_start=0): # change this to 2 after tests are finished
+ print tries_left
try:
return api_client.job_tasks().update(uuid=self['uuid'],
body={
diff --git a/sdk/python/tests/test_task_output_retry.py b/sdk/python/tests/test_task_output_retry.py
index 50001aa..64fd9d5 100644
--- a/sdk/python/tests/test_task_output_retry.py
+++ b/sdk/python/tests/test_task_output_retry.py
@@ -14,24 +14,27 @@ class ApiClientRetrytestMixin(object):
TEST_LOCATOR = 'd41d8cd98f00b204e9800998ecf8427e+0'
def setUp(self):
- api_client = mock.MagicMock()
+ self.api_client = mock.MagicMock()
+
+ def new_client(self, **kwargs):
+ return self.api_client(**kwargs)
def run_method(self, *args, **kwargs):
raise NotImplementedError("test subclasses must define run_method")
- def check_success(self, expected=None, *args, **kwargs):
+ def check_success(self, expected=None, api_client=None, *args, **kwargs):
if expected is None:
expected = self.DEFAULT_EXPECT
- self.assertEqual(expected, self.run_method(*args, **kwargs))
+ self.assertEqual(expected, self.run_method(api_client, *args, **kwargs))
- def check_exception(self, error_class=None, *args, **kwargs):
+ def check_exception(self, error_class=None, api_client=None, *args, **kwargs):
if error_class is None:
error_class = self.DEFAULT_EXCEPTION
- self.assertRaises(error_class, self.run_method, *args, **kwargs)
+ self.assertRaises(error_class, self.run_method(api_client), *args, **kwargs)
def test_immediate_success(self):
- with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 200):
- self.check_success()
+ with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 200) as api_client:
+ self.check_success(api_client)
def test_retry_then_success(self):
with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 500, 200):
@@ -42,8 +45,8 @@ class ApiClientRetrytestMixin(object):
self.check_success(num_retries=5)
def test_error_after_default_retries_exhausted(self):
- with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 500, 500, 500, 500, 500, 200):
- self.check_exception()
+ with self.TEST_API_PATCHER(self.DEFAULT_EXCEPTION, 500, 500, 500, 500, 500, 200) as api_client:
+ self.check_exception(api_client)
def test_no_retry_after_immediate_success(self):
with self.TEST_API_PATCHER(self.DEFAULT_EXPECT, 200, 400):
@@ -51,10 +54,11 @@ class ApiClientRetrytestMixin(object):
class TaskSetOutputTestCase(ApiClientRetrytestMixin, unittest.TestCase):
- DEFAULT_EXCEPT = ApiClientRetrytestMixin.TEST_UUID
+ DEFAULT_EXPECT = None
DEFAULT_RETURN = True
DEFAULT_EXCEPTION = arvados.errors.HttpError
TEST_API_PATCHER = staticmethod(tutil.mock_api_responses)
- def run_method(self, locator=ApiClientRetrytestMixin.TEST_LOCATOR, *args, **kwargs):
- return arvados.job_tasks().update(locator, *args, **kwargs)
+ def run_method(self, locator=ApiClientRetrytestMixin.TEST_LOCATOR, api_client=None, *args, **kwargs):
+ 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