]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rados.py: fix Rados() unicode checking
authorJosh Durgin <josh.durgin@inktank.com>
Wed, 14 Aug 2013 22:50:59 +0000 (15:50 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Wed, 14 Aug 2013 23:07:52 +0000 (16:07 -0700)
Check new parameters and check that rados_id is not None again to
catch the empty string.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Reviewed-by: Sage Weil <sage.weil@inktank.com>
src/pybind/rados.py
src/test/pybind/test_rados.py

index 34d83c7b3536a088f3ffb355b3d377b817df7918..7768f8c39d3fb8778176c27898d12197de60dc3a 100644 (file)
@@ -187,10 +187,14 @@ Rados object in state %s." % (self.state))
         self.librados = CDLL('librados.so.2')
         self.cluster = c_void_p()
         self.rados_id = rados_id
-        if rados_id and not isinstance(rados_id, str):
+        if rados_id is not None and not isinstance(rados_id, str):
             raise TypeError('rados_id must be a string or None')
         if conffile is not None and not isinstance(conffile, str):
             raise TypeError('conffile must be a string or None')
+        if name is not None and not isinstance(name, str):
+            raise TypeError('name must be a string or None')
+        if clustername is not None and not isinstance(clustername, str):
+            raise TypeError('clustername must be a string or None')
         if rados_id and name:
             raise Error("Rados(): can't supply both rados_id and name")
         if rados_id:
index 019a86c2763ada4c81c93565a2849ed0e99c7154..4628a44a652ce4ca2d3c4ec6b60bad5052419d8a 100644 (file)
@@ -11,6 +11,16 @@ def test_rados_init_error():
     assert_raises(Error, Rados, conffile='', name='invalid')
     assert_raises(Error, Rados, conffile='', name='bad.invalid')
 
+def test_rados_init_type_error():
+    assert_raises(TypeError, Rados, rados_id=u'admin')
+    assert_raises(TypeError, Rados, rados_id=u'')
+    assert_raises(TypeError, Rados, name=u'client.admin')
+    assert_raises(TypeError, Rados, name=u'')
+    assert_raises(TypeError, Rados, conffile=u'blah')
+    assert_raises(TypeError, Rados, conffile=u'')
+    assert_raises(TypeError, Rados, clusternaem=u'blah')
+    assert_raises(TypeError, Rados, clustername=u'')
+
 def test_rados_init():
     with Rados(conffile='', rados_id='admin'):
         pass