Skip to content

Commit

Permalink
add unit test, fix comment typo
Browse files Browse the repository at this point in the history
  • Loading branch information
mshannon-sil committed Nov 10, 2023
1 parent 3b60347 commit b857823
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion machine/corpora/usfm_file_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def _get_id(filename: StrPath, encoding: str) -> str:
if index != -1:
id = id[:index]
return id.strip().upper()
raise RuntimeError("The USFM does not contain and 'id' marker.")
raise RuntimeError("The USFM does not contain an 'id' marker.")
2 changes: 1 addition & 1 deletion machine/corpora/usfm_zip_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def _get_id(archive_filename: StrPath, path: str, encoding: str) -> str:
if index != -1:
id = id[:index]
return id.strip().upper()
raise RuntimeError("The USFM does not contain and 'id' marker.")
raise RuntimeError("The USFM does not contain an 'id' marker.")
16 changes: 16 additions & 0 deletions tests/corpora/test_usfm_file_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,19 @@ def test_get_rows_include_markers() -> None:

assert verse_ref(rows[16]).exact_equals(VerseRef.from_string("MAT 2:10", corpus.versification))
assert rows[16].text == "\\tc3-4 Chapter 2 verse 10"


def test_usfm_file_text_corpus_lowercase_usfm_id() -> None:
corpus = UsfmFileTextCorpus(USFM_TEST_PROJECT_PATH)

text = corpus.get_text("LEV")
assert text is not None
rows = list(text)

assert len(rows) == 2

assert verse_ref(rows[0]).exact_equals(VerseRef.from_string("LEV 14:55", corpus.versification))
assert rows[0].text == "Chapter fourteen, verse fifty-five. Segment b."

assert verse_ref(rows[1]).exact_equals(VerseRef.from_string("LEV 14:56", corpus.versification))
assert rows[1].text == "Chapter fourteen, verse fifty-six."
2 changes: 1 addition & 1 deletion tests/testutils/data/usfm/Tes/04LEVTes.SFM
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\id LEV - Test
\id lev - Test
\h Leviticus
\mt Leviticus
\c 14
Expand Down

0 comments on commit b857823

Please sign in to comment.