|
| 1 | +import datetime |
| 2 | + |
| 3 | +from fastapi_translations.models import DocFile, Summary |
| 4 | + |
| 5 | + |
| 6 | +def test_must_compute_summary_when_adding_docfile(): |
| 7 | + doc1 = DocFile( |
| 8 | + translation_lang="es", |
| 9 | + original_file="/test/file1.md", |
| 10 | + original_commit=datetime.datetime(2024, 1, 1, 0, 0, 0), |
| 11 | + translation_file="/test/file1.md", |
| 12 | + translation_exists=True, |
| 13 | + translation_commit=datetime.datetime(2024, 1, 15, 0, 0, 0), |
| 14 | + translation_is_outdated=True |
| 15 | + ) |
| 16 | + doc2 = DocFile( |
| 17 | + translation_lang="es", |
| 18 | + original_file="/test/file2.md", |
| 19 | + original_commit=datetime.datetime(2024, 1, 1, 0, 0, 0), |
| 20 | + translation_file="/test/file2.md", |
| 21 | + translation_exists=True, |
| 22 | + translation_commit=datetime.datetime(2024, 1, 1, 0, 0, 0), |
| 23 | + translation_is_outdated=False |
| 24 | + ) |
| 25 | + doc3 = DocFile( |
| 26 | + translation_lang="es", |
| 27 | + original_file="/test/file3.md", |
| 28 | + original_commit=datetime.datetime(2024, 1, 1, 0, 0, 0), |
| 29 | + translation_file=None, |
| 30 | + translation_exists=False, |
| 31 | + translation_commit=None, |
| 32 | + translation_is_outdated=False |
| 33 | + ) |
| 34 | + summary = Summary(lang="es") |
| 35 | + summary.append_file(doc1) |
| 36 | + summary.append_file(doc2) |
| 37 | + summary.append_file(doc3) |
| 38 | + |
| 39 | + assert summary.files_analyzed == 3 |
| 40 | + assert summary.files_missing_translation == 1 |
| 41 | + assert summary.files_outdated == 1 |
| 42 | + assert summary.files_translated == 2 |
0 commit comments