FreedomBox/freedombox/tests/test_context_processors.py
Sunil Mohan Adapa c700e0866e
*: Additional import path related changes
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2026-08-28 07:35:37 -04:00

32 lines
986 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 freedombox import context_processors as cp
@patch('freedombox.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']