3
This module contains tests for the examplegame.furniture module.
6
from twisted.trial.unittest import TestCase
8
from imaginary.test.commandutils import CommandTestCaseMixin, E, createLocation
10
from imaginary.objects import Thing, Exit
11
from examplegame.furniture import Chair
13
class SitAndStandTests(CommandTestCaseMixin, TestCase):
15
Tests for the 'sit' and 'stand' actions.
20
Create a room, with a dude in it, and a chair he can sit in.
22
CommandTestCaseMixin.setUp(self)
23
self.chairThing = Thing(store=self.store, name=u"chair")
24
self.chairThing.moveTo(self.location)
25
self.chair = Chair.createFor(self.chairThing)
28
def test_sitDown(self):
30
Sitting in a chair should move your location to that chair.
32
self.assertCommandOutput(
34
["You sit in the chair."],
35
["Test Player sits in the chair."])
36
self.assertEquals(self.player.location, self.chair.thing)
39
def test_standWhenStanding(self):
41
You can't stand up - you're already standing up.
43
self.assertCommandOutput(
45
["You're already standing."])
48
def test_standWhenSitting(self):
50
If a player stands up when sitting in a chair, they should be seen to
51
stand up, and they should be placed back into the room where the chair
55
self.assertCommandOutput(
58
["Test Player stands up."])
59
self.assertEquals(self.player.location, self.location)
62
def test_takeWhenSitting(self):
64
When a player is seated, they should still be able to take objects on
65
the floor around them.
68
self.ball = Thing(store=self.store, name=u'ball')
69
self.ball.moveTo(self.location)
70
self.assertCommandOutput(
73
["Test Player takes a ball."])
76
def test_moveWhenSitting(self):
78
A player who is sitting shouldn't be able to move without standing up
82
otherRoom = createLocation(self.store, u"elsewhere", None).thing
83
Exit.link(self.location, otherRoom, u'north')
84
self.assertCommandOutput(
86
["You can't do that while sitting down."])
87
self.assertCommandOutput(
89
["You can't go that way."])
92
def test_lookWhenSitting(self):
94
Looking around when sitting should display the description of the room.
97
self.assertCommandOutput(
99
# I'd like to add ', in the chair' to this test, but there's
100
# currently no way to modify the name of the object being looked
102
[E("[ Test Location ]"),
103
"Location for testing.",
104
"Here, you see Observer Player and a chair."])