mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
- In addition to the OperationalError, also handle all generic exceptions during page submit and page load. Redirect to the same page or parent using breadcrumbs. - Log exceptions handled by common error middleware so that they are also part of the system logs. - Update kiwix test as needed. - Refactor some test code that is setting up the menu items. Tests: - When an error occurs during form POST, the same page is show but with an error message. - When an error occurs in an app page during GET, the browser is redirected to the parent section. - When an error occurs in apps page during GET, the browser is redirected to the home page. - When an error occurs in home page during GET, the error is not handled and default 500 handle is triggered. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
32 lines
978 B
Python
32 lines
978 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Test module for custom context processors.
|
|
"""
|
|
|
|
from unittest.mock import MagicMock, Mock, patch
|
|
|
|
from django.urls import resolve
|
|
|
|
from plinth import context_processors as cp
|
|
|
|
|
|
@patch('plinth.notification.Notification')
|
|
def test_common(Notification, load_cfg, rf, test_menu):
|
|
"""Verify that the common() function returns the correct values."""
|
|
url = '/apps/testapp/create/'
|
|
request = rf.get(url)
|
|
request.resolver_match = resolve(url)
|
|
request.user = Mock()
|
|
request.user.groups.filter().exists = Mock(return_value=True)
|
|
request.session = MagicMock()
|
|
response = cp.common(request)
|
|
assert response is not None
|
|
|
|
config = response['cfg']
|
|
assert config is not None
|
|
assert config.box_name == 'FreedomBox'
|
|
assert response['box_name'] == 'FreedomBox'
|
|
assert len(response['breadcrumbs']) == 4
|
|
assert response['active_section_url'] == '/apps/'
|
|
assert response['user_is_admin']
|