Nir Soffer has uploaded a new change for review.

Change subject: storageServer: Fix Mismatch initialization
......................................................................

storageServer: Fix Mismatch initialization

Commit e57e0bdb3e was verified only with the positive flows, since it is
hard to simulate connection mismatch. In case of a real mismatch,
attmpting to log the mismatches would raise "TypeError: not enough
arguments for format string" hiding the real error.

This patch adds some trivial tests and initialize the "args" instance
variable.

Change-Id: Ic9593091c2da6c692f7fcbdd176835a1f2438417
Signed-off-by: Nir Soffer <[email protected]>
---
M tests/Makefile.am
A tests/storageServerTests.py
M vdsm/storage/storageServer.py
3 files changed, 35 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/04/36604/1

diff --git a/tests/Makefile.am b/tests/Makefile.am
index f644799..564223b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -76,6 +76,7 @@
        sslhelper.py \
        sslTests.py \
        storageMailboxTests.py \
+       storageServerTests.py \
        tcTests.py \
        testlibTests.py \
        toolTests.py \
diff --git a/tests/storageServerTests.py b/tests/storageServerTests.py
new file mode 100644
index 0000000..83099f5
--- /dev/null
+++ b/tests/storageServerTests.py
@@ -0,0 +1,33 @@
+#
+# Copyright 2014 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 storage.storageServer import IscsiConnection
+
+
+class IscsiConnectionMismatchTests(VdsmTestCase):
+
+    def test_no_args(self):
+        s = str(IscsiConnection.Mismatch("error 1"))
+        self.assertEqual(s, "error 1")
+
+    def test_format(self):
+        s = str(IscsiConnection.Mismatch("error %d with %r", 1, "text"))
+        self.assertEqual(s, "error 1 with 'text'")
diff --git a/vdsm/storage/storageServer.py b/vdsm/storage/storageServer.py
index 1ca4b8f..eb38fb3 100644
--- a/vdsm/storage/storageServer.py
+++ b/vdsm/storage/storageServer.py
@@ -349,7 +349,7 @@
 
         def __init__(self, fmt, *args):
             self.fmt = fmt
-            self.args
+            self.args = args
 
         def __str__(self):
             return self.fmt % self.args


-- 
To view, visit http://gerrit.ovirt.org/36604
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic9593091c2da6c692f7fcbdd176835a1f2438417
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to