Allow guests for multisession_mode>1. Resolves #2098. Fix unit tests

This commit is contained in:
Griatch 2020-06-26 16:34:35 +02:00
parent 9d7461e21e
commit a721760da6
5 changed files with 81 additions and 36 deletions

View file

@ -6,7 +6,7 @@ Test AMP client
import pickle
from model_mommy import mommy
from unittest import TestCase
from mock import MagicMock, patch
from unittest.mock import MagicMock, patch
from twisted.trial.unittest import TestCase as TwistedTestCase
from evennia.server import amp_client
from evennia.server.portal import amp_server
@ -36,6 +36,7 @@ class _TestAMP(TwistedTestCase):
self.server.sessions[1] = self.session
self.portal = portal.Portal(MagicMock())
self.portal.maintenance_task.stop()
self.portalsession = session.Session()
self.portalsession.sessid = 1
self.portal.sessions[1] = self.portalsession

View file

@ -6,6 +6,7 @@ Runs as part of the Evennia's test suite with 'evennia test evennia"
"""
from django.test.runner import DiscoverRunner
from unittest import mock
class EvenniaTestSuiteRunner(DiscoverRunner):
@ -21,9 +22,16 @@ class EvenniaTestSuiteRunner(DiscoverRunner):
Build a test suite for Evennia. test_labels is a list of apps to test.
If not given, a subset of settings.INSTALLED_APPS will be used.
"""
# the portal looping call starts before the unit-test suite so we
# can't mock it - instead we stop it before starting the test - otherwise
# we'd get unclean reactor errors across test boundaries.
from evennia.server.portal.portal import PORTAL
PORTAL.maintenance_task.stop()
import evennia
evennia._init()
return super(EvenniaTestSuiteRunner, self).build_suite(
test_labels, extra_tests=extra_tests, **kwargs
)