def test_find_block_devices(self): self.is_block_device.return_value = True self.is_device_mounted.side_effect = self._fake_is_device_mounted with patch_open() as (_open, _file): _file.read.return_value = PROC_PARTITIONS _file.readlines = MagicMock() _file.readlines.return_value = PROC_PARTITIONS.split('\n') result = swift_utils.find_block_devices() ex = ['/dev/sdb', '/dev/vdb', '/dev/cciss/c1d0'] self.assertEqual(ex, result)
def test_find_block_devices(self): self.is_block_device.return_value = True self.is_device_mounted.side_effect = self._fake_is_device_mounted with patch_open() as (_open, _file): _file.read.return_value = PROC_PARTITIONS _file.readlines = MagicMock() _file.readlines.return_value = PROC_PARTITIONS.split('\n') result = swift_utils.find_block_devices() ex = ['/dev/sdb', '/dev/vdb', '/dev/cciss/c1d0'] self.assertEqual(ex, result)
def test_find_block_devices_real_world(self): self.is_block_device.return_value = True side_effect = lambda x: x in ["/dev/sdb", "/dev/sdb1"] # flake8: noqa self.is_device_mounted.side_effect = side_effect with patch_open() as (_open, _file): _file.read.return_value = REAL_WORLD_PARTITIONS _file.readlines = MagicMock() _file.readlines.return_value = REAL_WORLD_PARTITIONS.split('\n') result = swift_utils.find_block_devices() expected = ["/dev/sda"] self.assertEqual(expected, result)
def test_find_block_devices_real_world(self): self.is_block_device.return_value = True side_effect = lambda x: x in ["/dev/sdb", "/dev/sdb1"] # flake8: noqa self.is_device_mounted.side_effect = side_effect with patch_open() as (_open, _file): _file.read.return_value = REAL_WORLD_PARTITIONS _file.readlines = MagicMock() _file.readlines.return_value = REAL_WORLD_PARTITIONS.split('\n') result = swift_utils.find_block_devices() expected = ["/dev/sda"] self.assertEqual(expected, result)