diff options
author | Jonas Pfefferle <pepperjo@japf.ch> | 2021-06-03 10:32:55 +0200 |
---|---|---|
committer | Jonas Pfefferle <pepperjo@japf.ch> | 2021-06-03 10:32:55 +0200 |
commit | adf8c178214e79dcc18b5d222b9db276b0d2f032 (patch) | |
tree | 4bd5f21e879fed47090427de89f4e1f8a4cc0511 /src/ceph-volume/ceph_volume/tests/util | |
parent | ceph-volume: data_allocate_fraction: new validation class (diff) | |
download | ceph-adf8c178214e79dcc18b5d222b9db276b0d2f032.tar.xz ceph-adf8c178214e79dcc18b5d222b9db276b0d2f032.zip |
ceph-volume: data_allocate_fraction: arg_validators tests
Add tests for argument validator. Check for Nan, <=0.0 and > 1.0
Signed-off-by: Jonas Pfefferle <pepperjo@japf.ch>
Diffstat (limited to 'src/ceph-volume/ceph_volume/tests/util')
-rw-r--r-- | src/ceph-volume/ceph_volume/tests/util/test_arg_validators.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ceph-volume/ceph_volume/tests/util/test_arg_validators.py b/src/ceph-volume/ceph_volume/tests/util/test_arg_validators.py index d4565ef4dcb..6666f318b4f 100644 --- a/src/ceph-volume/ceph_volume/tests/util/test_arg_validators.py +++ b/src/ceph-volume/ceph_volume/tests/util/test_arg_validators.py @@ -87,3 +87,30 @@ class TestValidDevice(object): def test_path_is_invalid(self, fake_call): with pytest.raises(argparse.ArgumentError): self.validator('/device/does/not/exist') + + +class TestValidFraction(object): + + def setup(self): + self.validator = arg_validators.ValidFraction() + + def test_fraction_is_valid(self, fake_call): + result = self.validator('0.8') + assert result == 0.8 + + def test_fraction_is_nan(self, fake_call): + with pytest.raises(argparse.ArgumentError): + self.validator('NaN') + + def test_fraction_is_negative(self, fake_call): + with pytest.raises(argparse.ArgumentError): + self.validator('-1.0') + + def test_fraction_is_zero(self, fake_call): + with pytest.raises(argparse.ArgumentError): + self.validator('0.0') + + def test_fraction_is_greater_one(self, fake_call): + with pytest.raises(argparse.ArgumentError): + self.validator('1.1') + |