Further tests with non-sqlite unit tests

This commit is contained in:
Griatch 2023-12-10 23:56:50 +01:00
parent 3e70507730
commit b6d9282594
4 changed files with 24 additions and 20 deletions

View file

@ -1339,14 +1339,6 @@ class TestXYZGrid(BaseEvenniaTest):
zcoord = "map1"
def setUp(self):
from django.conf import settings
from evennia import create_object
# we need to create a home room for the grid to be able to be properly deleted
home = create_object(typeclass="typeclasses.rooms.Room", key="Home", nohome=True)
home.id = settings.DEFAULT_HOME.strip("#")
home.save()
self.grid, err = xyzgrid.XYZGrid.create("testgrid")
self.map_data1 = {"map": MAP1, "zcoord": self.zcoord}

View file

@ -3,13 +3,12 @@ Test tutorial_world/mob
"""
from mock import patch
from twisted.internet.base import DelayedCall
from twisted.trial.unittest import TestCase as TwistedTestCase
from evennia.commands.default.tests import BaseEvenniaCommandTest
from evennia.utils.create import create_object
from evennia.utils.test_resources import BaseEvenniaTest, mockdeferLater, mockdelay
from mock import patch
from twisted.internet.base import DelayedCall
from twisted.trial.unittest import TestCase as TwistedTestCase
from . import mob
from . import objects as tutobjects
@ -35,6 +34,10 @@ DelayedCall.debug = True
class TestTutorialWorldObjects(TwistedTestCase, BaseEvenniaCommandTest):
def tearDown(self):
self.char1.delete()
super(BaseEvenniaCommandTest, self).tearDown()
def test_tutorialobj(self):
obj1 = create_object(tutobjects.TutorialObject, key="tutobj")
obj1.reset()
@ -103,15 +106,19 @@ class TestTutorialWorldObjects(TwistedTestCase, BaseEvenniaCommandTest):
self.call(
tutobjects.CmdShiftRoot(),
"green root up",
"You shift the weedy green root upwards.|Holding aside the root you "
"think you notice something behind it ...",
(
"You shift the weedy green root upwards.|Holding aside the root you "
"think you notice something behind it ..."
),
obj=wall,
)
self.call(
tutobjects.CmdPressButton(),
"",
"You move your fingers over the suspicious depression, then gives it a "
"decisive push. First",
(
"You move your fingers over the suspicious depression, then gives it a "
"decisive push. First"
),
obj=wall,
)
# we patch out the delay, so these are closed immediately

View file

@ -1185,7 +1185,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
for session in self.sessions.all():
self.account.unpuppet_object(session)
self.account = None
# unlink account/home to avoid issues with saving
self.db_account = None
self.db_home = None
for script in _ScriptDB.objects.get_all_scripts_on_obj(self):
script.delete()

View file

@ -97,6 +97,7 @@ DEFAULT_SETTING_RESETS = dict(
BASE_GUEST_TYPECLASS="evennia.accounts.accounts.DefaultGuest",
# a special setting boolean TEST_ENVIRONMENT is set by the test runner
# while the test suite is running.
DEFAULT_HOME="#1",
TEST_ENVIRONMENT=True,
)
@ -191,11 +192,11 @@ class EvenniaTestMixin:
self.account2.delete()
# Set up fake prototype module for allowing tests to use named prototypes.
@override_settings(
PROTOTYPE_MODULES=["evennia.utils.tests.data.prototypes_example"], DEFAULT_HOME="#1"
)
@override_settings(PROTOTYPE_MODULES=["evennia.utils.tests.data.prototypes_example"])
def create_rooms(self):
self.room1 = create.create_object(self.room_typeclass, key="Room", nohome=True)
self.room1.id = 1 # be sure this is default Home
self.room1.save()
self.room1.db.desc = "room_desc"
self.room2 = create.create_object(self.room_typeclass, key="Room2")
@ -552,6 +553,7 @@ class BaseEvenniaTestCase(TestCase):
"""
def tearDown(self) -> None:
super().tearDown()
flush_cache()
@ -571,6 +573,7 @@ class EvenniaTestCase(TestCase):
"""
def tearDown(self) -> None:
super().tearDown()
flush_cache()