Repository navigation
Add try_get_chapters to scripture parsing #407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| from pytest import raises | ||
|
|
||
| from machine.scripture import get_books, get_chapters | ||
| from machine.scripture import get_books, get_chapters, try_get_chapters | ||
|
|
||
|
|
||
| def test_get_books() -> None: | ||
|
|
@@ -177,3 +177,30 @@ def test_get_chapters() -> None: | |
| get_chapters("OT,MAT1") | ||
| with raises(ValueError): | ||
| get_chapters("OT,MAT-LUK") | ||
|
|
||
| # empty segments | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: F4. The empty-segment guard is tested only through string input with a doubled or lone |
||
| with raises(ValueError): | ||
| get_chapters("MAT;;MRK") | ||
| with raises(ValueError): | ||
| get_chapters(" ; ") | ||
| with raises(ValueError): | ||
| get_chapters(";") | ||
|
|
||
|
|
||
| def test_try_get_chapters() -> None: | ||
| assert try_get_chapters("MAT1-4,12,9") == {40: [1, 2, 3, 4, 9, 12]} | ||
| assert try_get_chapters("") == {} | ||
| assert try_get_chapters(["MAT", "-MAT 1"]) == {40: list(range(2, 29))} | ||
|
|
||
| # invalid syntax, book, chapter, and subtraction | ||
| assert try_get_chapters("OT,MAT1") is None | ||
| assert try_get_chapters("ABC") is None | ||
| assert try_get_chapters("MAT 500") is None | ||
| assert try_get_chapters("MAT3-1") is None | ||
| assert try_get_chapters("-MRK") is None | ||
| assert try_get_chapters("MRK 2-5;-MRK 6") is None | ||
|
|
||
| # empty segments | ||
| assert try_get_chapters("MAT;;MRK") is None | ||
| assert try_get_chapters(" ; ") is None | ||
| assert try_get_chapters(";") is None | ||
Uh oh!
There was an error while loading. Please reload this page.