annotate gamelib/tests/test_walkthrough.py @ 254:ca0c2875ad8f

More test fixes.
author Jeremy Thurgood <firxen@gmail.com>
date Fri, 27 Aug 2010 17:35:15 +0200
parents dfc89bc64fdb
children bfb6c682b4fb
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
254
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
11 def move_to(self, target):
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
12 self.interact_thing(self.state.current_scene.name + '.door')
252
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')
254
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
14 self.interact_thing('map.to' + target)
252
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
254
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
17 def test_walkthrough_complete(self):
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
18 self.fail("Walkthrough incomplete.")
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
19
252
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
20 def test_walkthrough(self):
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
21 """A complete game walkthrough.
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
22
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
23 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
24
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
25 # TODO: Add flavour interactions, maybe?
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
26
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
27 # Partially open the door.
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
28 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
29 self.interact_thing('cryo.door')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
30 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
31
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
32 # Get the 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.unit.1')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
34 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
35 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
36 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
37 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
38 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
39 self.close_detail()
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
40
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
41 # 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
42 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
43 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
44 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
45
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
46 # Go to the mess.
254
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
47 self.move_to('mess')
252
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
48
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
49 # Get the cans.
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
50 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
51 self.interact_thing('mess.cans')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
52 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
53 self.interact_thing('mess.cans')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
54 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
55 self.interact_thing('mess.cans')
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
56 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
57 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
58
254
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
59 # Bash one of the cans.
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
60 self.assert_item_exists('dented_can.0', False)
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
61 self.interact_item('full_can.1', 'titanium_leg')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
62 self.assert_inventory_item('dented_can.0')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
63 self.assert_inventory_item('full_can.1', False)
252
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
64
254
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
65 # Go to the machine room.
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
66 self.move_to('machine')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
67
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
68 # Sharpen leg into machete.
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
69 self.interact_thing('machine.grinder', 'titanium_leg')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
70 self.assert_inventory_item('titanium_leg', False)
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
71 self.assert_inventory_item('machete')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
72
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
73 # Go to the cryo room.
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
74 self.move_to('cryo')
252
dfc89bc64fdb Start of walkthrough "unit test" and associated fixes and tweaks.
Jeremy Thurgood <firxen@gmail.com>
parents:
diff changeset
75
254
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
76 # Chop up some pipes.
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
77 self.assert_game_data('fixed', True, 'cryo.pipe.left')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
78 self.interact_thing('cryo.pipe.left', 'machete')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
79 self.assert_game_data('fixed', False, 'cryo.pipe.left')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
80 self.assert_inventory_item('cryo_pipe.0')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
81
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
82 self.assert_game_data('fixed', True, 'cryo.pipe.right')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
83 self.interact_thing('cryo.pipe.right', 'machete')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
84 self.assert_game_data('fixed', False, 'cryo.pipe.right')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
85 self.assert_inventory_item('cryo_pipe.1')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
86
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
87 # Go to the mess.
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
88 self.move_to('mess')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
89
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
90 # Clear the broccoli.
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
91 self.assert_game_data('status', 'blocked', 'mess.tubes')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
92 self.interact_thing('mess.tubes', 'machete')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
93 self.assert_game_data('status', 'broken', 'mess.tubes')
ca0c2875ad8f More test fixes.
Jeremy Thurgood <firxen@gmail.com>
parents: 252
diff changeset
94