From: Alfredo Deza Date: Wed, 2 Jan 2019 19:18:14 +0000 (-0500) Subject: ceph-volume tests.util ensure ints and strings with commas can be converted to ints X-Git-Tag: v14.1.0~501^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=91bc3a1479c550be7b48128d5755228a2007e4b0;p=ceph.git ceph-volume tests.util ensure ints and strings with commas can be converted to ints Signed-off-by: Alfredo Deza --- diff --git a/src/ceph-volume/ceph_volume/tests/util/test_util.py b/src/ceph-volume/ceph_volume/tests/util/test_util.py index edea219fdad9..2d3f904f85b3 100644 --- a/src/ceph-volume/ceph_volume/tests/util/test_util.py +++ b/src/ceph-volume/ceph_volume/tests/util/test_util.py @@ -23,12 +23,19 @@ class TestStrToInt(object): result = util.str_to_int("1,99", round_down=False) assert result == 2 - def test_passing_a_float_str(self): - result = util.str_to_int("1.99") + @pytest.mark.parametrize("value", ['2', 2]) + def test_passing_an_int(self, value): + result = util.str_to_int(value) + assert result == 2 + + @pytest.mark.parametrize("value", ['1.99', 1.99]) + def test_passing_a_float(self, value): + result = util.str_to_int(value) assert result == 1 - def test_passing_a_float_does_not_round(self): - result = util.str_to_int("1.99", round_down=False) + @pytest.mark.parametrize("value", ['1.99', 1.99]) + def test_passing_a_float_does_not_round(self, value): + result = util.str_to_int(value, round_down=False) assert result == 2 def test_text_is_not_an_integer_like(self): @@ -36,6 +43,11 @@ class TestStrToInt(object): util.str_to_int("1.4GB") assert str(error.value) == "Unable to convert to integer: '1.4GB'" + def test_input_is_not_string(self): + with pytest.raises(RuntimeError) as error: + util.str_to_int(None) + assert str(error.value) == "Unable to convert to integer: 'None'" + def true_responses(upper_casing=False): if upper_casing: