示例#1
0
 def test_parse_filter_min_low(self, virtual_mock):
     """ Testing low notation with 20G: """
     virtual_mock.return_value = False
     matcher = dg.SizeMatcher('size', '50G:')
     assert isinstance(matcher.exact, tuple)
     assert matcher.low[0] == '50'
     assert matcher.low[1] == 'GB'
示例#2
0
 def test_compare_raise(self, virtual_mock):
     virtual_mock.return_value = False
     matcher = dg.SizeMatcher('size', 'None')
     disk_dict = dict(path='/dev/vdb', size='20.00 GB')
     with pytest.raises(Exception):
         matcher.compare(disk_dict)
         pytest.fail("Couldn't parse size")
示例#3
0
 def test_parse_filter_max_high(self, virtual_mock):
     """ Testing high notation with :50G """
     virtual_mock.return_value = False
     matcher = dg.SizeMatcher('size', ':50G')
     assert isinstance(matcher.exact, tuple)
     assert matcher.high[0] == '50'
     assert matcher.high[1] == 'GB'
示例#4
0
 def test_parse_filter_exact_GB_G(self, virtual_mock):
     """ Testing exact notation with 20G """
     virtual_mock.return_value = False
     matcher = dg.SizeMatcher('size', '20GB')
     assert isinstance(matcher.exact, tuple)
     assert matcher.exact[0] == '20'
     assert matcher.exact[1] == 'GB'
示例#5
0
 def test_normalize_suffix_raises(self, virtual_mock):
     virtual_mock.return_value = False
     with pytest.raises(dg.UnitNotSupported):
         dg.SizeMatcher('10P', 'size')._normalize_suffix("P")
         pytest.fail("Unit 'P' not supported")
示例#6
0
 def test_normalize_suffix(self, virtual_mock, test_input, expected):
     virtual_mock.return_value = False
     assert dg.SizeMatcher('10G',
                           'size')._normalize_suffix(test_input) == expected
示例#7
0
 def test_parse_suffix(self, virtual_mock, test_input, expected):
     virtual_mock.return_value = False
     assert dg.SizeMatcher('size',
                           '10G').parse_suffix(test_input) == expected
示例#8
0
 def test_get_k_v(self, virtual_mock, test_input, expected):
     virtual_mock.return_value = False
     assert dg.SizeMatcher('size', '10G')._get_k_v(test_input) == expected
示例#9
0
 def test_compare_at_least_1TB(self, virtual_mock, test_input, expected):
     virtual_mock.return_value = False
     matcher = dg.SizeMatcher('size', '1TB:')
     disk_dict = dict(path='/dev/sdz', size=test_input)
     ret = matcher.compare(disk_dict)
     assert ret is expected
示例#10
0
 def test_compare_high(self, virtual_mock, test_input, expected):
     virtual_mock.return_value = False
     matcher = dg.SizeMatcher('size', ':50GB')
     disk_dict = dict(path='/dev/vdb', size=test_input)
     ret = matcher.compare(disk_dict)
     assert ret is expected
示例#11
0
 def test_compare_exact(self, virtual_mock):
     virtual_mock.return_value = False
     matcher = dg.SizeMatcher('size', '20GB')
     disk_dict = dict(path='/dev/vdb', size='20.00 GB')
     ret = matcher.compare(disk_dict)
     assert ret is True
示例#12
0
 def test_to_byte_PB(self, virtual_mock):
     """ Expect to raise """
     virtual_mock.return_value = False
     with pytest.raises(dg.UnitNotSupported):
         dg.SizeMatcher('size', '10P').to_byte(('10', 'PB'))
     assert 'Unit \'P\' is not supported'
示例#13
0
 def test_to_byte_TB(self, virtual_mock):
     """ Pretty nonesense test.."""
     virtual_mock.return_value = False
     ret = dg.SizeMatcher('size', '10T').to_byte(('10', 'TB'))
     assert ret == 10 * 1e+12