def test_lsblk_returns_404_when_device_not_found(self, mock_run_command): mock_run_command.return_value = ["", "not a block device", 32] fake_dev = "/not/a/true/block/dev" keys = ["MOUNTPOINT"] with self.assertRaises(NotFoundError): _get_lsblk_devs(keys, [fake_dev]) cmd = ['lsblk', '-Pbo', 'MOUNTPOINT', fake_dev] mock_run_command.assert_called_once_with(cmd)
def test_lsblk_returns_500_when_unknown_error_occurs( self, mock_run_command): mock_run_command.return_value = ["", "", 1] valid_dev = "/valid/block/dev" keys = ["MOUNTPOINT"] with self.assertRaises(OperationFailed): _get_lsblk_devs(keys, [valid_dev]) cmd = ['lsblk', '-Pbo', 'MOUNTPOINT', valid_dev] mock_run_command.assert_called_once_with(cmd)