X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5e991889ca6c18cdd901b98b5083c4cee7d260c9..353bc51027bdf085c8b638cbde9dbb38e1fd0262:/sdk/python/tests/test_arv_put.py diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py index f1ed35a94a..e64d914741 100644 --- a/sdk/python/tests/test_arv_put.py +++ b/sdk/python/tests/test_arv_put.py @@ -19,7 +19,7 @@ from cStringIO import StringIO import arvados import arvados.commands.put as arv_put -from arvados_testutil import ArvadosBaseTestCase +from arvados_testutil import ArvadosBaseTestCase, fake_httplib2_response import run_test_server class ArvadosPutResumeCacheTest(ArvadosBaseTestCase): @@ -160,8 +160,9 @@ class ArvadosPutResumeCacheTest(ArvadosBaseTestCase): self.last_cache = arv_put.ResumeCache(cachefile.name) self.last_cache.save(thing) self.last_cache.close() - with self.assertRaises(arvados.errors.KeepRequestError): - arv_put.ResumeCache(self.last_cache.filename) + resume_cache = arv_put.ResumeCache(self.last_cache.filename) + self.assertNotEqual(None, resume_cache) + self.assertRaises(None, resume_cache.check_cache()) def test_basic_cache_storage(self): thing = ['test', 'list'] @@ -459,6 +460,20 @@ class ArvadosPutTest(run_test_server.TestCaseWithServers, ArvadosBaseTestCase): self.call_main_with_args, ['--project-uuid', self.Z_UUID, '--stream']) + def test_api_error_handling(self): + collections_mock = mock.Mock(name='arv.collections()') + coll_create_mock = collections_mock().create().execute + coll_create_mock.side_effect = arvados.errors.ApiError( + fake_httplib2_response(403), '{}') + arv_put.api_client = arvados.api('v1') + arv_put.api_client.collections = collections_mock + with self.assertRaises(SystemExit) as exc_test: + self.call_main_with_args(['/dev/null']) + self.assertLess(0, exc_test.exception.args[0]) + self.assertLess(0, coll_create_mock.call_count) + self.assertEqual("", self.main_stdout.getvalue()) + + class ArvPutIntegrationTest(run_test_server.TestCaseWithServers, ArvadosBaseTestCase): def _getKeepServerConfig():