From: Kefu Chai Date: Fri, 11 May 2018 16:42:46 +0000 (+0800) Subject: mgr/dashboard: set errno via the parent class X-Git-Tag: v14.0.0~151^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F21945%2Fhead;p=ceph.git mgr/dashboard: set errno via the parent class update the test accordingly. see also rados.Error.__str__() Signed-off-by: Ricardo Dias Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/dashboard/services/ceph_service.py b/src/pybind/mgr/dashboard/services/ceph_service.py index 7671f89cfa3e..a2e22f507bbe 100644 --- a/src/pybind/mgr/dashboard/services/ceph_service.py +++ b/src/pybind/mgr/dashboard/services/ceph_service.py @@ -24,10 +24,9 @@ from .. import logger, mgr class SendCommandError(rados.Error): def __init__(self, err, prefix, argdict, errno): - self.errno = errno self.prefix = prefix self.argdict = argdict - super(SendCommandError, self).__init__(err) + super(SendCommandError, self).__init__(err, errno) class CephService(object): diff --git a/src/pybind/mgr/dashboard/tests/test_exceptions.py b/src/pybind/mgr/dashboard/tests/test_exceptions.py index a60ceaa7f09f..5443cbfb2433 100644 --- a/src/pybind/mgr/dashboard/tests/test_exceptions.py +++ b/src/pybind/mgr/dashboard/tests/test_exceptions.py @@ -116,19 +116,19 @@ class RESTControllerTest(ControllerTestCase): self._get('/foo/error_send_command') self.assertStatus(400) self.assertJsonBody( - {'detail': 'hi', 'code': "42", 'component': 'foo'} + {'detail': '[errno -42] hi', 'code': "42", 'component': 'foo'} ) def test_error_send_command_list(self): self._get('/foo/') self.assertStatus(400) self.assertJsonBody( - {'detail': 'list', 'code': "42", 'component': 'foo'} + {'detail': '[errno -42] list', 'code': "42", 'component': 'foo'} ) def test_error_send_command_bowsable_api(self): self.getPage('/foo/error_send_command', headers=[('Accept', 'text/html')]) - for err in ["'detail': 'hi'", "'component': 'foo'"]: + for err in ["'detail': '[errno -42] hi'", "'component': 'foo'"]: self.assertIn(err.replace("'", "\'").encode('utf-8'), self.body) def test_error_foo_generic(self):