コード例 #1
0
 def test_multi_exception_raised_on_exceed(self):
     # limit retries so this doesn't take 40 seconds
     mock.patch.object(db_api._retry_db_errors, 'max_retries',
                       new=2).start()
     e = exceptions.MultipleExceptions([ValueError(), db_exc.DBDeadlock()])
     with testtools.ExpectedException(exceptions.MultipleExceptions):
         self._decorated_function(db_api.MAX_RETRIES + 1, e)
コード例 #2
0
ファイル: test_api.py プロジェクト: mjzhou/neutron-lib
 def test_multi_exception_raised_on_exceed(self):
     # limit retries so this doesn't take 40 seconds
     retry_fixture = fixture.DBRetryErrorsFixture(max_retries=2)
     retry_fixture.setUp()
     e = exceptions.MultipleExceptions([ValueError(), db_exc.DBDeadlock()])
     with testtools.ExpectedException(exceptions.MultipleExceptions):
         self._decorated_function(db_api.MAX_RETRIES + 1, e)
     retry_fixture.cleanUp()
コード例 #3
0
 def test_convert_exception_to_http_exc_multiple_same_codes(self):
     e = exceptions.MultipleExceptions([
         exceptions.NetworkNotFound(net_id='nid'),
         exceptions.PortNotFound(port_id='pid')
     ])
     conv = common.convert_exception_to_http_exc(e, base_v2.FAULT_MAP, None)
     self.assertIsInstance(conv, exc.HTTPNotFound)
     self.assertEqual(
         "Network nid could not be found.\nPort pid could not be found.",
         jsonutils.loads(conv.body)['NeutronError']['message'])
コード例 #4
0
 def test_convert_exception_to_http_exc_multiple_different_codes(self):
     e = exceptions.MultipleExceptions([
         exceptions.NetworkInUse(net_id='nid'),
         exceptions.PortNotFound(port_id='pid')
     ])
     conv = common.convert_exception_to_http_exc(e, base_v2.FAULT_MAP, None)
     self.assertIsInstance(conv, exc.HTTPConflict)
     self.assertEqual(
         ("HTTP 409 NetworkInUse: Unable to complete operation on network "
          "nid. There are one or more ports still in use on the network.\n"
          "HTTP 404 PortNotFound: Port pid could not be found."),
         jsonutils.loads(conv.body)['NeutronError']['message'])
コード例 #5
0
 def test_multi_nested_exception_contains_deadlock(self):
     i = exceptions.MultipleExceptions([ValueError(), db_exc.DBDeadlock()])
     e = exceptions.MultipleExceptions([ValueError(), i])
     self.assertIsNone(self._decorated_function(1, e))
コード例 #6
0
 def test_multi_exception_contains_retry(self):
     e = exceptions.MultipleExceptions(
         [ValueError(), db_exc.RetryRequest(TypeError())])
     self.assertIsNone(self._decorated_function(1, e))
コード例 #7
0
 def test_retries_on_multi_exception_containing_target(self):
     with testtools.ExpectedException(db_exc.RetryRequest):
         with db_api.exc_to_retry(ValueError):
             e = exceptions.MultipleExceptions([ValueError(), TypeError()])
             raise e
コード例 #8
0
 def test_convert_exception_to_http_exc_multiple_empty_inner(self):
     e = exceptions.MultipleExceptions([])
     conv = common.convert_exception_to_http_exc(e, base_v2.FAULT_MAP, None)
     self.assertIsInstance(conv, exc.HTTPInternalServerError)
コード例 #9
0
 def test_multi_exception_raised_on_exceed(self):
     e = exceptions.MultipleExceptions([ValueError(), db_exc.DBDeadlock()])
     with testtools.ExpectedException(exceptions.MultipleExceptions):
         self._decorated_function(db_api.MAX_RETRIES + 1, e)