]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests verify str_to_int utility
authorAlfredo Deza <adeza@redhat.com>
Fri, 13 Jul 2018 12:55:46 +0000 (08:55 -0400)
committerAlfredo Deza <adeza@redhat.com>
Fri, 27 Jul 2018 21:48:01 +0000 (17:48 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit 56b1bf633d3d16cf335043450df95f191e2907a4)

src/ceph-volume/ceph_volume/tests/util/test_util.py [new file with mode: 0644]

diff --git a/src/ceph-volume/ceph_volume/tests/util/test_util.py b/src/ceph-volume/ceph_volume/tests/util/test_util.py
new file mode 100644 (file)
index 0000000..c165b57
--- /dev/null
@@ -0,0 +1,18 @@
+import pytest
+from ceph_volume import util
+
+
+class TestStrToInt(object):
+
+    def test_passing_a_float_str(self):
+        result = util.str_to_int("1.99")
+        assert result == 1
+
+    def test_passing_a_float_does_not_round(self):
+        result = util.str_to_int("1.99", round_down=False)
+        assert result == 2
+
+    def test_text_is_not_an_integer_like(self):
+        with pytest.raises(RuntimeError) as error:
+            util.str_to_int("1.4GB")
+        assert str(error.value) == "Unable to convert to integer: '1.4GB'"