def test_match_device_wwn(self): # should return true if ID_WWN is given # and if it is the same in both uspecs # and if DEVTYPE is given and if DEVTYPE is disk # or if DEVTYPE is partition and MINOR is the same for both uspecs uspec1 = uspec2 = {'ID_WWN': 'fakewwn', 'DEVTYPE': 'disk'} self.assertTrue(hu.match_device(uspec1, uspec2)) uspec1 = uspec2 = {'ID_WWN': 'fakewwn', 'DEVTYPE': 'partition', 'MINOR': '1'} self.assertTrue(hu.match_device(uspec1, uspec2))
def test_match_device_wwn(self): # should return true if ID_WWN is given # and if it is the same in both uspecs # and if DEVTYPE is given and if DEVTYPE is disk # or if DEVTYPE is partition and MINOR is the same for both uspecs uspec1 = uspec2 = {'ID_WWN': 'fakewwn', 'DEVTYPE': 'disk'} self.assertTrue(hu.match_device(uspec1, uspec2)) uspec1 = uspec2 = { 'ID_WWN': 'fakewwn', 'DEVTYPE': 'partition', 'MINOR': '1' } self.assertTrue(hu.match_device(uspec1, uspec2))
def test_match_device_serial(self): # should return true if ID_SERIAL_SHORT is given # and if it is the same for both uspecs # and if DEVTYPE is given and if it is 'disk' uspec1 = uspec2 = {'ID_SERIAL_SHORT': 'fakeserial', 'DEVTYPE': 'disk'} self.assertTrue(hu.match_device(uspec1, uspec2))
def test_match_device_devlinks(self): # should return true if at least one by-id link from first uspec # matches by-id link from another uspec uspec1 = {'DEVLINKS': ['/dev/disk/by-path/fakepath', '/dev/disk/by-id/fakeid1', '/dev/disk/by-id/fakeid2']} uspec2 = {'DEVLINKS': ['/dev/disk/by-id/fakeid2', '/dev/disk/by-id/fakeid3']} self.assertTrue(hu.match_device(uspec1, uspec2))
def test_match_device_devlinks(self): # should return true if at least one by-id link from first uspec # matches by-id link from another uspec uspec1 = { 'DEVLINKS': [ '/dev/disk/by-path/fakepath', '/dev/disk/by-id/fakeid1', '/dev/disk/by-id/fakeid2' ] } uspec2 = { 'DEVLINKS': ['/dev/disk/by-id/fakeid2', '/dev/disk/by-id/fakeid3'] } self.assertTrue(hu.match_device(uspec1, uspec2))
def test_match_device_false(self): uspec1 = {'ID_WWN': 'fakewwn1', 'DEVTYPE': 'disk'} uspec2 = {'ID_WWN': 'fakewwn1', 'DEVTYPE': 'partition'} self.assertFalse(hu.match_device(uspec1, uspec2))
def test_match_device_serial_false(self): # should return false if ID_SERIAL_SHORT is given # and if it does not match each other uspec1 = {'ID_SERIAL_SHORT': 'fakeserial1'} uspec2 = {'ID_SERIAL_SHORT': 'fakeserial2'} self.assertFalse(hu.match_device(uspec1, uspec2))
def test_match_device_devpath(self): # should return true if DEVPATH is given # and if it is the same for both uspecs uspec1 = uspec2 = {'DEVPATH': '/devices/fake'} self.assertTrue(hu.match_device(uspec1, uspec2))
def test_match_device_wwn_false(self): # should return false if ID_WWN is given # and does not match each other uspec1 = {'ID_WWN': 'fakewwn1'} uspec2 = {'ID_WWN': 'fakewwn2'} self.assertFalse(hu.match_device(uspec1, uspec2))