Update docker-compose and README for Telegram bot integration; add environment file reference and clarify port usage in documentation.

This commit is contained in:
2025-08-31 23:32:56 +03:00
parent 7378179d98
commit 6733043a61
17 changed files with 2499 additions and 12 deletions

77
count_tests.py Normal file
View File

@@ -0,0 +1,77 @@
#!/usr/bin/env python3
"""
Скрипт для подсчета количества тестов в проекте
"""
import subprocess
import sys
import os
def count_tests_in_directory(directory):
"""Подсчитывает количество тестов в указанной директории"""
try:
# Запускаем pytest --collect-only для подсчета тестов
result = subprocess.run(
[sys.executable, '-m', 'pytest', directory, '--collect-only', '-q'],
capture_output=True,
text=True,
cwd=os.getcwd()
)
if result.returncode == 0:
# Ищем строку с количеством собранных тестов
for line in result.stdout.split('\n'):
if 'collected' in line:
# Извлекаем число из строки вида "78 collected"
parts = line.strip().split()
for part in parts:
if part.isdigit():
return int(part)
return 0
except Exception as e:
print(f"Ошибка при подсчете тестов в {directory}: {e}", file=sys.stderr)
return 0
def count_bot_tests():
"""Подсчитывает количество тестов бота"""
try:
# Переходим в директорию бота и запускаем pytest
bot_dir = os.path.join(os.getcwd(), 'bots', 'telegram-helper-bot')
result = subprocess.run(
[sys.executable, '-m', 'pytest', 'tests/', '--collect-only', '-q'],
capture_output=True,
text=True,
cwd=bot_dir
)
if result.returncode == 0:
# Ищем строку с количеством собранных тестов
for line in result.stdout.split('\n'):
if 'collected' in line:
# Извлекаем число из строки вида "201 collected"
parts = line.strip().split()
for part in parts:
if part.isdigit():
return int(part)
return 0
except Exception as e:
print(f"Ошибка при подсчете тестов бота: {e}", file=sys.stderr)
return 0
def main():
"""Основная функция"""
# Подсчитываем тесты инфраструктуры
infra_tests = count_tests_in_directory('tests/infra/')
# Подсчитываем тесты бота
bot_tests = count_bot_tests()
total_tests = infra_tests + bot_tests
# Выводим результат в формате для Makefile
print(f"{infra_tests}")
print(f"{bot_tests}")
print(f"{total_tests}")
if __name__ == '__main__':
main()