]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: set errno via the parent class
authorKefu Chai <kchai@redhat.com>
Fri, 11 May 2018 16:42:46 +0000 (00:42 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 11 May 2018 16:55:11 +0000 (00:55 +0800)
update the test accordingly. see also rados.Error.__str__()

Signed-off-by: Ricardo Dias <rdias@suse.com>
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/dashboard/services/ceph_service.py
src/pybind/mgr/dashboard/tests/test_exceptions.py

index 7671f89cfa3e36ccba3204b6c9e318fac3f81797..a2e22f507bbe3dbef0cf02a14da44bbcf0cdd561 100644 (file)
@@ -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):
index a60ceaa7f09fb856dc6a5874d06f06f3c78a7e57..5443cbfb2433ade3f120316065284fbb994b5f7c 100644 (file)
@@ -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):