Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kidig committed Aug 18, 2024
1 parent ce1a023 commit 5e600dc
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/test_clock/test_clock_ru.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from datetime import time

import pytest
from saa.core.plugins import supported_languages
from saa.core.watch import Watch

Russian = supported_languages.get("ru")

test_cases = [
(time(hour=2, minute=0), Russian, "два часа"),
(time(hour=5, minute=0), Russian, "пять часов"),
(time(hour=12, minute=50), Russian, "без десяти час"),
(time(hour=12, minute=55), Russian, "без пяти час"),
(time(hour=13, minute=0), Russian, "один час"),
(time(hour=13, minute=5), Russian, "пять минут второго"),
(time(hour=13, minute=15), Russian, "пятнадцать минут второго"),
(time(hour=13, minute=20), Russian, "двадцать минут второго"),
(time(hour=13, minute=30), Russian, "половина второго"),
(time(hour=13, minute=40), Russian, "без двадцати два"),
(time(hour=13, minute=45), Russian, "без пятнадцати два"),
(time(hour=13, minute=50), Russian, "без десяти два"),
(time(hour=13, minute=55), Russian, "без пяти два"),
]


@pytest.mark.parametrize("test_input, language, test_output", test_cases)
def test_clocks(test_input, language, test_output):
clock = Watch(language=language)
assert test_output == clock(test_input)


test_plural_cases = [
(time(hour=12, minute=17), Russian, "двенадцать семнадцать"),
(time(hour=12, minute=26), Russian, "двенадцать двадцать шесть"),
(time(hour=13, minute=1), Russian, "час ноль одна"),
(time(hour=13, minute=2), Russian, "час ноль две"),
(time(hour=13, minute=11), Russian, "час одиннадцать"),
]


@pytest.mark.parametrize("test_input, language, test_output", test_plural_cases)
def test_cases(test_input, language, test_output):
clock = Watch(language=language)
assert test_output == clock(test_input)
16 changes: 16 additions & 0 deletions tests/test_numbers/test_numbers_ru.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pytest
from saa.core.numbers import Converter
from saa.core.plugins import supported_languages

Russian = supported_languages.get("ru")
test_cases = [
(45, Russian, "сорок пять"),
(13, Russian, "тринадцать"),
(7, Russian, "семь"),
]


@pytest.mark.parametrize("test_input, language, test_output", test_cases)
def test_numbers(test_input, language, test_output):
convert = Converter(language=language)
assert test_output == convert(test_input)

0 comments on commit 5e600dc

Please sign in to comment.