Break up/extend MULTISESSION_MODE into several new settings
This commit is contained in:
parent
e9cce46d66
commit
a0a0a248a0
13 changed files with 392 additions and 368 deletions
|
|
@ -12,41 +12,34 @@ main test suite started with
|
|||
|
||||
"""
|
||||
import datetime
|
||||
from unittest.mock import MagicMock, Mock, patch
|
||||
|
||||
from anything import Anything
|
||||
|
||||
from parameterized import parameterized
|
||||
from django.conf import settings
|
||||
from twisted.internet import task
|
||||
from unittest.mock import patch, Mock, MagicMock
|
||||
|
||||
from evennia import DefaultRoom, DefaultExit, ObjectDB
|
||||
from evennia.commands.default.cmdset_character import CharacterCmdSet
|
||||
from evennia.utils.test_resources import (
|
||||
BaseEvenniaTest,
|
||||
BaseEvenniaCommandTest,
|
||||
EvenniaCommandTest,
|
||||
) # noqa
|
||||
from evennia.commands.default import (
|
||||
help as help_module,
|
||||
general,
|
||||
system,
|
||||
admin,
|
||||
account,
|
||||
building,
|
||||
batchprocess,
|
||||
comms,
|
||||
unloggedin,
|
||||
syscommands,
|
||||
from django.test import override_settings
|
||||
from evennia import (
|
||||
DefaultCharacter,
|
||||
DefaultExit,
|
||||
DefaultObject,
|
||||
DefaultRoom,
|
||||
ObjectDB,
|
||||
search_object,
|
||||
)
|
||||
from evennia.commands.default.muxcommand import MuxCommand
|
||||
from evennia.commands.command import Command, InterruptCommand
|
||||
from evennia.commands import cmdparser
|
||||
from evennia.commands.cmdset import CmdSet
|
||||
from evennia.utils import utils, gametime, create
|
||||
from evennia.server.sessionhandler import SESSIONS
|
||||
from evennia import search_object
|
||||
from evennia import DefaultObject, DefaultCharacter
|
||||
from evennia.commands.command import Command, InterruptCommand
|
||||
from evennia.commands.default import account, admin, batchprocess, building, comms, general
|
||||
from evennia.commands.default import help as help_module
|
||||
from evennia.commands.default import syscommands, system, unloggedin
|
||||
from evennia.commands.default.cmdset_character import CharacterCmdSet
|
||||
from evennia.commands.default.muxcommand import MuxCommand
|
||||
from evennia.prototypes import prototypes as protlib
|
||||
from evennia.server.sessionhandler import SESSIONS
|
||||
from evennia.utils import create, gametime, utils
|
||||
from evennia.utils.test_resources import BaseEvenniaCommandTest # noqa
|
||||
from evennia.utils.test_resources import BaseEvenniaTest, EvenniaCommandTest
|
||||
from parameterized import parameterized
|
||||
from twisted.internet import task
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Command testing
|
||||
|
|
@ -232,19 +225,16 @@ class TestHelp(BaseEvenniaCommandTest):
|
|||
),
|
||||
(
|
||||
"test/extra/subsubtopic", # partial subsub-match
|
||||
"Help for test/creating extra stuff/subsubtopic\n\n" "A subsubtopic text",
|
||||
"Help for test/creating extra stuff/subsubtopic\n\nA subsubtopic text",
|
||||
),
|
||||
(
|
||||
"test/creating extra/subsub", # partial subsub-match
|
||||
"Help for test/creating extra stuff/subsubtopic\n\n" "A subsubtopic text",
|
||||
"Help for test/creating extra stuff/subsubtopic\n\nA subsubtopic text",
|
||||
),
|
||||
("test/Something else", "Help for test/something else\n\n" "Something else"), # case
|
||||
("test/Something else", "Help for test/something else\n\nSomething else"), # case
|
||||
(
|
||||
"test/More", # case
|
||||
"Help for test/more\n\n"
|
||||
"Another text\n\n"
|
||||
"Subtopics:\n"
|
||||
" test/more/second-more",
|
||||
"Help for test/more\n\nAnother text\n\nSubtopics:\n test/more/second-more",
|
||||
),
|
||||
(
|
||||
"test/More/Second-more",
|
||||
|
|
@ -264,11 +254,11 @@ class TestHelp(BaseEvenniaCommandTest):
|
|||
),
|
||||
(
|
||||
"test/more/second/more again",
|
||||
"Help for test/more/second-more/more again\n\n" "Even more text.\n",
|
||||
"Help for test/more/second-more/more again\n\nEven more text.\n",
|
||||
),
|
||||
(
|
||||
"test/more/second/third",
|
||||
"Help for test/more/second-more/third more\n\n" "Third more text\n",
|
||||
"Help for test/more/second-more/third more\n\nThird more text\n",
|
||||
),
|
||||
]
|
||||
)
|
||||
|
|
@ -520,7 +510,7 @@ class TestCmdTasks(BaseEvenniaCommandTest):
|
|||
|
||||
def test_misformed_command(self):
|
||||
wanted_msg = (
|
||||
"Task command misformed.|Proper format tasks[/switch] " "[function name or task id]"
|
||||
"Task command misformed.|Proper format tasks[/switch] [function name or task id]"
|
||||
)
|
||||
self.call(system.CmdTasks(), f"/cancel", wanted_msg)
|
||||
|
||||
|
|
@ -557,18 +547,49 @@ class TestAdmin(BaseEvenniaCommandTest):
|
|||
|
||||
|
||||
class TestAccount(BaseEvenniaCommandTest):
|
||||
def test_ooc_look(self):
|
||||
if settings.MULTISESSION_MODE < 2:
|
||||
self.call(
|
||||
account.CmdOOCLook(), "", "You are out-of-character (OOC).", caller=self.account
|
||||
)
|
||||
if settings.MULTISESSION_MODE == 2:
|
||||
self.call(
|
||||
account.CmdOOCLook(),
|
||||
"",
|
||||
"Account TestAccount (you are OutofCharacter)",
|
||||
caller=self.account,
|
||||
)
|
||||
"""
|
||||
Test different account-specific modes
|
||||
|
||||
"""
|
||||
|
||||
@parameterized.expand(
|
||||
# multisession-mode, auto-puppet, max_nr_characters
|
||||
[
|
||||
(0, True, 1, "You are out-of-character"),
|
||||
(1, True, 1, "You are out-of-character"),
|
||||
(2, True, 1, "You are out-of-character"),
|
||||
(3, True, 1, "You are out-of-character"),
|
||||
(0, False, 1, "Account TestAccount"),
|
||||
(1, False, 1, "Account TestAccount"),
|
||||
(2, False, 1, "Account TestAccount"),
|
||||
(3, False, 1, "Account TestAccount"),
|
||||
(0, True, 2, "Account TestAccount"),
|
||||
(1, True, 2, "Account TestAccount"),
|
||||
(2, True, 2, "Account TestAccount"),
|
||||
(3, True, 2, "Account TestAccount"),
|
||||
(0, False, 2, "Account TestAccount"),
|
||||
(1, False, 2, "Account TestAccount"),
|
||||
(2, False, 2, "Account TestAccount"),
|
||||
(3, False, 2, "Account TestAccount"),
|
||||
]
|
||||
)
|
||||
def test_ooc_look(self, multisession_mode, auto_puppet, max_nr_chars, expected_result):
|
||||
|
||||
self.account.db._playable_characters = [self.char1]
|
||||
self.account.unpuppet_all()
|
||||
|
||||
with self.settings(MULTISESSION=multisession_mode):
|
||||
# we need to patch the module header instead of settings
|
||||
with patch("evennia.commands.default.account._MAX_NR_CHARACTERS", new=max_nr_chars):
|
||||
with patch(
|
||||
"evennia.commands.default.account._AUTO_PUPPET_ON_LOGIN", new=auto_puppet
|
||||
):
|
||||
self.call(
|
||||
account.CmdOOCLook(),
|
||||
"",
|
||||
expected_result,
|
||||
caller=self.account,
|
||||
)
|
||||
|
||||
def test_ooc(self):
|
||||
self.call(account.CmdOOC(), "", "You go OOC.", caller=self.account)
|
||||
|
|
@ -901,7 +922,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test2[+'three']",
|
||||
"Attribute Obj/test2[+'three'] [category:None] does not exist. (Nested lookups attempted)",
|
||||
"Attribute Obj/test2[+'three'] [category:None] does not exist. (Nested lookups"
|
||||
" attempted)",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
|
|
@ -1091,7 +1113,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
self.call(
|
||||
building.CmdSetAttribute(),
|
||||
"Obj/test4[0]['one']",
|
||||
"Attribute Obj/test4[0]['one'] [category:None] does not exist. (Nested lookups attempted)",
|
||||
"Attribute Obj/test4[0]['one'] [category:None] does not exist. (Nested lookups"
|
||||
" attempted)",
|
||||
)
|
||||
|
||||
def test_split_nested_attr(self):
|
||||
|
|
@ -1339,7 +1362,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
self.call(
|
||||
building.CmdTypeclass(),
|
||||
"Obj = evennia.objects.objects.DefaultExit",
|
||||
"Obj already has the typeclass 'evennia.objects.objects.DefaultExit'. Use /force to override.",
|
||||
"Obj already has the typeclass 'evennia.objects.objects.DefaultExit'. Use /force to"
|
||||
" override.",
|
||||
)
|
||||
self.call(
|
||||
building.CmdTypeclass(),
|
||||
|
|
@ -1355,9 +1379,9 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
self.call(
|
||||
building.CmdTypeclass(),
|
||||
"Obj",
|
||||
"Obj updated its existing typeclass (evennia.objects.objects.DefaultObject).\n"
|
||||
"Only the at_object_creation hook was run (update mode). Attributes set before swap were not removed\n"
|
||||
"(use `swap` or `type/reset` to clear all).",
|
||||
"Obj updated its existing typeclass (evennia.objects.objects.DefaultObject).\nOnly the"
|
||||
" at_object_creation hook was run (update mode). Attributes set before swap were not"
|
||||
" removed\n(use `swap` or `type/reset` to clear all).",
|
||||
cmdstring="update",
|
||||
)
|
||||
self.call(
|
||||
|
|
@ -1560,9 +1584,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
self.call(
|
||||
building.CmdTeleport(),
|
||||
"Obj = Room2",
|
||||
"Obj(#{}) is leaving Room(#{}), heading for Room2(#{}).|Teleported Obj -> Room2.".format(
|
||||
oid, rid, rid2
|
||||
),
|
||||
"Obj(#{}) is leaving Room(#{}), heading for Room2(#{}).|Teleported Obj -> Room2."
|
||||
.format(oid, rid, rid2),
|
||||
)
|
||||
self.call(building.CmdTeleport(), "NotFound = Room", "Could not find 'NotFound'.")
|
||||
self.call(
|
||||
|
|
@ -1598,7 +1621,7 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
self.call(
|
||||
building.CmdTag(),
|
||||
"Obj",
|
||||
"Tags on Obj: 'testtag', 'testtag2', " "'testtag2' (category: category1), 'testtag3'",
|
||||
"Tags on Obj: 'testtag', 'testtag2', 'testtag2' (category: category1), 'testtag3'",
|
||||
)
|
||||
|
||||
self.call(building.CmdTag(), "/search NotFound", "No objects found with tag 'NotFound'.")
|
||||
|
|
@ -1654,7 +1677,7 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
|
||||
self.call(
|
||||
building.CmdSpawn(),
|
||||
"/save {'key':'Test Char', " "'typeclass':'evennia.objects.objects.DefaultCharacter'}",
|
||||
"/save {'key':'Test Char', 'typeclass':'evennia.objects.objects.DefaultCharacter'}",
|
||||
"A prototype_key must be given, either as `prototype_key = <prototype>` or as "
|
||||
"a key 'prototype_key' inside the prototype structure.",
|
||||
)
|
||||
|
|
@ -1678,7 +1701,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
self.call(
|
||||
building.CmdSpawn(),
|
||||
"{'prototype_key':'GOBLIN', 'typeclass':'evennia.objects.objects.DefaultCharacter', "
|
||||
"'key':'goblin', 'location':'%s'}" % spawnLoc.dbref,
|
||||
"'key':'goblin', 'location':'%s'}"
|
||||
% spawnLoc.dbref,
|
||||
"Spawned goblin",
|
||||
)
|
||||
goblin = get_object(self, "goblin")
|
||||
|
|
@ -1725,7 +1749,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
# Location should be the specified location.
|
||||
self.call(
|
||||
building.CmdSpawn(),
|
||||
"/noloc {'prototype_parent':'TESTBALL', 'key': 'Ball', 'prototype_key': 'foo', 'location':'%s'}"
|
||||
"/noloc {'prototype_parent':'TESTBALL', 'key': 'Ball', 'prototype_key': 'foo',"
|
||||
" 'location':'%s'}"
|
||||
% spawnLoc.dbref,
|
||||
"Spawned Ball",
|
||||
)
|
||||
|
|
@ -1785,8 +1810,8 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
|
||||
|
||||
import evennia.commands.default.comms as cmd_comms # noqa
|
||||
from evennia.utils.create import create_channel # noqa
|
||||
from evennia.comms.comms import DefaultChannel # noqa
|
||||
from evennia.utils.create import create_channel # noqa
|
||||
|
||||
|
||||
@patch("evennia.commands.default.comms.CHANNEL_DEFAULT_TYPECLASS", DefaultChannel)
|
||||
|
|
@ -1986,7 +2011,8 @@ class TestBatchProcess(BaseEvenniaCommandTest):
|
|||
self.call(
|
||||
batchprocess.CmdBatchCommands(),
|
||||
"batchprocessor.example_batch_cmds",
|
||||
"Running Batch-command processor - Automatic mode for batchprocessor.example_batch_cmds",
|
||||
"Running Batch-command processor - Automatic mode for"
|
||||
" batchprocessor.example_batch_cmds",
|
||||
)
|
||||
# we make sure to delete the button again here to stop the running reactor
|
||||
confirm = building.CmdDestroy.confirm
|
||||
|
|
@ -2018,7 +2044,8 @@ class TestUnconnectedCommand(BaseEvenniaCommandTest):
|
|||
# instead of using SERVER_START_TIME (0), we use 86400 because Windows won't let us use anything lower
|
||||
gametime.SERVER_START_TIME = 86400
|
||||
expected = (
|
||||
"## BEGIN INFO 1.1\nName: %s\nUptime: %s\nConnected: %d\nVersion: Evennia %s\n## END INFO"
|
||||
"## BEGIN INFO 1.1\nName: %s\nUptime: %s\nConnected: %d\nVersion: Evennia %s\n## END"
|
||||
" INFO"
|
||||
% (
|
||||
settings.SERVERNAME,
|
||||
datetime.datetime.fromtimestamp(gametime.SERVER_START_TIME).ctime(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue