mirror of
https://github.com/ceph/ceph
synced 2025-01-18 17:12:29 +00:00
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>
This commit is contained in:
parent
287ab0e049
commit
adf8c17821
@ -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')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user