8 changed files with 152 additions and 1 deletions
@ -0,0 +1,19 @@ |
|||
# Header 1 { #header-1 } |
|||
|
|||
Some text with a link to <a href="https://fastapi.tiangolo.com">FastAPI</a>. |
|||
|
|||
## Header 2 { #header-2 } |
|||
|
|||
Two links here: <a href="https://fastapi.tiangolo.com/how-to/">How to</a> and <a href="project-generation.md" class="internal-link" target="_blank">Project Generators</a>. |
|||
|
|||
### Header 3 { #header-3 } |
|||
|
|||
Another link: <a href="project-generation.md" class="internal-link" target="_blank" title="Link title">**FastAPI** Project Generators</a> with title. |
|||
|
|||
# Header 4 { #header-4 } |
|||
|
|||
Link to anchor: <a href="#header-2">Header 2</a> |
|||
|
|||
# Header with <a href="http://example.com">link</a> { #header-with-link } |
|||
|
|||
Some text |
|||
@ -0,0 +1,21 @@ |
|||
# Заголовок 1 { #header-1 } |
|||
|
|||
Немного текста со ссылкой на <a href="https://fastapi.tiangolo.com">FastAPI</a>. |
|||
|
|||
## Заголовок 2 { #header-2 } |
|||
|
|||
Две ссылки здесь: <a href="https://fastapi.tiangolo.com/how-to/">How to</a> и <a href="project-generation.md" class="internal-link" target="_blank">Project Generators</a>. |
|||
|
|||
### Заголовок 3 { #header-3 } |
|||
|
|||
Ещё ссылка: <a href="project-generation.md" class="internal-link" target="_blank" title="Тайтл">**FastAPI** Генераторы Проектов</a> с тайтлом. |
|||
|
|||
И ещё одна <a href="https://github.com">экстра ссылка</a>. |
|||
|
|||
# Заголовок 4 { #header-4 } |
|||
|
|||
Ссылка на якорь: <a href="#header-2">Заголовок 2</a> |
|||
|
|||
# Заголовок со <a href="http://example.com">ссылкой</a> { #header-with-link } |
|||
|
|||
Немного текста |
|||
@ -0,0 +1,19 @@ |
|||
# Заголовок 1 { #header-1 } |
|||
|
|||
Немного текста со ссылкой на <a href="https://fastapi.tiangolo.com">FastAPI</a>. |
|||
|
|||
## Заголовок 2 { #header-2 } |
|||
|
|||
Две ссылки здесь: <a href="https://fastapi.tiangolo.com/how-to/">How to</a> и <a href="project-generation.md" class="internal-link" target="_blank">Project Generators</a>. |
|||
|
|||
### Заголовок 3 { #header-3 } |
|||
|
|||
Ещё ссылка: <a href="project-generation.md" class="internal-link" target="_blank" title="Тайтл">**FastAPI** Генераторы Проектов</a> с тайтлом. |
|||
|
|||
# Заголовок 4 { #header-4 } |
|||
|
|||
Ссылка на якорь: <a href="#header-2">Заголовок 2</a> |
|||
|
|||
# Заголовок с потерянной ссылкой { #header-with-link } |
|||
|
|||
Немного текста |
|||
@ -0,0 +1,56 @@ |
|||
from pathlib import Path |
|||
|
|||
import pytest |
|||
from typer.testing import CliRunner |
|||
|
|||
from scripts.translation_fixer import cli |
|||
|
|||
data_path = Path( |
|||
"scripts/tests/test_translation_fixer/test_html_links/data" |
|||
).absolute() |
|||
|
|||
|
|||
@pytest.mark.parametrize( |
|||
"copy_test_files", |
|||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_gt.md")], |
|||
indirect=True, |
|||
) |
|||
def test_gt(runner: CliRunner, root_dir: Path, copy_test_files): |
|||
result = runner.invoke( |
|||
cli, |
|||
["fix-pages", "docs/lang/docs/doc.md"], |
|||
) |
|||
assert result.exit_code == 1, result.output |
|||
|
|||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() |
|||
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text() |
|||
|
|||
assert fixed_content == expected_content # Translated doc remains unchanged |
|||
assert "Error processing docs/lang/docs/doc.md" in result.output |
|||
assert ( |
|||
"Number of HTML links does not match the number " |
|||
"in the original document (7 vs 6)" |
|||
) in result.output |
|||
|
|||
|
|||
@pytest.mark.parametrize( |
|||
"copy_test_files", |
|||
[(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_lt.md")], |
|||
indirect=True, |
|||
) |
|||
def test_lt(runner: CliRunner, root_dir: Path, copy_test_files): |
|||
result = runner.invoke( |
|||
cli, |
|||
["fix-pages", "docs/lang/docs/doc.md"], |
|||
) |
|||
# assert result.exit_code == 1, result.output |
|||
|
|||
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text() |
|||
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text() |
|||
|
|||
assert fixed_content == expected_content # Translated doc remains unchanged |
|||
assert "Error processing docs/lang/docs/doc.md" in result.output |
|||
assert ( |
|||
"Number of HTML links does not match the number " |
|||
"in the original document (5 vs 6)" |
|||
) in result.output |
|||
Loading…
Reference in new issue