From 65925511bc0ccc17d3983f54a0b1052f169749eb Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 12 May 2018 00:42:46 +0800 Subject: [PATCH] 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 --- src/pybind/mgr/dashboard/services/ceph_service.py | 3 +-- src/pybind/mgr/dashboard/tests/test_exceptions.py | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/dashboard/services/ceph_service.py b/src/pybind/mgr/dashboard/services/ceph_service.py index 7671f89cfa3..a2e22f507bb 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 a60ceaa7f09..5443cbfb243 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): -- 2.39.5