summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-05-11 20:09:23 +0000
committerGerrit Code Review <review@openstack.org>2013-05-11 20:09:23 +0000
commitc102f7421d3e23ee696698784b82146825041182 (patch)
tree0a1d6376cb1d1f51d6d6a5e9c60b0d344fb8ee26 /tests
parentbfda6841f681613c65a01736946d78f3dec540c6 (diff)
parentd9b0719f02433b243a20fe705af4799c619f4e28 (diff)
downloadoslo-c102f7421d3e23ee696698784b82146825041182.tar.gz
oslo-c102f7421d3e23ee696698784b82146825041182.tar.xz
oslo-c102f7421d3e23ee696698784b82146825041182.zip
Merge "Handle ints passed to `boolean_from_string`"
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_strutils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/unit/test_strutils.py b/tests/unit/test_strutils.py
index 1863c40..b0af958 100644
--- a/tests/unit/test_strutils.py
+++ b/tests/unit/test_strutils.py
@@ -48,6 +48,10 @@ class StrUtilsTest(utils.BaseTestCase):
self.assertFalse(strutils.bool_from_string(c(
'This should not be True')))
+ # Whitespace should be stripped
+ self.assertTrue(strutils.bool_from_string(c(' true ')))
+ self.assertFalse(strutils.bool_from_string(c(' false ')))
+
def test_bool_from_string(self):
self._test_bool_from_string(lambda s: s)
@@ -55,8 +59,16 @@ class StrUtilsTest(utils.BaseTestCase):
self._test_bool_from_string(six.text_type)
def test_other_bool_from_string(self):
+ self.assertFalse(strutils.bool_from_string(None))
self.assertFalse(strutils.bool_from_string(mock.Mock()))
+ def test_int_bool_from_string(self):
+ self.assertTrue(strutils.bool_from_string(1))
+
+ self.assertFalse(strutils.bool_from_string(-1))
+ self.assertFalse(strutils.bool_from_string(0))
+ self.assertFalse(strutils.bool_from_string(2))
+
def test_int_from_bool_as_string(self):
self.assertEqual(1, strutils.int_from_bool_as_string(True))
self.assertEqual(0, strutils.int_from_bool_as_string(False))