Skip to content

Commit

Permalink
added crumbling wall test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiogaplanet committed May 15, 2022
1 parent bd6f930 commit 1a6a6c1
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
7 changes: 5 additions & 2 deletions typeclasses/exits/crumblingwall.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
# position of the roots.


from evennia import CmdSet
import random

from evennia import CmdSet, DefaultExit
from evennia.utils import delay, search

from commands.command import Command
from typeclasses.object import Object
from typeclasses.base import Object


class CmdShiftRoot(Command):
Expand Down
60 changes: 60 additions & 0 deletions world/tests/test_exits.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Test typeclasses/exits.


from mock import patch

from evennia import create_object
from evennia.commands.default.tests import CommandTest
from evennia.utils.test_resources import mockdelay, mockdeferLater

from twisted.trial.unittest import TestCase as TwistedTestCase
from twisted.internet.base import DelayedCall

from typeclasses.exits import crumblingwall as drucrumblingwall


DelayedCall.debug = True


class TestExits(TwistedTestCase, CommandTest):
@patch("typeclasses.exits.crumblingwall.delay", mockdelay)
@patch("evennia.scripts.taskhandler.deferLater", mockdeferLater)
def test_crumblingwall(self):
wall = create_object(drucrumblingwall.CrumblingWall, key="wall", location=self.room1)
wall.db.destination = self.room2.dbref
self.assertFalse(wall.db.button_exposed)
self.assertFalse(wall.db.exit_open)
wall.db.root_pos = {"yellow": 0, "green": 0, "red": 0, "blue": 0}
self.call(
drucrumblingwall.CmdShiftRoot(),
"blue root right",
"You shove the root adorned with small blue flowers to the right.",
obj=wall,
)
self.call(
drucrumblingwall.CmdShiftRoot(),
"red root left",
"You shift the reddish root to the left.",
obj=wall,
)
self.call(
drucrumblingwall.CmdShiftRoot(),
"yellow root down",
"You shove the root adorned with small yellow flowers downwards.",
obj=wall,
)
self.call(
drucrumblingwall.CmdShiftRoot(),
"green root up",
"You shift the weedy green root upwards.|Holding aside the root you think you notice something behind it ...",
obj=wall,
)
self.call(
drucrumblingwall.CmdPressButton(),
"",
"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
self.assertFalse(wall.db.button_exposed)
self.assertFalse(wall.db.exit_open)

0 comments on commit 1a6a6c1

Please sign in to comment.