8 changed files with 176 additions and 0 deletions
@ -0,0 +1,19 @@ |
|||
# Header 1 { #header-1 } |
|||
|
|||
Some text with a link to [FastAPI](https://fastapi.tiangolo.com). |
|||
|
|||
## Header 2 { #header-2 } |
|||
|
|||
Two links here: [How to](https://fastapi.tiangolo.com/how-to/) and [Project Generators](project-generation.md){.internal-link target=_blank}. |
|||
|
|||
### Header 3 { #header-3 } |
|||
|
|||
Another link: [**FastAPI** Project Generators](project-generation.md "Link title"){.internal-link target=_blank} with title. |
|||
|
|||
# Header 4 { #header-4 } |
|||
|
|||
Link to anchor: [Header 2](#header-2) |
|||
|
|||
# Header with [link](http://example.com) { #header-with-link } |
|||
|
|||
Some text |
|||
@ -0,0 +1,19 @@ |
|||
# Заголовок 1 { #header-1 } |
|||
|
|||
Немного текста со ссылкой на [FastAPI](https://fastapi.tiangolo.com). |
|||
|
|||
## Заголовок 2 { #header-2 } |
|||
|
|||
Две ссылки здесь: [How to](https://fastapi.tiangolo.com/how-to/) и [Project Generators](project-generation.md){.internal-link target=_blank}. |
|||
|
|||
### Заголовок 3 { #header-3 } |
|||
|
|||
Ещё ссылка: [**FastAPI** Генераторы Проектов](project-generation.md "Тайтл"){.internal-link target=_blank} с тайтлом. |
|||
|
|||
# Заголовок 4 { #header-4 } |
|||
|
|||
Ссылка на якорь: [Заголовок 2](#header-2) |
|||
|
|||
# Заголовок со [ссылкой](http://example.com) { #header-with-link } |
|||
|
|||
Немного текста |
|||
@ -0,0 +1,21 @@ |
|||
# Заголовок 1 { #header-1 } |
|||
|
|||
Немного текста со ссылкой на [FastAPI](https://fastapi.tiangolo.com). |
|||
|
|||
## Заголовок 2 { #header-2 } |
|||
|
|||
Две ссылки здесь: [How to](https://fastapi.tiangolo.com/how-to/) и [Project Generators](project-generation.md){.internal-link target=_blank}. |
|||
|
|||
### Заголовок 3 { #header-3 } |
|||
|
|||
Ещё ссылка: [**FastAPI** Генераторы Проектов](project-generation.md "Тайтл"){.internal-link target=_blank} с тайтлом. |
|||
|
|||
И ещё одна [экстра ссылка](https://github.com). |
|||
|
|||
# Заголовок 4 { #header-4 } |
|||
|
|||
Ссылка на якорь: [Заголовок 2](#header-2) |
|||
|
|||
# Заголовок со [ссылкой](http://example.com) { #header-with-link } |
|||
|
|||
Немного текста |
|||
@ -0,0 +1,19 @@ |
|||
# Заголовок 1 { #header-1 } |
|||
|
|||
Немного текста со ссылкой на [FastAPI](https://fastapi.tiangolo.com). |
|||
|
|||
## Заголовок 2 { #header-2 } |
|||
|
|||
Две ссылки здесь: [How to](https://fastapi.tiangolo.com/how-to/) и [Project Generators](project-generation.md){.internal-link target=_blank}. |
|||
|
|||
### Заголовок 3 { #header-3 } |
|||
|
|||
Ещё ссылка: [**FastAPI** Генераторы Проектов](project-generation.md "Тайтл"){.internal-link target=_blank} с тайтлом. |
|||
|
|||
# Заголовок 4 { #header-4 } |
|||
|
|||
Ссылка на якорь: [Заголовок 2](#header-2) |
|||
|
|||
# Заголовок с потерянной ссылкой { #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_markdown_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 markdown 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 markdown links does not match the number " |
|||
"in the original document (5 vs 6)" |
|||
) in result.output |
|||
Loading…
Reference in new issue