Skip to content

Commit

Permalink
Add minimal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Marques committed Jul 31, 2024
1 parent aceebf1 commit 8857b90
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fastapi_translations/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.0.4"
VERSION = "0.0.5"
Empty file added tests/__init__.py
Empty file.
42 changes: 42 additions & 0 deletions tests/models_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import datetime

from fastapi_translations.models import DocFile, Summary


def test_must_compute_summary_when_adding_docfile():
doc1 = DocFile(
translation_lang="es",
original_file="/test/file1.md",
original_commit=datetime.datetime(2024, 1, 1, 0, 0, 0),
translation_file="/test/file1.md",
translation_exists=True,
translation_commit=datetime.datetime(2024, 1, 15, 0, 0, 0),
translation_is_outdated=True
)
doc2 = DocFile(
translation_lang="es",
original_file="/test/file2.md",
original_commit=datetime.datetime(2024, 1, 1, 0, 0, 0),
translation_file="/test/file2.md",
translation_exists=True,
translation_commit=datetime.datetime(2024, 1, 1, 0, 0, 0),
translation_is_outdated=False
)
doc3 = DocFile(
translation_lang="es",
original_file="/test/file3.md",
original_commit=datetime.datetime(2024, 1, 1, 0, 0, 0),
translation_file=None,
translation_exists=False,
translation_commit=None,
translation_is_outdated=False
)
summary = Summary(lang="es")
summary.append_file(doc1)
summary.append_file(doc2)
summary.append_file(doc3)

assert summary.files_analyzed == 3
assert summary.files_missing_translation == 1
assert summary.files_outdated == 1
assert summary.files_translated == 2

0 comments on commit 8857b90

Please sign in to comment.