Skip to content

Commit ce7a9ef

Browse files
committed
port commit 707d7dc, ScriptureRef test coverage
1 parent 953f203 commit ce7a9ef

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

machine/corpora/scripture_ref.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import List, Optional
55

66
from ..scripture.constants import ENGLISH_VERSIFICATION
7-
from ..scripture.verse_ref import VerseRef, Versification, are_overlapping_verse_ranges
7+
from ..scripture.verse_ref import VerseRef, Versification
88
from ..utils.comparable import Comparable
99
from .scripture_element import ScriptureElement
1010

@@ -86,11 +86,6 @@ def change_versification(self, versification: Versification) -> ScriptureRef:
8686
vr.change_versification(versification)
8787
return ScriptureRef(vr, self.path)
8888

89-
def overlaps(self, other: ScriptureRef) -> bool:
90-
if not are_overlapping_verse_ranges(self.verse_ref, other.verse_ref):
91-
return False
92-
return self.path == other.path
93-
9489
def compare_to(self, other: object, compare_segments: bool = True, strict: bool = True):
9590
if not isinstance(other, ScriptureRef):
9691
raise TypeError("other is not a ScriptureRef object.")

tests/corpora/test_scripture_ref.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,49 @@
1+
from pytest import raises
2+
13
from machine.corpora import ScriptureRef
24

35

46
def test_compare_to_strict():
57
assert compare_to_strict("MAT 1:1", "MAT 1:2") == -1, "VerseLessThan"
68
assert compare_to_strict("MAT 1:1", "MAT 1:1") == 0, "VerseEqualTo"
79
assert compare_to_strict("MAT 1:2", "MAT 1:1") == 1, "VerseGreaterThan"
10+
assert compare_to_strict("MAT 1:1-3", "MAT 1:1") == 1, "MultiVerseExtensionGreaterThan"
11+
assert compare_to_strict("MAT 1:1", "MAT 1:1-3") == -1, "MultiVerseExtensionLessThan"
12+
assert compare_to_strict("MAT 1:1-3", "MAT 1:2") == -1, "MultiVerseStartLessThan"
13+
assert compare_to_strict("MAT 1:2", "MAT 1:1-3") == 1, "MultiVerseEndGreaterThan"
814
assert compare_to_strict("MAT 1:0/1:p", "MAT 1:0/2:p") == -1, "NonVerseLessThan"
915
assert compare_to_strict("MAT 1:0/1:p", "MAT 1:0/1:p") == 0, "NonVerseEqualTo"
1016
assert compare_to_strict("MAT 1:0/2:p", "MAT 1:0/1:p") == 1, "NonVerseGreaterThan"
1117
assert compare_to_strict("MAT 1:0/1:esb", "MAT 1:0/1:esb/1:p") == -1, "NonVerseParentChild"
18+
assert compare_to_strict("MAT 1:0/2:esb", "MAT 1:0/1:esb/1:p") == 1, "NonVerseParentOtherChild"
1219

1320

1421
def test_compare_to_relaxed():
1522
assert compare_to_relaxed("MAT 1:1", "MAT 1:2") == -1, "VerseLessThan"
1623
assert compare_to_relaxed("MAT 1:1", "MAT 1:1") == 0, "VerseEqualTo"
1724
assert compare_to_relaxed("MAT 1:2", "MAT 1:1") == 1, "VerseGreaterThan"
1825
assert compare_to_relaxed("MAT 1:0/1:p", "MAT 1:0/2:p") == 0, "NonVerseSameMarkerDifferentPosition"
19-
assert compare_to_relaxed("MAT 1:0/2:esb", "MAT 1:0/1:esb/1:p") == -1, "NonVerseParentChild"
26+
assert compare_to_relaxed("MAT 1:0/1:esb", "MAT 1:0/1:esb/1:p") == -1, "NonVerseParentChild"
27+
assert compare_to_relaxed("MAT 1:0/2:esb", "MAT 1:0/1:esb/1:p") == -1, "NonVerseParentOtherChild"
28+
29+
30+
def test_is_equal_to():
31+
ref1 = ScriptureRef.parse("MAT 1:1/1:p")
32+
ref1dup = ScriptureRef.parse("MAT 1:1/1:p")
33+
ref2 = ScriptureRef.parse("MAT 1:2/1:p")
34+
obj1 = "A different type"
35+
36+
assert ref1 == ref1dup
37+
assert ref1 != ref2
38+
assert ref1 != obj1
39+
40+
41+
def test_is_equal_to_throws_argument_exception():
42+
ref1 = ScriptureRef.parse("MAT 1:1/1:p")
43+
obj1 = "A different type"
44+
45+
with raises(TypeError):
46+
ref1.compare_to(obj1)
2047

2148

2249
def compare_to_strict(ref1_str, ref2_str):

0 commit comments

Comments
 (0)