mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Test for XYZRoom and XYZExit subclasses with callbacks.
This commit is contained in:
parent
fe5faa45c4
commit
38768d137d
2 changed files with 80 additions and 1 deletions
|
|
@ -6,7 +6,7 @@ Tests for the XYZgrid system.
|
|||
|
||||
from random import randint
|
||||
from parameterized import parameterized
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, override_settings
|
||||
from evennia.utils.test_resources import BaseEvenniaTest
|
||||
from . import xymap, xyzgrid, xymap_legend, xyzroom
|
||||
|
||||
|
|
@ -1415,3 +1415,81 @@ class TestBuildExampleGrid(BaseEvenniaTest):
|
|||
self.assertTrue(room2a.db.desc.startswith("This is the entrance to"))
|
||||
self.assertEqual(room2b.key, "North-west corner of the atrium")
|
||||
self.assertTrue(room2b.db.desc.startswith("Sunlight sifts down"))
|
||||
|
||||
|
||||
class TestXyzRoom(xyzroom.XYZRoom):
|
||||
def at_object_creation(self):
|
||||
breakpoint()
|
||||
|
||||
class TestXyzExit(xyzroom.XYZExit):
|
||||
def at_object_creation(self):
|
||||
breakpoint()
|
||||
|
||||
# @override_settings(
|
||||
# XYZEXIT_PROTOTYPE_OVERRIDE= {
|
||||
# "typeclass": "evennia.contrib.grid.xyzgrid.tests.TestXyzExit",
|
||||
# },
|
||||
# XYZROOM_PROTOTYPE_OVERRIDE= {
|
||||
# "typeclass": "evennia.contrib.grid.xyzgrid.tests.TestXyzRoom",
|
||||
# }
|
||||
# )
|
||||
class TestCallbacks(BaseEvenniaTest):
|
||||
@override_settings(
|
||||
XYZEXIT_PROTOTYPE_OVERRIDE={
|
||||
"typeclass": "evennia.contrib.grid.xyzgrid.tests.TestXyzExit",
|
||||
},
|
||||
XYZROOM_PROTOTYPE_OVERRIDE={
|
||||
"typeclass": "evennia.contrib.grid.xyzgrid.tests.TestXyzRoom",
|
||||
})
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
from evennia.prototypes import prototypes as protlib
|
||||
for prototype_key in ('xyz_room', 'xyz_exit', 'xyzroom', 'xyzexit'):
|
||||
proto = protlib.search_prototype(
|
||||
prototype_key,
|
||||
# require_single=True,
|
||||
# no_db=True
|
||||
)
|
||||
print(prototype_key, 'found?', proto)
|
||||
|
||||
self.map_data = {
|
||||
"map": """
|
||||
|
||||
+ 0 1
|
||||
|
||||
0 #-#
|
||||
|
||||
+ 0 1
|
||||
|
||||
""",
|
||||
"zcoord": "map1",
|
||||
"prototypes": {
|
||||
("*", "*"): {
|
||||
"key": "room",
|
||||
"desc": "A room.",
|
||||
"prototype_parent": "xyz_room",
|
||||
},
|
||||
("*", "*", "*"): {
|
||||
"desc": "A passage.",
|
||||
"prototype_parent": "xyz_exit",
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"map_visual_range": 1,
|
||||
"map_mode": "scan",
|
||||
}
|
||||
}
|
||||
self.grid, err = xyzgrid.XYZGrid.create("testgrid")
|
||||
|
||||
def _log(msg):
|
||||
print(msg)
|
||||
self.grid.log = _log
|
||||
|
||||
self.grid.add_maps(self.map_data)
|
||||
|
||||
def tearDown(self):
|
||||
self.grid.delete()
|
||||
|
||||
def test_dummy(self):
|
||||
self.grid.spawn()
|
||||
|
|
|
|||
|
|
@ -302,6 +302,7 @@ class MapNode:
|
|||
to their destinations.
|
||||
|
||||
"""
|
||||
# breakpoint()
|
||||
global NodeTypeclass
|
||||
if not NodeTypeclass:
|
||||
from .xyzroom import XYZRoom as NodeTypeclass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue