Change in vdsm[ovirt-3.6.3]: exception: Make VdsmException reusable

piotr.kliczewski at gmail.com piotr.kliczewski at gmail.com
Thu Feb 18 11:06:52 UTC 2016


Hello Nir Soffer, Yaniv Bronhaim, Francesco Romani,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/53698

to review the following change.

Change subject: exception: Make VdsmException reusable
......................................................................

exception: Make VdsmException reusable

VdsmException was initializing code and message to default values if
called without arguments. This make is useless as as base class for
more specific exceptions, defining real code and message.

GlusterException, the only exception inheriting from VdsmException,
avoided this issue by overriding __init__.

Required-For: https://bugzilla.redhat.com/1295778
Change-Id: Icd6643d9670cb9b067e372bf5a1a6c57ced41954
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/48875
Reviewed-by: Francesco Romani <fromani at redhat.com>
Reviewed-by: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Continuous-Integration: Jenkins CI
Reviewed-on: https://gerrit.ovirt.org/52982
Tested-by: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Reviewed-by: Yaniv Bronhaim <ybronhei at redhat.com>
---
M lib/vdsm/exception.py
M tests/Makefile.am
A tests/exception_test.py
3 files changed, 35 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/98/53698/1

diff --git a/lib/vdsm/exception.py b/lib/vdsm/exception.py
index 35d9e92..dd3fd97 100644
--- a/lib/vdsm/exception.py
+++ b/lib/vdsm/exception.py
@@ -24,10 +24,6 @@
     code = 0
     message = "Vdsm Exception"
 
-    def __init__(self, code=0, message='Vdsm Exception'):
-        self.code = code
-        self.message = message
-
     def __str__(self):
         return self.message
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a9836a1..36967c8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -45,6 +45,7 @@
 	deviceTests.py \
 	domainDescriptorTests.py \
 	encodingTests.py \
+	exception_test.py \
 	executorTests.py \
 	fileSDTests.py \
 	fileVolumeTests.py \
diff --git a/tests/exception_test.py b/tests/exception_test.py
new file mode 100644
index 0000000..c1e354c
--- /dev/null
+++ b/tests/exception_test.py
@@ -0,0 +1,34 @@
+#
+# Copyright 2016 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+from testlib import VdsmTestCase
+from vdsm.exception import VdsmException
+
+
+class TestVdsmException(VdsmTestCase):
+
+    def test_str(self):
+        e = VdsmException()
+        self.assertEqual(str(e), e.message)
+
+    def test_response(self):
+        e = VdsmException()
+        self.assertEqual(e.response(),
+                         {"status": {"code": 0, "message": "Vdsm Exception"}})


-- 
To view, visit https://gerrit.ovirt.org/53698
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd6643d9670cb9b067e372bf5a1a6c57ced41954
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6.3
Gerrit-Owner: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>


More information about the vdsm-patches mailing list