def test_unmount_storage(self): b = BConsole() with patch.object(b, 'start_process') as mock_method: start_process = mock_method.return_value start_process.communicate.return_value = ('unmounted.', '') self.assertTrue(b.unmount_storage('File')) with patch.object(b, 'start_process') as mock_method: start_process = mock_method.return_value start_process.communicate.return_value = ('error', 'error') self.assertFalse(b.unmount_storage('File'))
def modify_storage(request): bc = BConsole() enderer='templates/storage_list.jinja2', storages = ['File',] log.debug('###################################') log.debug(request.params) log.debug('###################################') command = request.POST.get('command') if command == 'unmount': ret = {'okmsg':'Storage unmounted correctly'} for storage in storages: if not bc.unmount_storage(storage): msg = 'Error unmounting storage: %s' % storage log.info(msg) ret = {'errormsg':msg} break else: ret = {'okmsg':'Storage mounted correctly'} for storage in storages: if not bc.mount_storage(storage): msg = 'Error mounting storage: %s' % storage log.info(msg) ret = {'errormsg':msg} break redirect_url = request.route_url('storage_list', _query=ret) response = HTTPFound(location=redirect_url) return response