def test_is_disk_readonly(self, mock_ureport):
     # should return False if device is read only
     mock_ureport.return_value = {}
     bspec = {
         'ro': '1'
     }
     self.assertFalse(hu.is_disk('/dev/fake', bspec=bspec))
 def test_is_disk_partition(self, mock_breport):
     # should return False if udev DEVTYPE is partition
     mock_breport.return_value = {}
     uspec = {
         'DEVTYPE': 'partition'
     }
     self.assertFalse(hu.is_disk('/dev/fake', uspec=uspec))
Beispiel #3
0
 def test_is_disk_readonly(self, mock_ureport):
     # should return False if device is read only
     mock_ureport.return_value = {}
     bspec = {
         'ro': '1'
     }
     self.assertFalse(hu.is_disk('/dev/fake', bspec=bspec))
 def test_is_disk_cdrom(self, mock_breport):
     # should return False if udev ID_CDROM is set to 1
     mock_breport.return_value = {}
     uspec = {
         'ID_CDROM': '1'
     }
     self.assertFalse(hu.is_disk('/dev/fake', uspec=uspec))
Beispiel #5
0
 def test_is_disk_partition(self, mock_breport):
     # should return False if udev DEVTYPE is partition
     mock_breport.return_value = {}
     uspec = {
         'DEVTYPE': 'partition'
     }
     self.assertFalse(hu.is_disk('/dev/fake', uspec=uspec))
Beispiel #6
0
 def test_is_disk_cdrom(self, mock_breport):
     # should return False if udev ID_CDROM is set to 1
     mock_breport.return_value = {}
     uspec = {
         'ID_CDROM': '1'
     }
     self.assertFalse(hu.is_disk('/dev/fake', uspec=uspec))
 def test_is_disk_uspec_bspec_none(self, mock_ureport, mock_breport):
     # should call udevreport if uspec is None
     # should call blockdevreport if bspec is None
     # should return True if uspec and bspec are empty
     mock_ureport.return_value = {}
     mock_breport.return_value = {}
     self.assertTrue(hu.is_disk('/dev/fake'))
     mock_ureport.assert_called_once_with('/dev/fake')
     mock_breport.assert_called_once_with('/dev/fake')
Beispiel #8
0
 def test_is_disk_uspec_bspec_none(self, mock_ureport, mock_breport):
     # should call udevreport if uspec is None
     # should call blockdevreport if bspec is None
     # should return True if uspec and bspec are empty
     mock_ureport.return_value = {}
     mock_breport.return_value = {}
     self.assertTrue(hu.is_disk('/dev/fake'))
     mock_ureport.assert_called_once_with('/dev/fake')
     mock_breport.assert_called_once_with('/dev/fake')
 def test_is_disk_major(self, mock_breport):
     # should return False if udev MAJOR is not in a list of
     # major numbers which are used for disks
     # look at kernel/Documentation/devices.txt
     mock_breport.return_value = {}
     valid_majors = [3, 8, 65, 66, 67, 68, 69, 70, 71, 104, 105,
                     106, 107, 108, 109, 110, 111, 202, 252, 253]
     for major in (set(range(1, 261)) - set(valid_majors)):
         uspec = {
             'MAJOR': str(major)
         }
         self.assertFalse(hu.is_disk('/dev/fake', uspec=uspec))
Beispiel #10
0
 def test_is_disk_major(self, mock_breport):
     # should return False if udev MAJOR is not in a list of
     # major numbers which are used for disks
     # look at kernel/Documentation/devices.txt
     mock_breport.return_value = {}
     valid_majors = [3, 8, 65, 66, 67, 68, 69, 70, 71, 104, 105,
                     106, 107, 108, 109, 110, 111, 202, 252, 253, 259]
     for major in (set(range(1, 261)) - set(valid_majors)):
         uspec = {
             'MAJOR': str(major)
         }
         self.assertFalse(hu.is_disk('/dev/fake', uspec=uspec))
 def test_is_disk_bspec_none(self, mock_breport):
     # should call blockdevreport if bspec is None but uspec is not None
     uspec = {'key': 'value'}
     mock_breport.return_value = {}
     hu.is_disk('/dev/fake', uspec=uspec)
     mock_breport.assert_called_once_with('/dev/fake')
Beispiel #12
0
 def test_is_disk_bspec_none(self, mock_breport):
     # should call blockdevreport if bspec is None but uspec is not None
     uspec = {'key': 'value'}
     mock_breport.return_value = {}
     hu.is_disk('/dev/fake', uspec=uspec)
     mock_breport.assert_called_once_with('/dev/fake')