[ARVADOS] updated: dbd30cba1ac27fa5a19096b1572860c8cc2fd867
git at public.curoverse.com
git at public.curoverse.com
Thu Oct 8 16:43:52 EDT 2015
Summary of changes:
sdk/python/tests/test_init.py | 83 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
create mode 100644 sdk/python/tests/test_init.py
via dbd30cba1ac27fa5a19096b1572860c8cc2fd867 (commit)
from 6fb3726cbd0ee75d85249eca568e75159fff66e5 (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 dbd30cba1ac27fa5a19096b1572860c8cc2fd867
Author: Bryan Cosca <bcosc at curoverse.com>
Date: Thu Oct 8 16:43:44 2015 -0400
6600: Added test_init.py
diff --git a/sdk/python/tests/test_init.py b/sdk/python/tests/test_init.py
new file mode 100644
index 0000000..355a21c
--- /dev/null
+++ b/sdk/python/tests/test_init.py
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+
+import mock
+import os
+import unittest
+import hashlib
+import run_test_server
+import json
+import arvados
+import arvados_testutil as tutil
+from apiclient import http as apiclient_http
+
+ at tutil.skip_sleep
+class ApiClientRetryTestMixin(object):
+
+ TEST_UUID = 'zzzzz-zzzzz-zzzzzzzzzzzzzzz'
+ TEST_LOCATOR = 'd41d8cd98f00b204e9800998ecf8427e+0'
+
+ @classmethod
+ def setUpClass(cls):
+ run_test_server.run()
+ cls.api = arvados.api('v1')
+
+ def tearDown(cls):
+ run_test_server.reset()
+
+ def run_method(self, *args, **kwargs):
+ raise NotImplementedError("test subclasses must define run_method")
+
+ def check_success(self, expected=None, *args, **kwargs):
+ try:
+ self.run_method
+ except: # This seems really iffy, because random exceptions can occur.
+ self.assertTrue(False)
+
+ def check_exception(self, error_class=None, *args, **kwargs):
+ if error_class is None:
+ error_class = self.DEFAULT_EXCEPTION
+ self.assertRaises(error_class, self.run_method)
+
+ def test_immediate_success(self):
+ with tutil.mock_responses('', 200):
+ self.check_success()
+
+ def test_immediate_failure(self):
+ with tutil.mock_responses('', 400):
+ self.check_exception()
+
+ def test_retry_then_success(self):
+ with tutil.mock_responses('', 500, 200):
+ self.check_success()
+
+ def test_error_after_default_retries_exhausted(self):
+ with tutil.mock_responses('', 500, 500, 500, 500, 500, 500):
+ self.check_exception()
+
+ def test_no_retry_after_immediate_success(self):
+ with tutil.mock_responses('', 200, 400):
+ self.check_success()
+
+class TaskSetOutputTestCase(ApiClientRetryTestMixin, unittest.TestCase):
+ DEFAULT_EXCEPTION = arvados.errors.ApiError
+
+ def run_method(self, locator=ApiClientRetryTestMixin.TEST_LOCATOR, *args, **kwargs):
+ arvados.task_set_output({'uuid':self.TEST_UUID},s=locator)
+
+class CurrentJobTestCase(ApiClientRetryTestMixin, unittest.TestCase):
+ DEFAULT_EXCEPTION = arvados.errors.ApiError
+
+ os.environ['JOB_UUID'] = 'zzzzz-zzzzz-zzzzzzzzzzzzzzz'
+ os.environ['JOB_WORK'] = '.'
+
+ def run_method(self, *args, **kwargs):
+ arvados.current_job()
+
+class CurrentTaskTestCase(ApiClientRetryTestMixin, unittest.TestCase):
+ DEFAULT_EXCEPTION = arvados.errors.ApiError
+
+ os.environ['TASK_UUID'] = 'zzzzz-zzzzz-zzzzzzzzzzzzzzz'
+ os.environ['TASK_WORK'] = '.'
+
+ def run_method(self, *args, **kwargs):
+ arvados.current_task()
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list