Esempio n. 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'
Esempio n. 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")
Esempio n. 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'
Esempio n. 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'
Esempio n. 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")
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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'
Esempio n. 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