-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_verse_parsing.py
More file actions
153 lines (143 loc) · 3.15 KB
/
test_verse_parsing.py
File metadata and controls
153 lines (143 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
from verse_parsing import to_range
refs = [
"GEN 1:1",
"GEN 1:2",
"GEN 1:3",
"GEN 1:4",
"GEN 2:1",
"GEN 2:2",
"GEN 2:3",
"GEN 3:1",
"GEN 3:2",
"GEN 3:3",
"EXD 1:1",
"EXD 1:2",
"EXD 1:3",
"EXD 2:1",
"EXD 2:2",
"EXD 2:3",
]
def test_single():
assert to_range(["GEN 1:1"], refs) == "GEN 1:1"
def test_single_range():
assert to_range(["GEN 1:1","GEN 1:2", "GEN 1:3"], refs ) == "GEN 1:1-3"
def test_chapter_range():
assert to_range( ["GEN 1:1",
"GEN 1:2",
"GEN 1:3",
"GEN 1:4",
"GEN 2:1",
"GEN 2:2",
"GEN 2:3"], refs ) == "GEN 1-2"
def test_verse_list():
assert to_range(["GEN 1:1", "GEN 1:3"], refs) == "GEN 1:1,3"
def test_chapter_list():
assert to_range( [
"GEN 1:1",
"GEN 1:2",
"GEN 1:3",
"GEN 1:4",
"GEN 3:1",
"GEN 3:2",
"GEN 3:3" ], refs ) == "GEN 1,3"
def test_whole_book():
assert to_range( [
"GEN 1:1",
"GEN 1:2",
"GEN 1:3",
"GEN 1:4",
"GEN 2:1",
"GEN 2:2",
"GEN 2:3",
"GEN 3:1",
"GEN 3:2",
"GEN 3:3", ], refs ) == "GEN"
def test_book_range():
test_refs = [
"GEN 1:1",
"GEN 1:2",
"GEN 1:3",
"GEN 1:4",
"GEN 2:1",
"GEN 2:2",
"GEN 2:3",
"GEN 3:1",
"GEN 3:2",
"GEN 3:3",
"EXD 1:1",
"EXD 1:2",
"EXD 1:3",
"EXD 2:1",
"EXD 2:2",
"EXD 2:3",
]
assert to_range( test_refs, refs ) == "GEN-EXD"
def test_range_and_list():
test_refs = [
"GEN 1:1",
"GEN 1:3",
"GEN 1:4",
]
assert to_range( test_refs, refs ) == "GEN 1:1,3-4"
def test_not_hide_verse_when_start_showing_verse():
"""
If the previous range shows a verse, you can't hide the verse
otherwise it looks like a verse range.
"""
test_refs = [
"GEN 1:2",
"GEN 1:3",
"GEN 1:4",
"GEN 2:1",
"GEN 2:2",
"GEN 2:3",
"GEN 3:1",
"GEN 3:2",
"GEN 3:3",
]
assert to_range( test_refs, refs ) == "GEN 1:2-3:3"
def test_not_hide_chapter_when_next_verse_is_next_chapter():
test_refs = [
"GEN 1:1",
#"GEN 1:2",
"GEN 1:3",
"GEN 1:4",
"GEN 2:1",
# "GEN 2:2",
# "GEN 2:3",
# "GEN 3:1",
# "GEN 3:2",
# "GEN 3:3",
# "EXD 1:1",
# "EXD 1:2",
# "EXD 1:3",
# "EXD 2:1",
# "EXD 2:2",
# "EXD 2:3",
]
assert to_range( test_refs, refs ) == "GEN 1:1,1:3-2:1"
def test_have_whole_start_chapter_but_not_end_chapter():
"""
If you have the whole starting chapter but not the whole ending chapter,
you can't hide the verse on the end of the range because you don't have all
the verses.
"""
test_refs = [
"GEN 1:1",
"GEN 1:2",
"GEN 1:3",
"GEN 1:4",
"GEN 2:1",
# "GEN 2:2",
"GEN 2:3",
"GEN 3:1",
"GEN 3:2",
"GEN 3:3",
"EXD 1:1",
"EXD 1:2",
"EXD 1:3",
"EXD 2:1",
"EXD 2:2",
"EXD 2:3",
]
assert to_range( test_refs, refs ) == "GEN 1-2:1,3-EXD"