annotate gamelib/tests/test_walkthrough.py @ 252:dfc89bc64fdb

Start of walkthrough "unit test" and associated fixes and tweaks.
author Jeremy Thurgood <firxen@gmail.com>
date Fri, 27 Aug 2010 16:45:47 +0200
parents
children ca0c2875ad8f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
252
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
1 import game_logic_utils
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
2
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
3
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
4 class TestWalkthrough(game_logic_utils.GameLogicTestCase):
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
5
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
6 CURRENT_SCENE = 'cryo'
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
7
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
8 def close_detail(self):
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
9 self.state.set_current_detail(None)
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
10
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
11 def move(self, source, target):
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
12 self.interact_thing(source+'.door')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
13 self.assert_current_scene('map')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
14 self.interact_thing('map.to'+target)
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
15 self.assert_current_scene(target)
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
16
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
17 def test_walkthrough(self):
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
18 """A complete game walkthrough.
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
19
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
20 This should only contain interacts and assertions."""
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
21
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
22 # TODO: Add flavour interactions, maybe?
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
23
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
24 # Partially open the door.
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
25 self.assert_game_data('door', 'shut', 'cryo.door')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
26 self.interact_thing('cryo.door')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
27 self.assert_game_data('door', 'ajar', 'cryo.door')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
28
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
29 # Get the titanium leg.
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
30 self.interact_thing('cryo.unit.1')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
31 self.assertEquals('cryo_detail', self.state.current_detail.name)
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
32 self.assert_detail_thing('cryo.titanium_leg')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
33 self.interact_thing('cryo.titanium_leg')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
34 self.assert_detail_thing('cryo.titanium_leg', False)
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
35 self.assert_inventory_item('titanium_leg')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
36 self.close_detail()
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
37
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
38 # Open the door the rest of the way.
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
39 self.interact_thing('cryo.door', 'titanium_leg')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
40 self.assert_game_data('door', 'open', 'cryo.door')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
41 self.assert_inventory_item('titanium_leg')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
42
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
43 # Go to the machine room.
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
44 self.move('cryo', 'machine')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
45
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
46 # Sharpen leg into machete.
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
47 self.interact_thing('machine.grinder', 'titanium_leg')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
48 self.assert_inventory_item('titanium_leg', False)
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
49 self.assert_inventory_item('machete')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
50
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
51 # Go to the mess.
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
52 self.move('machine', 'mess')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
53
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
54 # Clear the broccoli.
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
55 self.assert_game_data('status', 'blocked', 'mess.tubes')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
56 self.interact_thing('mess.tubes', 'machete')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
57 self.assert_game_data('status', 'broken', 'mess.tubes')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
58
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
59 # Get the cans.
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
60 self.assert_game_data('cans_available', 3, 'mess.cans')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
61 self.interact_thing('mess.cans')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
62 self.assert_inventory_item('full_can.0')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
63 self.interact_thing('mess.cans')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
64 self.assert_inventory_item('full_can.1')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
65 self.interact_thing('mess.cans')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
66 self.assert_inventory_item('full_can.2')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
67 self.assert_game_data('cans_available', 0, 'mess.cans')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
68
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
69
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
70 self.fail("Walkthrough incomplete.")
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
71