Update documentation and code snippets

This commit is contained in:
2025-12-03 14:30:33 +03:00
parent 2a0ec209c3
commit 52139e5405
14 changed files with 484 additions and 200 deletions
+30 -9
View File
@@ -21,17 +21,19 @@ msgstr ""
#: ../../root/testing.rst:2
msgid "Тестирование"
msgstr ""
msgstr "Testing"
#: ../../root/testing.rst:4
msgid ""
"В этом разделе описаны практики тестирования приложений на основе "
"``Argenta``. Примеры основаны на фактическом публичном API."
msgstr ""
"This section describes testing practices for applications based on ``Argenta``. "
"Examples are based on the actual public API."
#: ../../root/testing.rst:7
msgid "Модульное тестирование обработчиков"
msgstr ""
msgstr "Unit Testing Handlers"
#: ../../root/testing.rst:9
msgid ""
@@ -39,25 +41,29 @@ msgid ""
"чистые функции, не поднимая весь цикл приложения. Рекомендуются "
"``unittest`` или ``pytest``."
msgstr ""
"Handlers in ``Argenta`` are regular functions. They are convenient to test as pure "
"functions without starting the entire application cycle. ``unittest`` or ``pytest`` "
"are recommended."
#: ../../root/testing.rst:11 ../../root/testing.rst:24
#: ../../root/testing.rst:37 ../../root/testing.rst:53
msgid "**Пример использования:**"
msgstr ""
msgstr "**Usage example:**"
#: ../../root/testing.rst:20
msgid "Тестирование с внедрением зависимостей (DI)"
msgstr ""
msgstr "Testing with Dependency Injection (DI)"
#: ../../root/testing.rst:22
msgid ""
"Если обработчику нужны зависимости, используйте ``dishka`` и интеграцию "
"``Argenta``:"
msgstr ""
"If a handler needs dependencies, use ``dishka`` and ``Argenta`` integration:"
#: ../../root/testing.rst:33
msgid "Интеграционное тестирование приложения"
msgstr ""
msgstr "Integration Testing of the Application"
#: ../../root/testing.rst:35
msgid ""
@@ -66,10 +72,13 @@ msgid ""
"ввода. Это даёт близкое к реальности поведение без необходимости "
"симулировать ``stdin``."
msgstr ""
"For higher-level tests, assemble ``App`` and ``Router`` and call handlers through "
"command parsing, bypassing the infinite input loop. This provides behavior close to "
"reality without the need to simulate ``stdin``."
#: ../../root/testing.rst:46
msgid "E2E-тестирование цикла"
msgstr ""
msgstr "E2E Testing of the Loop"
#: ../../root/testing.rst:48
msgid ""
@@ -77,6 +86,9 @@ msgid ""
"передачей строк в ``stdin``. Это тяжелее и обычно не требуется. Если всё "
"же необходимо — пример ниже."
msgstr ""
"Full execution of the ``start_polling`` loop can be covered through a subprocess "
"with passing strings to ``stdin``. This is heavier and usually not required. If "
"still necessary, an example is below."
#: ../../root/testing.rst:51
msgid ""
@@ -85,34 +97,43 @@ msgid ""
"``input`` как аргумент ``side_effects``, иначе тестируемое приложение "
"будет ожидать ввода следующей команды и не сможет корректно завершиться."
msgstr ""
"Be sure to pass the exit command string trigger as the last element in the list "
"that you pass in the context manager when patching ``input`` as the ``side_effects`` "
"argument, otherwise the application under test will wait for the next command input "
"and will not be able to terminate correctly."
#: ../../root/testing.rst:62
msgid "Советы по тестированию"
msgstr ""
msgstr "Testing Tips"
#: ../../root/testing.rst:64
msgid "**Изолируйте тесты**: Каждый тест должен быть независимым от других."
msgstr ""
msgstr "**Isolate tests**: Each test should be independent of others."
#: ../../root/testing.rst:65
msgid ""
"**Моки для внешних интеграций**: БД, HTTP-клиенты и т.п. подменяйте "
"заглушками и провайдерами ``dishka``."
msgstr ""
"**Mocks for external integrations**: Replace databases, HTTP clients, etc. with "
"stubs and ``dishka`` providers."
#: ../../root/testing.rst:66
msgid ""
"**Покрывайте ошибочные сценарии**: Некорректные флаги, неизвестные "
"команды, пустой ввод."
msgstr ""
"**Cover error scenarios**: Incorrect flags, unknown commands, empty input."
#: ../../root/testing.rst:67
msgid ""
"**Минимизируйте зависимость от форматирования**: Сравнивайте ключевые "
"фрагменты вывода, а не весь блок целиком."
msgstr ""
"**Minimize formatting dependency**: Compare key output fragments, not the entire "
"block."
#: ../../root/testing.rst:68
msgid "**Измеряйте покрытие**: Используйте ``pytest-cov``."
msgstr ""
msgstr "**Measure coverage**: Use ``pytest-cov``."