Skip to content

Commit 070aa42

Browse files
committed
Update jump test to work with YS2.
1 parent 3c13d0b commit 070aa42

5 files changed

Lines changed: 75 additions & 17 deletions

File tree

examples/yarn2/jump-metadata.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
id,node,lineNumber,tags

examples/yarn2/jump.csv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
id,text,file,node,lineNumber
2+
line:/Users/sweaver/Git/YarnRunner-Python/examples/yarn2/jump.yarn-Start-0,This is a test of the jump functionality.,/Users/sweaver/Git/YarnRunner-Python/examples/yarn2/jump.yarn,Start,3
3+
line:/Users/sweaver/Git/YarnRunner-Python/examples/yarn2/jump.yarn-Start-1,Begin Jump,/Users/sweaver/Git/YarnRunner-Python/examples/yarn2/jump.yarn,Start,5
4+
line:/Users/sweaver/Git/YarnRunner-Python/examples/yarn2/jump.yarn-begin_jump-2,Some text is output.,/Users/sweaver/Git/YarnRunner-Python/examples/yarn2/jump.yarn,begin_jump,11
5+
line:/Users/sweaver/Git/YarnRunner-Python/examples/yarn2/jump.yarn-jump_complete-3,The jump is now complete.,/Users/sweaver/Git/YarnRunner-Python/examples/yarn2/jump.yarn,jump_complete,22

examples/yarn2/jump.yarn

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
title: Start
2+
---
3+
This is a test of the jump functionality.
4+
5+
-> Begin Jump
6+
<<jump begin_jump>>
7+
===
8+
title: begin_jump
9+
---
10+
11+
Some text is output.
12+
13+
<<jump jump_stage_2>>
14+
15+
===
16+
title: jump_stage_2
17+
---
18+
<<jump jump_complete>>
19+
===
20+
title: jump_complete
21+
---
22+
The jump is now complete.
23+
===

examples/yarn2/jump.yarnc

705 Bytes
Binary file not shown.

tests/test_jump.py

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,63 @@
11
import os
22
from .context import YarnRunner
33

4-
compiled_yarn_f = open(os.path.join(os.path.dirname(
4+
compiled_yarn_f1 = open(os.path.join(os.path.dirname(
55
__file__), '../examples/yarn1/jump.yarnc'), 'rb')
6-
names_csv_f = open(os.path.join(os.path.dirname(
6+
names_csv_f1 = open(os.path.join(os.path.dirname(
77
__file__), '../examples/yarn1/jump.csv'), 'r')
8+
compiled_yarn_f2 = open(os.path.join(os.path.dirname(
9+
__file__), '../examples/yarn2/jump.yarnc'), 'rb')
10+
names_csv_f2 = open(os.path.join(os.path.dirname(
11+
__file__), '../examples/yarn2/jump.csv'), 'r')
812

9-
runner = YarnRunner(compiled_yarn_f, names_csv_f)
13+
runner1 = YarnRunner(compiled_yarn_f1, names_csv_f1)
14+
runner2 = YarnRunner(compiled_yarn_f2, names_csv_f2)
1015

1116

12-
def test_start_node_text():
13-
assert "This is a test of the jump functionality." == runner.get_line()
14-
assert not runner.has_line()
15-
assert not runner.finished
17+
def test_start_node_text1():
18+
assert "This is a test of the jump functionality." == runner1.get_line()
19+
assert not runner1.has_line()
20+
assert not runner1.finished
1621

1722

18-
def test_start_node_choices():
19-
choices = runner.get_choices()
23+
def test_start_node_choices1():
24+
choices = runner1.get_choices()
2025

2126
assert len(choices) == 1
2227
assert choices[0]["choice"] == "begin_jump"
2328
assert choices[0]["text"] == "Begin Jump"
2429

2530

26-
def test_jumps():
27-
runner.choose(0)
31+
def test_jumps1():
32+
runner1.choose(0)
2833

29-
assert "Some text is output." == runner.get_line()
30-
assert runner.has_line()
31-
assert "The jump is now complete." == runner.get_line()
32-
assert not runner.has_line()
33-
assert runner.finished
34-
assert runner.current_node == 'jump_complete'
34+
assert "Some text is output." == runner1.get_line()
35+
assert runner1.has_line()
36+
assert "The jump is now complete." == runner1.get_line()
37+
assert not runner1.has_line()
38+
assert runner1.finished
39+
assert runner1.current_node == 'jump_complete'
40+
41+
42+
def test_start_node_text2():
43+
assert "This is a test of the jump functionality." == runner2.get_line()
44+
assert not runner2.has_line()
45+
assert not runner2.finished
46+
47+
48+
def test_start_node_choices2():
49+
choices = runner2.get_choices()
50+
51+
assert len(choices) == 1
52+
assert choices[0]["text"] == "Begin Jump"
53+
54+
55+
def test_jumps2():
56+
runner2.choose(0)
57+
58+
assert "Some text is output." == runner2.get_line()
59+
assert runner2.has_line()
60+
assert "The jump is now complete." == runner2.get_line()
61+
assert not runner2.has_line()
62+
assert runner2.finished
63+
assert runner2.current_node == 'jump_complete'

0 commit comments

Comments
 (0)