mirror of
https://github.com/evennia/evennia.git
synced 2026-03-21 23:36:30 +01:00
Move some mocks to avoid global changes, as per #1779
This commit is contained in:
parent
70faa3fc98
commit
2c3ea3feb1
2 changed files with 12 additions and 7 deletions
|
|
@ -2,6 +2,7 @@
|
|||
Module containing the test cases for the Audit system.
|
||||
"""
|
||||
|
||||
from django.test import override_settings
|
||||
from django.conf import settings
|
||||
from evennia.utils.test_resources import EvenniaTest
|
||||
import re
|
||||
|
|
@ -12,10 +13,8 @@ settings.AUDIT_IN = True
|
|||
settings.AUDIT_OUT = True
|
||||
settings.AUDIT_ALLOW_SPARSE = True
|
||||
|
||||
# Configure settings to use custom session
|
||||
settings.SERVER_SESSION_CLASS = "evennia.contrib.security.auditing.server.AuditedServerSession"
|
||||
|
||||
|
||||
@override_settings(SERVER_SESSION_CLASS="evennia.contrib.security.auditing.server.AuditedServerSession")
|
||||
class AuditingTest(EvenniaTest):
|
||||
|
||||
def test_mask(self):
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ from evennia.utils import create
|
|||
from evennia.utils.idmapper.models import flush_cache
|
||||
|
||||
|
||||
SESSIONS.data_out = Mock()
|
||||
SESSIONS.disconnect = Mock()
|
||||
|
||||
|
||||
def unload_module(module):
|
||||
"""
|
||||
Reset import so one can mock global constants.
|
||||
|
|
@ -68,6 +64,11 @@ class EvenniaTest(TestCase):
|
|||
"""
|
||||
Sets up testing environment
|
||||
"""
|
||||
self.backups = (SESSIONS.data_out, SESSIONS.disconnect,
|
||||
settings.DEFAULT_HOME, settings.PROTOTYPE_MODULES)
|
||||
SESSIONS.data_out = Mock()
|
||||
SESSIONS.disconnect = Mock()
|
||||
|
||||
self.account = create.create_account("TestAccount", email="test@test.com", password="testpassword", typeclass=self.account_typeclass)
|
||||
self.account2 = create.create_account("TestAccount2", email="test@test.com", password="testpassword", typeclass=self.account_typeclass)
|
||||
self.room1 = create.create_object(self.room_typeclass, key="Room", nohome=True)
|
||||
|
|
@ -101,6 +102,11 @@ class EvenniaTest(TestCase):
|
|||
|
||||
def tearDown(self):
|
||||
flush_cache()
|
||||
SESSIONS.data_out = self.backups[0]
|
||||
SESSIONS.disconnect = self.backups[1]
|
||||
settings.DEFAULT_HOME = self.backups[2]
|
||||
settings.PROTOTYPE_MODULES = self.backups[3]
|
||||
|
||||
del SESSIONS[self.session.sessid]
|
||||
self.account.delete()
|
||||
self.account2.delete()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue