Rename all at_before/after hooks to at_pre/post. Old names still work but are deprecated. Resolves #1454.

This commit is contained in:
Griatch 2021-10-31 22:18:58 +01:00
parent 7b25299be4
commit 36e985557f
21 changed files with 106 additions and 102 deletions

View file

@ -101,6 +101,8 @@ Up requirements to Django 3.2+, Twisted 21+
`msg_contents`.
- Update defauklt website to show Telnet/SSL/SSH connect info. Added new
`SERVER_HOSTNAME` setting for use in the server:port stanza.
- Changed all `at_before/after_*` hooks to `at_pre/post_*` for consistency
across Evennia (the old names still work but are deprecated)
### Evennia 0.9.5 (2019-2020)

View file

@ -170,14 +170,14 @@ object).
1. The Exit command triggers `at_traverse(obj, destination)` on the Exit object.
1. In `at_traverse`, `object.move_to(destination)` is triggered. This triggers the following hooks,
in order:
1. `obj.at_before_move(destination)` - if this returns False, move is aborted.
1. `origin.at_before_leave(obj, destination)`
1. `obj.at_pre_move(destination)` - if this returns False, move is aborted.
1. `origin.at_pre_leave(obj, destination)`
1. `obj.announce_move_from(destination)`
1. Move is performed by changing `obj.location` from source location to `destination`.
1. `obj.announce_move_to(source)`
1. `destination.at_object_receive(obj, source)`
1. `obj.at_after_move(source)`
1. On the Exit object, `at_after_traverse(obj, source)` is triggered.
1. `obj.at_post_move(source)`
1. On the Exit object, `at_post_traverse(obj, source)` is triggered.
If the move fails for whatever reason, the Exit will look for an Attribute `err_traverse` on itself
and display this as an error message. If this is not found, the Exit will instead call

View file

@ -35,12 +35,12 @@ for more info.
**Q:** How does one keep a character from using any exit, if they meet a certain condition? (I.E. in
combat, immobilized, etc.)
**A:** The `at_before_move` hook is called by Evennia just before performing any move. If it returns
**A:** The `at_pre_move` hook is called by Evennia just before performing any move. If it returns
`False`, the move is aborted. Let's say we want to check for an [Attribute](../Components/Attributes.md) `cantmove`.
Add the following code to the `Character` class:
```python
def at_before_move(self, destination):
def at_pre_move(self, destination):
"Called just before trying to move"
if self.db.cantmove: # replace with condition you want to test
self.msg("Something is preventing you from moving!")

View file

@ -36,7 +36,7 @@ This requires a change to our Character typeclass. Open `mygame/typeclasses/char
class Character(DefaultCharacter):
# ...
def at_before_move(self, destination):
def at_pre_move(self, destination):
"""
Called by self.move_to when trying to move somewhere. If this returns
False, the move is immediately cancelled.
@ -49,7 +49,7 @@ class Character(DefaultCharacter):
```
When moving somewhere, [character.move_to](evennia.objects.objects.DefaultObject.move_to) is called. This in turn
will call `character.at_before_move`. Here we look for an Attribute `is_resting` (which we will assign below)
will call `character.at_pre_move`. Here we look for an Attribute `is_resting` (which we will assign below)
to determine if we are stuck on the chair or not.
## Making the Chair itself

View file

@ -81,14 +81,14 @@ This room checks the typeclass of objects entering it (using `utils.inherits_fro
contents and inform any `NPCs inside by calling their `at_char_entered` method.
You'll also see that we have added a 'look' into this code. This is because, by default, the
`at_object_receive` is carried out *before* the character's `at_after_move` which, we will now
`at_object_receive` is carried out *before* the character's `at_post_move` which, we will now
overload. This means that a character entering would see the NPC perform its actions before the
'look' command. Deactivate the look command in the default `Character` class within the
`typeclasses.characters` module:
```python
# Add this hook in any blank area within your Character class.
def at_after_move(self, source_location):
def at_post_move(self, source_location):
"""
Default is to look around after a move
Note: This has been moved to Room.at_object_receive

View file

@ -427,8 +427,8 @@ class CmdGet(COMMAND_DEFAULT_CLASS):
caller.msg("You can't get that.")
return
# calling at_before_get hook method
if not obj.at_before_get(caller):
# calling at_pre_get hook method
if not obj.at_pre_get(caller):
return
success = obj.move_to(caller, quiet=True)
@ -477,8 +477,8 @@ class CmdDrop(COMMAND_DEFAULT_CLASS):
if not obj:
return
# Call the object script's at_before_drop() method.
if not obj.at_before_drop(caller):
# Call the object script's at_pre_drop() method.
if not obj.at_pre_drop(caller):
return
success = obj.move_to(caller.location, quiet=True)
@ -530,8 +530,8 @@ class CmdGive(COMMAND_DEFAULT_CLASS):
caller.msg("You are not holding %s." % to_give.key)
return
# calling at_before_give hook method
if not to_give.at_before_give(caller, target):
# calling at_pre_give hook method
if not to_give.at_pre_give(caller, target):
return
# give object
@ -597,14 +597,14 @@ class CmdSay(COMMAND_DEFAULT_CLASS):
speech = self.args
# Calling the at_before_say hook on the character
speech = caller.at_before_say(speech)
# Calling the at_pre_say hook on the character
speech = caller.at_pre_say(speech)
# If speech is empty, stop here
if not speech:
return
# Call the at_after_say hook on the character
# Call the at_post_say hook on the character
caller.at_say(speech, msg_self=True)
@ -643,7 +643,7 @@ class CmdWhisper(COMMAND_DEFAULT_CLASS):
return
# Call a hook to change the speech before whispering
speech = caller.at_before_say(speech, whisper=True, receivers=receivers)
speech = caller.at_pre_say(speech, whisper=True, receivers=receivers)
# no need for self-message if we are whispering to ourselves (for some reason)
msg_self = None if caller in receivers else True

View file

@ -290,7 +290,7 @@ class EventCharacter(DefaultCharacter):
super().announce_move_to(source_location, msg=string, mapping=mapping)
def at_before_move(self, destination):
def at_pre_move(self, destination):
"""
Called just before starting to move this object to
destination.
@ -330,7 +330,7 @@ class EventCharacter(DefaultCharacter):
return True
def at_after_move(self, source_location):
def at_post_move(self, source_location):
"""
Called after move has completed, regardless of quiet mode or
not. Allows changes to the object due to the location it is
@ -340,7 +340,7 @@ class EventCharacter(DefaultCharacter):
source_location (Object): Wwhere we came from. This may be `None`.
"""
super().at_after_move(source_location)
super().at_post_move(source_location)
origin = source_location
destination = self.location
@ -410,7 +410,7 @@ class EventCharacter(DefaultCharacter):
super().at_pre_unpuppet()
def at_before_say(self, message, **kwargs):
def at_pre_say(self, message, **kwargs):
"""
Before the object says something.
@ -646,7 +646,7 @@ class EventExit(DefaultExit):
normally by calling
`traversing_object.move_to(target_location)`. It is normally
only implemented by Exit objects. If it returns False (usually
because `move_to` returned False), `at_after_traverse` below
because `move_to` returned False), `at_post_traverse` below
should not be called and instead `at_failed_traverse` should be
called.

View file

@ -970,7 +970,7 @@ class CmdSay(RPCommand): # replaces standard say
return
# calling the speech modifying hook
speech = caller.at_before_say(self.args)
speech = caller.at_pre_say(self.args)
# preparing the speech with sdesc/speech parsing.
targets = self.caller.location.contents
send_emote(self.caller, targets, speech, anonymous_add=None)
@ -1614,7 +1614,7 @@ class ContribRPCharacter(DefaultCharacter, ContribRPObject):
# initializing sdesc
self.sdesc.add("A normal person")
def at_before_say(self, message, **kwargs):
def at_pre_say(self, message, **kwargs):
"""
Called before the object says or whispers anything, return modified message.

View file

@ -59,7 +59,7 @@ class SlowExit(DefaultExit):
"This callback will be called by utils.delay after move_delay seconds."
source_location = traversing_object.location
if traversing_object.move_to(target_location):
self.at_after_traverse(traversing_object, source_location)
self.at_post_traverse(traversing_object, source_location)
else:
if self.db.err_traverse:
# if exit has a better error message, let's use it.

View file

@ -322,7 +322,7 @@ class TBBasicCharacter(DefaultCharacter):
can be changed at creation and factor into combat calculations.
"""
def at_before_move(self, destination):
def at_pre_move(self, destination):
"""
Called just before starting to move this object to
destination.

View file

@ -588,7 +588,7 @@ class TBEArmor(DefaultObject):
-4
) # Amount to modify defense value (pos = harder to hit, neg = easier)
def at_before_drop(self, dropper):
def at_pre_drop(self, dropper):
"""
Can't drop in combat.
"""
@ -605,7 +605,7 @@ class TBEArmor(DefaultObject):
dropper.db.worn_armor = None
dropper.location.msg_contents("%s removes %s." % (dropper, self))
def at_before_give(self, giver, getter):
def at_pre_give(self, giver, getter):
"""
Can't give away in combat.
"""
@ -649,7 +649,7 @@ class TBEquipCharacter(DefaultCharacter):
can be changed at creation and factor into combat calculations.
"""
def at_before_move(self, destination):
def at_pre_move(self, destination):
"""
Called just before starting to move this object to
destination.

View file

@ -531,7 +531,7 @@ class TBItemsCharacter(DefaultCharacter):
can be changed at creation and factor into combat calculations.
"""
def at_before_move(self, destination):
def at_pre_move(self, destination):
"""
Called just before starting to move this object to
destination.

View file

@ -351,7 +351,7 @@ class TBMagicCharacter(DefaultCharacter):
self.db.max_mp = 20 # Set maximum MP to 20
self.db.mp = self.db.max_mp # Set current MP to maximum
def at_before_move(self, destination):
def at_pre_move(self, destination):
"""
Called just before starting to move this object to
destination.

View file

@ -799,7 +799,7 @@ class TBRangeCharacter(DefaultCharacter):
can be changed at creation and factor into combat calculations.
"""
def at_before_move(self, destination):
def at_pre_move(self, destination):
"""
Called just before starting to move this object to
destination.
@ -833,7 +833,7 @@ class TBRangeObject(DefaultObject):
objects on your own turn.
"""
def at_before_drop(self, dropper):
def at_pre_drop(self, dropper):
"""
Called by the default `drop` command before this object has been
dropped.
@ -869,7 +869,7 @@ class TBRangeObject(DefaultObject):
Notes:
This hook cannot stop the drop from happening. Use
permissions or the at_before_drop() hook for that.
permissions or the at_pre_drop() hook for that.
"""
# If dropper is currently in combat
@ -878,7 +878,7 @@ class TBRangeObject(DefaultObject):
self.db.combat_range = {}
dropper.location.db.combat_turnhandler.join_rangefield(self, anchor_obj=dropper)
def at_before_get(self, getter):
def at_pre_get(self, getter):
"""
Called by the default `get` command before this object has been
picked up.
@ -917,7 +917,7 @@ class TBRangeObject(DefaultObject):
Notes:
This hook cannot stop the pickup from happening. Use
permissions or the at_before_get() hook for that.
permissions or the at_pre_get() hook for that.
"""
# If gotten, erase range values
@ -932,7 +932,7 @@ class TBRangeObject(DefaultObject):
if is_in_combat(getter):
spend_action(getter, 1, action_name="get") # Use up one action.
def at_before_give(self, giver, getter):
def at_pre_give(self, giver, getter):
"""
Called by the default `give` command before this object has been
given.
@ -976,7 +976,7 @@ class TBRangeObject(DefaultObject):
Notes:
This hook cannot stop the give from happening. Use
permissions or the at_before_give() hook for that.
permissions or the at_pre_give() hook for that.
"""
# Spend an action if in combat

View file

@ -751,7 +751,7 @@ class CrumblingWall(TutorialObject, DefaultExit):
# call the parent to continue execution (will use the desc we just set)
return super().return_appearance(caller)
def at_after_traverse(self, traverser, source_location):
def at_post_traverse(self, traverser, source_location):
"""
This is called after we traversed this exit. Cleans up and resets
the puzzle.

View file

@ -347,7 +347,7 @@ class WildernessScript(DefaultScript):
# ... but that other wilderness room belongs to another
# wilderness map
create_new_room = True
old_room.wilderness.at_after_object_leave(obj)
old_room.wilderness.at_post_object_leave(obj)
else:
for item in old_room.contents:
if item.has_account:
@ -451,7 +451,7 @@ class WildernessScript(DefaultScript):
# And finally put this room away in storage
self.db.unused_rooms.append(room)
def at_after_object_leave(self, obj):
def at_post_object_leave(self, obj):
"""
Called after an object left this wilderness map. Used for cleaning up.
@ -551,7 +551,7 @@ class WildernessRoom(DefaultRoom):
target_location (Object): Where `moved_obj` is going.
"""
self.wilderness.at_after_object_leave(moved_obj)
self.wilderness.at_post_object_leave(moved_obj)
def set_active_coordinates(self, new_coordinates, obj):
"""
@ -698,7 +698,7 @@ class WildernessExit(DefaultExit):
):
return False
if not traversing_object.at_before_move(None):
if not traversing_object.at_pre_move(None):
return False
traversing_object.location.msg_contents(
"{} leaves to {}".format(traversing_object.key, new_coordinates),
@ -712,7 +712,7 @@ class WildernessExit(DefaultExit):
exclude=[traversing_object],
)
traversing_object.at_after_move(None)
traversing_object.at_post_move(None)
return True

View file

@ -19,7 +19,7 @@ class Character(DefaultCharacter):
(important!)sets locks so character cannot be picked up
and its commands only be called by itself, not anyone else.
(to change things, use at_object_creation() instead).
at_after_move(source_location) - Launches the "look" command after every move.
at_post_move(source_location) - Launches the "look" command after every move.
at_post_unpuppet(account) - when Account disconnects from the Character, we
store the current location in the pre_logout_location Attribute and
move it to a None-location so the "unpuppeted" character

View file

@ -29,7 +29,7 @@ class Exit(DefaultExit):
at_traverse(traveller, target_loc) - called to do the actual traversal and calling of the other hooks.
If overloading this, consider using super() to use the default
movement implementation (and hook-calling).
at_after_traverse(traveller, source_loc) - called by at_traverse just after traversing.
at_post_traverse(traveller, source_loc) - called by at_traverse just after traversing.
at_failed_traverse(traveller) - called by at_traverse if traversal failed for some reason. Will
not be called if the attribute `err_traverse` is
defined, in which case that will simply be echoed.

View file

@ -119,13 +119,13 @@ class Object(DefaultObject):
of a lock access check on this object. Return value
does not affect check result.
at_before_move(destination) - called just before moving object
at_pre_move(destination) - called just before moving object
to the destination. If returns False, move is cancelled.
announce_move_from(destination) - called in old location, just
before move, if obj.move_to() has quiet=False
announce_move_to(source_location) - called in new location, just
after move, if obj.move_to() has quiet=False
at_after_move(source_location) - always called after a move has
at_post_move(source_location) - always called after a move has
been successfully performed.
at_object_leave(obj, target_location) - called when an object leaves
this object in any fashion
@ -136,7 +136,7 @@ class Object(DefaultObject):
handles all moving across the exit, including
calling the other exit hooks. Use super() to retain
the default functionality.
at_after_traverse(traversing_object, source_location) - (exit-objects only)
at_post_traverse(traversing_object, source_location) - (exit-objects only)
called just after a traversal has happened.
at_failed_traverse(traversing_object) - (exit-objects only) called if
traversal fails and property err_traverse is not defined.

View file

@ -840,7 +840,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
moving to a None location. If you want to run hooks, run them manually
(and make sure they can manage None locations).
move_hooks (bool): If False, turn off the calling of move-related hooks
(at_before/after_move etc) with quiet=True, this is as quiet a move
(at_pre/post_move etc) with quiet=True, this is as quiet a move
as can be done.
Keyword Args:
@ -857,13 +857,13 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
The `DefaultObject` hooks called (if `move_hooks=True`) are, in order:
1. `self.at_before_move(destination)` (if this returns False, move is aborted)
1. `self.at_pre_move(destination)` (if this returns False, move is aborted)
2. `source_location.at_object_leave(self, destination)`
3. `self.announce_move_from(destination)`
4. (move happens here)
5. `self.announce_move_to(source_location)`
6. `destination.at_object_receive(self, source_location)`
7. `self.at_after_move(source_location)`
7. `self.at_post_move(source_location)`
"""
def logerr(string="", err=None):
@ -890,10 +890,10 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
# Before the move, call eventual pre-commands.
if move_hooks:
try:
if not self.at_before_move(destination, **kwargs):
if not self.at_pre_move(destination, **kwargs):
return False
except Exception as err:
logerr(errtxt.format(err="at_before_move()"), err)
logerr(errtxt.format(err="at_pre_move()"), err)
return False
# Save the old location
@ -943,9 +943,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
# (usually calling 'look')
if move_hooks:
try:
self.at_after_move(source_location, **kwargs)
self.at_post_move(source_location, **kwargs)
except Exception as err:
logerr(errtxt.format(err="at_after_move"), err)
logerr(errtxt.format(err="at_post_move"), err)
return False
return True
@ -1244,7 +1244,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
self.aliases.batch_add(*cdict["aliases"])
if cdict.get("location"):
cdict["location"].at_object_receive(self, None)
self.at_after_move(None)
self.at_post_move(None)
if cdict.get("tags"):
# this should be a list of tags, tuples (key, category) or (key, category, data)
self.tags.batch_add(*cdict["tags"])
@ -1452,7 +1452,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
# hooks called when moving the object
def at_before_move(self, destination, **kwargs):
def at_pre_move(self, destination, **kwargs):
"""
Called just before starting to move this object to
destination.
@ -1473,6 +1473,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
# return has_perm(self, destination, "can_move")
return True
# deprecated alias
at_before_move = at_pre_move
def announce_move_from(self, destination, msg=None, mapping=None, **kwargs):
"""
Called if the move is to be announced. This is
@ -1583,7 +1586,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
destination.msg_contents(string, exclude=(self,), from_obj=self, mapping=mapping)
def at_after_move(self, source_location, **kwargs):
def at_post_move(self, source_location, **kwargs):
"""
Called after move has completed, regardless of quiet mode or
not. Allows changes to the object due to the location it is
@ -1597,6 +1600,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
"""
pass
# deprecated
at_after_move = at_post_move
def at_object_leave(self, moved_obj, target_location, **kwargs):
"""
Called just before an object leaves from inside this object
@ -1630,7 +1636,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
normally by calling
`traversing_object.move_to(target_location)`. It is normally
only implemented by Exit objects. If it returns False (usually
because `move_to` returned False), `at_after_traverse` below
because `move_to` returned False), `at_post_traverse` below
should not be called and instead `at_failed_traverse` should be
called.
@ -1643,7 +1649,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
"""
pass
def at_after_traverse(self, traversing_object, source_location, **kwargs):
def at_post_traverse(self, traversing_object, source_location, **kwargs):
"""
Called just after an object successfully used this object to
traverse to another object (i.e. this object is a type of
@ -1660,6 +1666,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
"""
pass
# deprecated
at_after_traverse = at_post_traverse
def at_failed_traverse(self, traversing_object, **kwargs):
"""
This is called if an object fails to traverse this object for
@ -1901,7 +1910,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
"""
pass
def at_before_get(self, getter, **kwargs):
def at_pre_get(self, getter, **kwargs):
"""
Called by the default `get` command before this object has been
picked up.
@ -1920,6 +1929,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
"""
return True
# deprecated
at_before_get = at_pre_get
def at_get(self, getter, **kwargs):
"""
Called by the default `get` command when this object has been
@ -1932,12 +1944,12 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
Notes:
This hook cannot stop the pickup from happening. Use
permissions or the at_before_get() hook for that.
permissions or the at_pre_get() hook for that.
"""
pass
def at_before_give(self, giver, getter, **kwargs):
def at_pre_give(self, giver, getter, **kwargs):
"""
Called by the default `give` command before this object has been
given.
@ -1958,6 +1970,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
"""
return True
# deprecated
at_before_give = at_pre_give
def at_give(self, giver, getter, **kwargs):
"""
Called by the default `give` command when this object has been
@ -1971,12 +1986,12 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
Notes:
This hook cannot stop the give from happening. Use
permissions or the at_before_give() hook for that.
permissions or the at_pre_give() hook for that.
"""
pass
def at_before_drop(self, dropper, **kwargs):
def at_pre_drop(self, dropper, **kwargs):
"""
Called by the default `drop` command before this object has been
dropped.
@ -2002,6 +2017,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
return False
return True
# deprecated
at_before_drop = at_pre_drop
def at_drop(self, dropper, **kwargs):
"""
Called by the default `drop` command when this object has been
@ -2014,12 +2032,12 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
Notes:
This hook cannot stop the drop from happening. Use
permissions or the at_before_drop() hook for that.
permissions or the at_pre_drop() hook for that.
"""
pass
def at_before_say(self, message, **kwargs):
def at_pre_say(self, message, **kwargs):
"""
Before the object says something.
@ -2044,6 +2062,9 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
"""
return message
# deprecated
at_before_say = at_pre_say
def at_say(
self,
message,
@ -2339,7 +2360,7 @@ class DefaultCharacter(DefaultObject):
# add the default cmdset
self.cmdset.add_default(settings.CMDSET_CHARACTER, persistent=True)
def at_after_move(self, source_location, **kwargs):
def at_post_move(self, source_location, **kwargs):
"""
We make sure to look around after a move.
@ -2347,6 +2368,9 @@ class DefaultCharacter(DefaultObject):
if self.location.access(self, "view"):
self.msg(text=(self.at_look(self.location), {"type": "look"}))
# deprecated
at_after_move = at_post_move
def at_pre_puppet(self, account, session=None, **kwargs):
"""
Return the character from storage in None location in `at_post_unpuppet`.
@ -2811,7 +2835,7 @@ class DefaultExit(DefaultObject):
"""
source_location = traversing_object.location
if traversing_object.move_to(target_location):
self.at_after_traverse(traversing_object, source_location)
self.at_post_traverse(traversing_object, source_location)
else:
if self.db.err_traverse:
# if exit has a better error message, let's use it.

View file

@ -39,34 +39,12 @@ class TestGeneralContext(TestCase):
"websocket_port": "websocket_client_port_testvalue",
"websocket_url": "websocket_client_url_testvalue",
"rest_api_enabled": True,
"server_hostname": 'localhost',
"ssh_enabled": False,
"ssh_ports": False,
"telnet_enabled": True,
"telnet_ports": [4000],
"telnet_ssl_enabled": False,
"telnet_ssl_ports": [4003],
},
)
# spec being an empty list will initially raise AttributeError in set_game_name_and_slogan to test defaults
@patch("evennia.web.utils.general_context.settings", spec=[])
@patch("evennia.web.utils.general_context.get_evennia_version")
def test_set_game_name_and_slogan(self, mock_get_version, mock_settings):
mock_get_version.return_value = "version 1"
# test default/fallback values
mock_settings.REST_API_ENABLED = False
general_context.set_game_name_and_slogan()
self.assertEqual(general_context.GAME_NAME, "Evennia")
self.assertEqual(general_context.GAME_SLOGAN, "version 1")
# test values when the settings are defined
mock_settings.SERVERNAME = "test_name"
mock_settings.GAME_SLOGAN = "test_game_slogan"
general_context.set_game_name_and_slogan()
self.assertEqual(general_context.GAME_NAME, "test_name")
self.assertEqual(general_context.GAME_SLOGAN, "test_game_slogan")
@patch("evennia.web.utils.general_context.settings")
def test_set_webclient_settings(self, mock_settings):
mock_settings.WEBCLIENT_ENABLED = "webclient"
mock_settings.WEBSOCKET_CLIENT_URL = "websocket_url"
mock_settings.WEBSOCKET_CLIENT_ENABLED = "websocket_client"
mock_settings.WEBSOCKET_CLIENT_PORT = 5000
general_context.set_webclient_settings()
self.assertEqual(general_context.WEBCLIENT_ENABLED, "webclient")
self.assertEqual(general_context.WEBSOCKET_URL, "websocket_url")
self.assertEqual(general_context.WEBSOCKET_CLIENT_ENABLED, "websocket_client")
self.assertEqual(general_context.WEBSOCKET_PORT, 5000)