mirror of
https://github.com/evennia/evennia.git
synced 2026-03-28 10:37:16 +01:00
Added a new 'contrib' folder for optional code snippets not suitable for the server core. Added contrib/menusystem for implementing a multi-choice menu system. Added contrib/lineeditor - a powerful line editor with commands mimicking VI. Also added an example NPC class using the menu system to allow for a conversation. As part of creating these contributions, lots of bugs were found and fixed. A new and more powerful cmdparser was intruduced as a result - this one is much easier to understand than the old one, while being more efficient and versatile. All testsuites were updated. Also: Resolves issue 165.
This commit is contained in:
parent
2c47d6a66b
commit
b9c1921a0b
16 changed files with 1426 additions and 354 deletions
|
|
@ -23,7 +23,10 @@ from src.utils import create, ansi
|
|||
from src.server import session, sessionhandler
|
||||
from src.locks.lockhandler import LockHandler
|
||||
from src.server.models import ServerConfig
|
||||
from src.comms.models import Channel, Msg, PlayerChannelConnection
|
||||
from src.comms.models import Channel, Msg, PlayerChannelConnection, ExternalChannelConnection
|
||||
from django.contrib.auth.models import User
|
||||
from src.players.models import PlayerDB
|
||||
from src.objects.models import ObjectDB
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Command testing
|
||||
|
|
@ -32,6 +35,17 @@ from src.comms.models import Channel, Msg, PlayerChannelConnection
|
|||
# print all feedback from test commands (can become very verbose!)
|
||||
VERBOSE = False
|
||||
|
||||
|
||||
def cleanup():
|
||||
User.objects.all().delete()
|
||||
PlayerDB.objects.all().delete()
|
||||
ObjectDB.objects.all().delete()
|
||||
Channel.objects.all().delete()
|
||||
Msg.objects.all().delete()
|
||||
PlayerChannelConnection.objects.all().delete()
|
||||
ExternalChannelConnection.objects.all().delete()
|
||||
ServerConfig.objects.all().delete()
|
||||
|
||||
class FakeSession(session.Session):
|
||||
"""
|
||||
A fake session that
|
||||
|
|
@ -76,15 +90,16 @@ class CommandTest(TestCase):
|
|||
Inherit new tests from this.
|
||||
"""
|
||||
|
||||
NOMANGLE = False # mangle command input for extra testing
|
||||
NOMANGLE = True # mangle command input for extra testing
|
||||
|
||||
def setUp(self):
|
||||
"sets up the testing environment"
|
||||
ServerConfig.objects.conf("default_home", 2)
|
||||
|
||||
self.addCleanup(cleanup)
|
||||
|
||||
self.room1 = create.create_object(settings.BASE_ROOM_TYPECLASS, key="room1")
|
||||
self.room2 = create.create_object(settings.BASE_ROOM_TYPECLASS, key="room2")
|
||||
|
||||
self.room2 = create.create_object(settings.BASE_ROOM_TYPECLASS, key="room2")
|
||||
# create a faux player/character for testing.
|
||||
self.char1 = create.create_player("TestChar", "testplayer@test.com", "testpassword", location=self.room1)
|
||||
self.char1.player.user.is_superuser = True
|
||||
|
|
@ -111,6 +126,17 @@ class CommandTest(TestCase):
|
|||
self.exit1 = create.create_object(settings.BASE_EXIT_TYPECLASS, key="exit1", location=self.room1)
|
||||
self.exit2 = create.create_object(settings.BASE_EXIT_TYPECLASS, key="exit2", location=self.room2)
|
||||
|
||||
def tearDown(self):
|
||||
"Cleans up testing environment after test has run."
|
||||
User.objects.all().delete()
|
||||
PlayerDB.objects.all().delete()
|
||||
ObjectDB.objects.all().delete()
|
||||
Channel.objects.all().delete()
|
||||
Msg.objects.all().delete()
|
||||
PlayerChannelConnection.objects.all().delete()
|
||||
ExternalChannelConnection.objects.all().delete()
|
||||
ServerConfig.objects.all().delete()
|
||||
|
||||
def get_cmd(self, cmd_class, argument_string=""):
|
||||
"""
|
||||
Obtain a cmd instance from a class and an input string
|
||||
|
|
@ -401,15 +427,16 @@ class TestChannelCreate(CommandTest):
|
|||
self.execute_cmd("@ccreate testchannel1;testchan1;testchan1b = This is a test channel")
|
||||
self.execute_cmd("testchan1 Hello", "[testchannel1] TestChar: Hello")
|
||||
class TestAddCom(CommandTest):
|
||||
def test_call(self):
|
||||
def test_call(self):
|
||||
self.execute_cmd("@cdestroy testchannel1", "Channel 'testchannel1'")
|
||||
self.execute_cmd("@ccreate testchannel1;testchan1;testchan1b = This is a test channel")
|
||||
self.execute_cmd("addcom chan1 = testchannel1")
|
||||
self.execute_cmd("addcom chan2 = testchan1")
|
||||
self.execute_cmd("delcom testchannel1")
|
||||
self.execute_cmd("addcom testchannel1" "You now listen to the channel channel.")
|
||||
|
||||
class TestDelCom(CommandTest):
|
||||
def test_call(self):
|
||||
self.execute_cmd("@cdestroy testchannel1", "Channel 'testchannel1'")
|
||||
self.execute_cmd("@ccreate testchannel1;testchan1;testchan1b = This is a test channel")
|
||||
self.execute_cmd("addcom chan1 = testchan1")
|
||||
self.execute_cmd("addcom chan2 = testchan1b")
|
||||
|
|
@ -430,7 +457,9 @@ class TestChannels(CommandTest):
|
|||
self.execute_cmd("@cdestroy testchannel1", "Channel 'testchannel1'")
|
||||
class TestCBoot(CommandTest):
|
||||
def test_call(self):
|
||||
self.execute_cmd("@cdestroy testchannel1", "Channel 'testchannel1'")
|
||||
self.execute_cmd("@ccreate testchannel1;testchan1;testchan1b = This is a test channel")
|
||||
self.execute_cmd("addcom testchan = testchannel1")
|
||||
self.execute_cmd("@cboot testchannel1 = TestChar", "TestChar boots TestChar from channel.")
|
||||
class TestCemit(CommandTest):
|
||||
def test_call(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue