mirror of
https://github.com/evennia/evennia.git
synced 2026-03-25 09:16:32 +01:00
Adds account and puppet to context processor, modifies test.
This commit is contained in:
parent
882e6130e4
commit
4f6b8f323c
2 changed files with 16 additions and 8 deletions
|
|
@ -69,7 +69,7 @@ def general_context(request):
|
|||
"""
|
||||
account = None
|
||||
if request.user.is_authenticated(): account = request.user
|
||||
|
||||
|
||||
puppet = None
|
||||
if request.session.get('puppet'): puppet = request.session['puppet']
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
from mock import Mock, patch
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.test import RequestFactory, TestCase
|
||||
from mock import MagicMock, patch
|
||||
from . import general_context
|
||||
|
||||
|
||||
class TestGeneralContext(TestCase):
|
||||
maxDiff = None
|
||||
|
||||
|
|
@ -15,8 +13,18 @@ class TestGeneralContext(TestCase):
|
|||
@patch('evennia.web.utils.general_context.WEBSOCKET_PORT', "websocket_client_port_testvalue")
|
||||
@patch('evennia.web.utils.general_context.WEBSOCKET_URL', "websocket_client_url_testvalue")
|
||||
def test_general_context(self):
|
||||
request = Mock()
|
||||
self.assertEqual(general_context.general_context(request), {
|
||||
request = RequestFactory().get('/')
|
||||
request.user = AnonymousUser()
|
||||
request.session = {
|
||||
'account': None,
|
||||
'puppet': None,
|
||||
}
|
||||
|
||||
response = general_context.general_context(request)
|
||||
|
||||
self.assertEqual(response, {
|
||||
'account': None,
|
||||
'puppet': None,
|
||||
'game_name': "test_name",
|
||||
'game_slogan': "test_game_slogan",
|
||||
'evennia_userapps': ['Accounts'],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue