Debian Codegraph @

django_mailman3/tests/test_context_processors.py

raw
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2016-2023 by the Free Software Foundation, Inc.
4 #
5 # This file is part of Django-Mailman.
6 #
7 # Django-Mailman is free software: you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the Free
9 # Software Foundation, either version 3 of the License, or (at your option)
10 # any later version.
11 #
12 # Django-Mailman is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 # more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # Django-Mailman. If not, see <http://www.gnu.org/licenses/>.
19
20
21 from django.test import RequestFactory, TestCase, override_settings
22
23 from django_mailman3.context_processors import common
24
25
26 class TestContextProcessors(TestCase):
27
28 def setUp(self):
29 self.factory = RequestFactory()
30
31 @override_settings(LOGIN_URL='/login', LOGOUT_URL='/logout',
32 ALLOWED_HOSTS=['example.com'])
33 def test_common_with_all_vars(self, *args, **kwargs):
34 request = self.factory.get('/', HTTP_HOST='example.com')
35 context = common(request)
36 self.assertEqual(context['site_name'], 'example.com')
37 self.assertEqual(context['LOGIN_URL'], '/login')
38 self.assertEqual(context['LOGOUT_URL'], '/logout')