diff --git a/tests/e2e/test_api.py b/tests/e2e/test_api.py index bf906d32..2b245bd6 100644 --- a/tests/e2e/test_api.py +++ b/tests/e2e/test_api.py @@ -1693,3 +1693,43 @@ def test_en_ulb_1jn_en_ulb_3jn_language_book_order_with_no_email_1c() -> None: assert ( "1 John" in body_content and "3 John" in body_content ), "Document should have had both 1 John and 3 John in it, but it didn't" + +@pytest.mark.focus +def test_en_tn_mat_with_book_intro() -> None: + with TestClient(app=app, base_url=settings.api_test_url()) as client: + response = client.post( + "/documents", + json={ + # "email_address": settings.TO_EMAIL_ADDRESS, + "assembly_strategy_kind": model.AssemblyStrategyEnum.LANGUAGE_BOOK_ORDER, + "assembly_layout_kind": model.AssemblyLayoutEnum.ONE_COLUMN, + "layout_for_print": False, + "chunk_size": model.ChunkSizeEnum.CHAPTER, + "generate_pdf": False, + "generate_epub": False, + "generate_docx": False, + "resource_requests": [ + { + "lang_code": "en", + "resource_type": "tn", + "book_code": "mat", + }, + ], + }, + ) + finished_document_request_key = check_result( + response, suffix="html", poll_duration=4 + ) + html_filepath = os.path.join( + settings.DOCUMENT_OUTPUT_DIR, + "{}.html".format(finished_document_request_key), + ) + with open(html_filepath, "r") as fin: + html = fin.read() + body_match = re.search(r"(.*?)", html, re.DOTALL) + assert body_match, "Body not found in HTML" + body_content = body_match.group(1) + if settings.SHOW_TN_BOOK_INTRO: + assert ( + "Outline of the Book of Matthew" in body_content + ), "Document should have had TN book intro for mat, but didn't" diff --git a/tests/unit/test_usfm_error_detection_and_fixes.py b/tests/unit/test_usfm_error_detection_and_fixes.py index baea0112..e0b94e17 100644 --- a/tests/unit/test_usfm_error_detection_and_fixes.py +++ b/tests/unit/test_usfm_error_detection_and_fixes.py @@ -74,7 +74,7 @@ def test_fix_verse_marker_without_v(self) -> None: \v 3 Vinse na man kpha fuhm ka nan zii bagaba.\v 4 Vinse we ba linwabung ɓuocnham la,la bagaba se ,Ii nyin faram la Neman li nwah buock.\v 5 Na man kha fuh la bai ba gamza gabq we bai fuh la bepiu la wulah vii a jekang.\v 6 In bi yang la bai ninka,Yuka be pi ba ba chonin ala we ba la ba ,au tarta vii kau u gama wala vii ba wai Yeso Almasihu.""", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers(self) -> None: self.assertEqual( @@ -82,7 +82,7 @@ def test_standalone_verse_numbers(self) -> None: r"\v 1 Some text.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers2(self) -> None: self.assertEqual( @@ -90,7 +90,7 @@ def test_standalone_verse_numbers2(self) -> None: r"\v 1 Some text. \v 2 This is more text.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers3(self) -> None: self.assertEqual( @@ -98,7 +98,7 @@ def test_standalone_verse_numbers3(self) -> None: r"\v 1 Some text. \v 2 This is more text.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers4(self) -> None: self.assertEqual( @@ -106,7 +106,7 @@ def test_standalone_verse_numbers4(self) -> None: r"\v 1 Some text. \v 2 This is more text.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers5(self) -> None: self.assertEqual( @@ -114,7 +114,7 @@ def test_standalone_verse_numbers5(self) -> None: r"\c 1 Some text. \v 1 This is more text.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers6(self) -> None: self.assertEqual( @@ -122,7 +122,7 @@ def test_standalone_verse_numbers6(self) -> None: r"\1 Some text. \2 This is more text.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers7(self) -> None: actual = fix_standalone_verse_numbers( @@ -144,7 +144,7 @@ def test_standalone_verse_numbers7(self) -> None: # print(repr(expected)) self.assertEqual(actual, expected) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers8(self) -> None: self.assertEqual( @@ -160,7 +160,7 @@ def test_standalone_verse_numbers8(self) -> None: """, ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers9(self) -> None: self.assertEqual( @@ -174,7 +174,7 @@ def test_standalone_verse_numbers9(self) -> None: """, ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers10(self) -> None: self.assertEqual( @@ -184,7 +184,7 @@ def test_standalone_verse_numbers10(self) -> None: r"""\v 15 وأليود ولد أليعازر \li1 وأليعازر ولد متان \li1 ومتان ولد يعقوب \li1 \v 16 ويعقوب ولد يوسف رجل مريم اللي ولدت عيسى اللي يسموه المسيح \li4 \v 17 ويطلع مجموع الأجيال من إبراهيم إلى داود 14 جيل ومن داود إلى الأسر البابلي 14 جيل ومن الأسر البابلي إلى المسيح 14 جيل""", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers11(self) -> None: self.assertEqual( @@ -194,7 +194,7 @@ def test_standalone_verse_numbers11(self) -> None: r"""\v 1 This is a verse \v2 this is another verse \v 3 and this verse too \v 4 and another as well""", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers12(self) -> None: self.assertEqual( @@ -204,7 +204,7 @@ def test_standalone_verse_numbers12(self) -> None: r"""\v 1 This is a verse \v2 this is another verse 3 and this verse too 3 and another as well""", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers13(self) -> None: self.assertEqual( @@ -262,7 +262,7 @@ def test_standalone_verse_numbers13(self) -> None: """, ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers14(self) -> None: self.assertEqual( @@ -288,7 +288,7 @@ def test_standalone_verse_numbers14(self) -> None: """, ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers15(self) -> None: self.assertEqual( @@ -320,7 +320,7 @@ def test_standalone_verse_numbers15(self) -> None: """, ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_standalone_verse_numbers16(self) -> None: self.assertEqual( @@ -397,7 +397,7 @@ def test_fix_usfm(self) -> None: """, ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_after_number(self) -> None: self.assertEqual( @@ -405,7 +405,7 @@ def test_fix_missing_space_after_number(self) -> None: r"\v 1 Some text.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_after_number2(self) -> None: self.assertEqual( @@ -413,7 +413,7 @@ def test_fix_missing_space_after_number2(self) -> None: r"\v 2 Another verse.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_after_number3(self) -> None: self.assertEqual( @@ -421,7 +421,7 @@ def test_fix_missing_space_after_number3(self) -> None: r"\v 5 5 Some text.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_after_number4(self) -> None: self.assertEqual( @@ -434,7 +434,7 @@ def test_fix_missing_space_after_number4(self) -> None: """, ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_after_number5(self) -> None: self.assertEqual( @@ -449,8 +449,7 @@ def test_fix_missing_space_after_number5(self) -> None: """, ) - # FIXME 11 gets matched and then split into 1 1 - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_missing_space_after_number6(self) -> None: self.assertEqual( @@ -464,7 +463,7 @@ def test_missing_space_after_number6(self) -> None: """, ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_missing_space_after_number7(self) -> None: self.assertEqual( @@ -494,7 +493,7 @@ def test_missing_space_after_number7(self) -> None: """, ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_before_number(self) -> None: self.assertEqual( @@ -502,7 +501,7 @@ def test_fix_missing_space_before_number(self) -> None: r"Wut. 1 Some text.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_before_number2(self) -> None: self.assertEqual( @@ -510,7 +509,7 @@ def test_fix_missing_space_before_number2(self) -> None: r"Wut. 1 Some text. \v 2 Yo", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_before_number3(self) -> None: self.assertEqual( @@ -524,7 +523,7 @@ def test_fix_missing_space_before_number3(self) -> None: """, ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_before_number4(self) -> None: actual = fix_missing_space_before_number( @@ -539,7 +538,7 @@ def test_fix_missing_space_before_number4(self) -> None: print("Actual: ", actual) self.assertEqual(actual, expected) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_before_number5(self) -> None: self.assertEqual( @@ -553,7 +552,7 @@ def test_fix_missing_space_before_number5(self) -> None: """, ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_before_number6(self) -> None: actual = fix_missing_space_before_number( @@ -568,7 +567,7 @@ def test_fix_missing_space_before_number6(self) -> None: print("Actual: ", actual) self.assertEqual(actual, expected) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_before_verse_marker(self) -> None: self.assertEqual( @@ -576,7 +575,7 @@ def test_fix_missing_space_before_verse_marker(self) -> None: r"Wut \v 1Some text.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_before_verse_marker2(self) -> None: self.assertEqual( @@ -586,7 +585,7 @@ def test_fix_missing_space_before_verse_marker2(self) -> None: r"\v 2Another verse. \v 3 This is more text.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_before_verse_marker3(self) -> None: self.assertEqual( @@ -594,7 +593,7 @@ def test_fix_missing_space_before_verse_marker3(self) -> None: r"\v 5 5Some text.", ) - @pytest.mark.focus + # @pytest.mark.focus @pytest.mark.usfm_fixes def test_fix_missing_space_before_verse_marker4(self) -> None: self.assertEqual(