Skip to content

Port: Handle invalid book id tags more robustly#292

Open
Copilot wants to merge 5 commits intomainfrom
copilot/port-handle-invalid-book-id-tags
Open

Port: Handle invalid book id tags more robustly#292
Copilot wants to merge 5 commits intomainfrom
copilot/port-handle-invalid-book-id-tags

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 23, 2026

  • Update usfm_parser.py: Truncate book code to 3 characters when longer than 3
  • Update usfm_text_base.py: In start_book, add early return if verse_ref.book is already set and doesn't match the new code (handle multiple \id markers)
  • Update usfm_file_text_corpus.py: In _get_id, add truncation to 3 chars if id has no space or space after position 3; always uppercase the result
  • Update test data files: Change 03LEVTes.SFM and 131CHTes.SFM to use full book names (without " - Test")
  • Add tests in test_usfm_memory_text.py for invalid/truncated/multiple/no-space book code scenarios
  • Move pytest import to the top of test_usfm_memory_text.py
  • Use specific RuntimeError (not generic Exception) in the three error-raising test cases

This change is Reviewable

Copilot AI changed the title [WIP] Port handling of invalid book ID tags from PR 407 Port: Handle invalid book id tags more robustly Apr 23, 2026
Copilot AI requested a review from ddaspit April 23, 2026 19:33
Comment thread tests/corpora/test_usfm_memory_text.py Outdated


def test_get_rows_book_code_invalid() -> None:
import pytest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Move pytest import to the top of the file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in fd84e59.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.50%. Comparing base (1ce8112) to head (ad16cf1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #292   +/-   ##
=======================================
  Coverage   91.49%   91.50%           
=======================================
  Files         355      355           
  Lines       22835    22861   +26     
=======================================
+ Hits        20894    20920   +26     
  Misses       1941     1941           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI requested a review from ddaspit April 23, 2026 20:03
@ddaspit ddaspit marked this pull request as ready for review April 23, 2026 20:04
Copy link
Copy Markdown
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@ddaspit reviewed 6 files and all commit messages, made 2 comments, and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on copilot[bot]).


tests/corpora/test_usfm_memory_text.py line 470 at r2 (raw file):

def test_get_rows_book_code_different_to_filename() -> None:
    with pytest.raises(Exception):

@copilot[bot] Check for the specific error that is thrown.

Copy link
Copy Markdown
Author

Copilot AI commented Apr 23, 2026

:lgtm:

@ddaspit reviewed 6 files and all commit messages, made 2 comments, an...

Done in ad16cf1. The ValueError raised in start_book is caught and re-wrapped as RuntimeError by the parser, so all three error-raising tests now assert RuntimeError.

Copilot AI requested a review from ddaspit April 23, 2026 20:25
Copy link
Copy Markdown
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddaspit reviewed 1 file and all commit messages, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on copilot[bot]).

@ddaspit ddaspit requested a review from pmachapman April 23, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port 'Handle invalid book id tags more robustly'

3 participants