mirror of
https://github.com/evennia/evennia.git
synced 2026-04-03 06:27:17 +02:00
Test to improve test behavior for postgres/mysql
This commit is contained in:
parent
cff2bc4c4c
commit
608ec2f1fb
3 changed files with 24 additions and 11 deletions
|
|
@ -676,19 +676,25 @@ class ObjectDBManager(TypedObjectManager):
|
|||
|
||||
location = dbid_to_obj(location, self.model)
|
||||
destination = dbid_to_obj(destination, self.model)
|
||||
if home:
|
||||
home = dbid_to_obj(home, self.model)
|
||||
|
||||
if not nohome and not home:
|
||||
try:
|
||||
home = dbid_to_obj(settings.DEFAULT_HOME, self.model)
|
||||
except self.model.DoesNotExist:
|
||||
if home:
|
||||
home_obj_or_dbref = home
|
||||
elif nohome:
|
||||
home_obj_or_dbref = None
|
||||
else:
|
||||
home_obj_or_dbref = settings.DEFAULT_HOME
|
||||
|
||||
try:
|
||||
home = dbid_to_obj(home_obj_or_dbref, self.model)
|
||||
except self.model.DoesNotExist:
|
||||
if settings._TEST_ENVIRONMENT:
|
||||
# this happens for databases where the #1 location is flushed during tests
|
||||
home = None
|
||||
else:
|
||||
raise self.model.DoesNotExist(
|
||||
"settings.DEFAULT_HOME (= '%s') does not exist, or the setting is malformed."
|
||||
% settings.DEFAULT_HOME
|
||||
f"settings.DEFAULT_HOME (= '{settings.DEFAULT_HOME}') does not exist, "
|
||||
"or the setting is malformed."
|
||||
)
|
||||
elif nohome and not home:
|
||||
home = None
|
||||
|
||||
# create new instance
|
||||
new_object = typeclass(
|
||||
|
|
|
|||
|
|
@ -1149,6 +1149,10 @@ SESSION_SYNC_ATTRS = (
|
|||
AMP_SERVER_PROTOCOL_CLASS = "evennia.server.portal.amp_server.AMPServerProtocol"
|
||||
AMP_CLIENT_PROTOCOL_CLASS = "evennia.server.amp_client.AMPServerClientProtocol"
|
||||
|
||||
# don't change this manually, it can be checked from code to know if
|
||||
# being run from a unit test (set by the evennia.utils.test_resources.BaseEvenniaTest
|
||||
# and BaseEvenniaTestCase unit testing parents)
|
||||
_TEST_ENVIRONMENT = False
|
||||
|
||||
######################################################################
|
||||
# Django extensions
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ DEFAULT_SETTING_RESETS = dict(
|
|||
FUNCPARSER_PROTOTYPE_PARSING_MODULES=["evennia.prototypes.protfuncs",
|
||||
"evennia.game_template.server.conf.prototypefuncs"],
|
||||
BASE_GUEST_TYPECLASS="evennia.accounts.accounts.DefaultGuest",
|
||||
# a special flag; test with settings._TEST_ENVIRONMENT to see if code runs in a test
|
||||
_TEST_ENVIRONMENT=True,
|
||||
)
|
||||
|
||||
DEFAULT_SETTINGS = {
|
||||
|
|
@ -153,7 +155,8 @@ 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"],
|
||||
DEFAULT_HOME="#1")
|
||||
def create_rooms(self):
|
||||
self.room1 = create.create_object(self.room_typeclass, key="Room", nohome=True)
|
||||
self.room1.db.desc = "room_desc"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue