exploration.tests._test_journal

  • Authors: Peter Mawhorter
  • Consulted:
  • Date: 2022-4-4
  • Purpose: Tests for the journal parsing functionality.
  1"""
  2- Authors: Peter Mawhorter
  3- Consulted:
  4- Date: 2022-4-4
  5- Purpose: Tests for the journal parsing functionality.
  6"""
  7
  8import json
  9
 10from .. import journal
 11
 12
 13def test_simpleConversion():
 14    """
 15    A simple test of *simple* journal conversion.
 16    """
 17    simple = journal.convertJournal("""\
 18S First_Room
 19x Exit Second_Room Entrance
 20tt tag
 21
 22o Onwards
 23E END
 24""")
 25    assert len(simple) == 3
 26
 27    finalGraph = simple.currentGraph()
 28
 29    assert list(finalGraph["First_Room"]) == ["Second_Room"]
 30    assert list(finalGraph["Second_Room"]) == [
 31        "First_Room",
 32        "Onwards",
 33        "_e:END"
 34    ]
 35    assert list(finalGraph.nodes) == [
 36        "First_Room",
 37        "Second_Room",
 38        "_u:1",
 39        "_e:END"
 40    ]
 41    assert len(finalGraph) == 4
 42    assert json.dumps(
 43        finalGraph.textMapObj(),
 44        indent=4
 45    ) == """\
 46{
 47    "First_Room::Exit": {
 48        "Second_Room::Entrance": "First_Room",
 49        "Second_Room::Onwards": {},
 50        "Second_Room::_e:END": {}
 51    }
 52}"""
 53
 54
 55def test_basicConversion():
 56    """
 57    A very simple test of journal conversion.
 58    """
 59    simple, continueFrom = journal.convertJournal("""\
 60[First_Room]
 61> Exit {tag}
 62
 63[Second_Room]
 64< Entrance
 65$$ END
 66""")
 67    assert len(simple) == 3
 68    assert continueFrom is None
 69
 70    finalGraph = simple.currentGraph()
 71
 72    assert list(finalGraph["First_Room"]) == ["Second_Room"]
 73    assert list(finalGraph["Second_Room"]) == ["First_Room", "_e:END"]
 74    assert list(finalGraph.nodes) == ["First_Room", "Second_Room", "_e:END"]
 75    assert len(finalGraph) == 3
 76    assert json.dumps(
 77        finalGraph.textMapObj(),
 78        indent=4
 79    ) == """\
 80{
 81    "First_Room::Exit": {
 82        "Second_Room::Entrance": "First_Room",
 83        "Second_Room::_e:END": {}
 84    }
 85}"""
 86
 87
 88def test_startOfCotM():
 89    """
 90    A test for converting part of a journal from Castlevania: Circle of
 91    the Moon. This journal covers an experienced re-playthrough up to
 92    the first boss (Cerberus) and boss reward (double-jump).
 93    """
 94    expl, continueFrom = journal.convertJournal("""\
 95[Confrontation_Site]
 96< Top_Left
 97> Bottom {forced}
 98
 99[Rubble_Tower_Base]
100< Top
101x< Crack (short_and_high)
102# -Skeleton_Bomber-
103. <Salamander>
104" Literally first enemy I touched!
105> Bottom_Right
106
107[Catacombs_Entrance]
108< Top_Left
109x< up (height)
110? mid
111> First_Right
112
113[Catacombs_Treasury]
114< Left
115x box (heavy)
116> Left
117
118[Catacombs_Entrance]
119< First_Right
120- mid
121? lower
122. <Mercury>
123" Bone head along the way
124>< Mid_Left [save]
125- lower
126. <dagger>
127> Bot_Left
128
129[Blockwall_Cave]
130< Right
131x< jump (height)
132> Right
133
134[Catacombs_Entrance]
135< Bot_Left
136> Bot_Right
137
138[Green_Grates]
139< Left
140# -Earth_Demon-
141x< jump (distance)
142. <dash_boots> (/distance)
143- jump
144- climb
145? below_right
146> Upper_Right
147
148[Catacombs_Treasury_2]
149< Left
150x block (crumble)
151> Left
152
153[Green_Grates]
154< Upper_Right
155- below_right
156> Lower_Right
157
158[Zombie_Corridor]
159< Left
160# -Poison_Worm- + - Zombie- + -Skeleton-
161> Right
162
163[Pinkstone_Tower]
164< Left_Mid
165? down
166? up
167? across
168>< Left_Crumble [. <mp>]
169@ down
170> Bottom_Right
171
172[Green_Shaft_Cave]
173< Left
174# -Earth_Demon-
175. <ht>
176x< up (tall_and_narrow)
177> Left
178
179[Pinkstone_Tower]
180< Bottom_Right
181- across
182> Mid_Right
183
184[Squeeze_Under]
185< Right
186. <hp>
187> Right
188
189[Pinkstone_Tower]
190< Mid_Right
191- up
192? up2
193> Upper_Left
194
195[Pinkstone_Connector_Crack]
196< Right
197x< crack (short_and_high)
198> Right
199
200[Pinkstone_Tower]
201< Upper_Left
202- up2
203? across2
204? up3
205>< Top_Left [. <mp>]
206- up3
207? Top
208- across2
209>< Top_Right [save]
210> Top
211
212[FlameMouth_Chamber]
213< Bottom
214? right
215> Left
216
217[Pinkstone_Tower_2]
218< Entrance_Crack
219. <axe>
220? Right
221>< Left [. <hp>]
222> Right
223
224[Pinkstone_Connector_Crack]
225< Left
226-> crack
227> Right
228
229[Pinkstone_Tower]
230< Upper_Left
231> Top
232
233[FlameMouth_Chamber]
234< Bottom
235- right
236? up
237- right2
238. <mp>
239x< ledge (height)
240- up
241> Top_Left
242
243[Muddy_Pinkstone]
244< Right
245? down
246>< Top_Left [save]
247- down
248> Bottom_Left
249
250[Greenstone_Double_Shaft]
251< Top_Right
252# -Gremlin-
253>< Mid_Right [. <ht>]
254? up
255> Bottom_Left
256
257[Mummies_Hallway]
258< Right
259# Mummy
260. <holy water>
261x< ledge (height)
262> Right
263
264[Greenstone_Double_Shaft]
265< Bottom_Left
266- up
267?b Top_Left
268> Mid_Left
269
270[Hopper_Treasury]
271< Right
272# -Hopper-
273. <mp>
274> Right
275
276[Greenstone_Double_Shaft]
277< Mid_Left
278> Top_Left {boss}
279
280[Cerberus]
281< Right {boss}
282# -Cerberus-
283>< Left [. <double> (/height|distance)]
284> Right
285""")
286    assert len(expl) == 3
287    assert continueFrom == ("Cerberus", "Right")
288
289    firstGraph, firstPos, firstState, firstChoice = expl.situationAtStep(0)
290    fifthGraph, fifthPos, fifthState, fifthChoice = expl.situationAtStep(5)
291    finalGraph, finalPos, finalState, finalChoice = expl.currentSituation()
292
293    assert len(firstGraph) == 1
294    assert firstPos == "Confrontation_Site"
295
296    assert len(fifthGraph) == 10
297    assert fifthPos == "Catacombs_Entrance"
298
299    assert len(finalGraph) == 100
300    assert finalPos == "Cerberus"
301
302# TODO: Specific case coverage tests...
def test_simpleConversion():
14def test_simpleConversion():
15    """
16    A simple test of *simple* journal conversion.
17    """
18    simple = journal.convertJournal("""\
19S First_Room
20x Exit Second_Room Entrance
21tt tag
22
23o Onwards
24E END
25""")
26    assert len(simple) == 3
27
28    finalGraph = simple.currentGraph()
29
30    assert list(finalGraph["First_Room"]) == ["Second_Room"]
31    assert list(finalGraph["Second_Room"]) == [
32        "First_Room",
33        "Onwards",
34        "_e:END"
35    ]
36    assert list(finalGraph.nodes) == [
37        "First_Room",
38        "Second_Room",
39        "_u:1",
40        "_e:END"
41    ]
42    assert len(finalGraph) == 4
43    assert json.dumps(
44        finalGraph.textMapObj(),
45        indent=4
46    ) == """\
47{
48    "First_Room::Exit": {
49        "Second_Room::Entrance": "First_Room",
50        "Second_Room::Onwards": {},
51        "Second_Room::_e:END": {}
52    }
53}"""

A simple test of simple journal conversion.

def test_basicConversion():
56def test_basicConversion():
57    """
58    A very simple test of journal conversion.
59    """
60    simple, continueFrom = journal.convertJournal("""\
61[First_Room]
62> Exit {tag}
63
64[Second_Room]
65< Entrance
66$$ END
67""")
68    assert len(simple) == 3
69    assert continueFrom is None
70
71    finalGraph = simple.currentGraph()
72
73    assert list(finalGraph["First_Room"]) == ["Second_Room"]
74    assert list(finalGraph["Second_Room"]) == ["First_Room", "_e:END"]
75    assert list(finalGraph.nodes) == ["First_Room", "Second_Room", "_e:END"]
76    assert len(finalGraph) == 3
77    assert json.dumps(
78        finalGraph.textMapObj(),
79        indent=4
80    ) == """\
81{
82    "First_Room::Exit": {
83        "Second_Room::Entrance": "First_Room",
84        "Second_Room::_e:END": {}
85    }
86}"""

A very simple test of journal conversion.

def test_startOfCotM():
 89def test_startOfCotM():
 90    """
 91    A test for converting part of a journal from Castlevania: Circle of
 92    the Moon. This journal covers an experienced re-playthrough up to
 93    the first boss (Cerberus) and boss reward (double-jump).
 94    """
 95    expl, continueFrom = journal.convertJournal("""\
 96[Confrontation_Site]
 97< Top_Left
 98> Bottom {forced}
 99
100[Rubble_Tower_Base]
101< Top
102x< Crack (short_and_high)
103# -Skeleton_Bomber-
104. <Salamander>
105" Literally first enemy I touched!
106> Bottom_Right
107
108[Catacombs_Entrance]
109< Top_Left
110x< up (height)
111? mid
112> First_Right
113
114[Catacombs_Treasury]
115< Left
116x box (heavy)
117> Left
118
119[Catacombs_Entrance]
120< First_Right
121- mid
122? lower
123. <Mercury>
124" Bone head along the way
125>< Mid_Left [save]
126- lower
127. <dagger>
128> Bot_Left
129
130[Blockwall_Cave]
131< Right
132x< jump (height)
133> Right
134
135[Catacombs_Entrance]
136< Bot_Left
137> Bot_Right
138
139[Green_Grates]
140< Left
141# -Earth_Demon-
142x< jump (distance)
143. <dash_boots> (/distance)
144- jump
145- climb
146? below_right
147> Upper_Right
148
149[Catacombs_Treasury_2]
150< Left
151x block (crumble)
152> Left
153
154[Green_Grates]
155< Upper_Right
156- below_right
157> Lower_Right
158
159[Zombie_Corridor]
160< Left
161# -Poison_Worm- + - Zombie- + -Skeleton-
162> Right
163
164[Pinkstone_Tower]
165< Left_Mid
166? down
167? up
168? across
169>< Left_Crumble [. <mp>]
170@ down
171> Bottom_Right
172
173[Green_Shaft_Cave]
174< Left
175# -Earth_Demon-
176. <ht>
177x< up (tall_and_narrow)
178> Left
179
180[Pinkstone_Tower]
181< Bottom_Right
182- across
183> Mid_Right
184
185[Squeeze_Under]
186< Right
187. <hp>
188> Right
189
190[Pinkstone_Tower]
191< Mid_Right
192- up
193? up2
194> Upper_Left
195
196[Pinkstone_Connector_Crack]
197< Right
198x< crack (short_and_high)
199> Right
200
201[Pinkstone_Tower]
202< Upper_Left
203- up2
204? across2
205? up3
206>< Top_Left [. <mp>]
207- up3
208? Top
209- across2
210>< Top_Right [save]
211> Top
212
213[FlameMouth_Chamber]
214< Bottom
215? right
216> Left
217
218[Pinkstone_Tower_2]
219< Entrance_Crack
220. <axe>
221? Right
222>< Left [. <hp>]
223> Right
224
225[Pinkstone_Connector_Crack]
226< Left
227-> crack
228> Right
229
230[Pinkstone_Tower]
231< Upper_Left
232> Top
233
234[FlameMouth_Chamber]
235< Bottom
236- right
237? up
238- right2
239. <mp>
240x< ledge (height)
241- up
242> Top_Left
243
244[Muddy_Pinkstone]
245< Right
246? down
247>< Top_Left [save]
248- down
249> Bottom_Left
250
251[Greenstone_Double_Shaft]
252< Top_Right
253# -Gremlin-
254>< Mid_Right [. <ht>]
255? up
256> Bottom_Left
257
258[Mummies_Hallway]
259< Right
260# Mummy
261. <holy water>
262x< ledge (height)
263> Right
264
265[Greenstone_Double_Shaft]
266< Bottom_Left
267- up
268?b Top_Left
269> Mid_Left
270
271[Hopper_Treasury]
272< Right
273# -Hopper-
274. <mp>
275> Right
276
277[Greenstone_Double_Shaft]
278< Mid_Left
279> Top_Left {boss}
280
281[Cerberus]
282< Right {boss}
283# -Cerberus-
284>< Left [. <double> (/height|distance)]
285> Right
286""")
287    assert len(expl) == 3
288    assert continueFrom == ("Cerberus", "Right")
289
290    firstGraph, firstPos, firstState, firstChoice = expl.situationAtStep(0)
291    fifthGraph, fifthPos, fifthState, fifthChoice = expl.situationAtStep(5)
292    finalGraph, finalPos, finalState, finalChoice = expl.currentSituation()
293
294    assert len(firstGraph) == 1
295    assert firstPos == "Confrontation_Site"
296
297    assert len(fifthGraph) == 10
298    assert fifthPos == "Catacombs_Entrance"
299
300    assert len(finalGraph) == 100
301    assert finalPos == "Cerberus"

A test for converting part of a journal from Castlevania: Circle of the Moon. This journal covers an experienced re-playthrough up to the first boss (Cerberus) and boss reward (double-jump).