mirror of
https://github.com/dartdavros/chatballs.git
synced 2026-10-05 01:14:58 +03:00
✅ fix(tests): pytest-сьют backend снова запускается целиком
`docker compose run backend-app pytest` (то, что делает scripts/check.ps1) не доходил до первого теста. Две независимые причины, обе давние. 1. Область сбора. В pytest.ini не было ни `testpaths`, ни `norecursedirs`, а compose монтирует `data/media` в `/app/apps/backend/media`. На установке с демо-данными это 741 каталог организаций, и сбор падал через 2:46 с `OSError: [Errno 12] Cannot allocate memory` на обходе медиа. `testpaths` перечисляет оба пакета с тестами: только `chatballs` было бы мало — в `chatballs_backend/test_surfaces.py` лежат проверки изоляции поверхностей (loopback-only admin, раздельные cookie, исключение gateway-эндпоинта из SSL-редиректа), и они бы молча выпали из прогона. `norecursedirs` добавлен сверх этого: на запуск с явным путём `testpaths` не распространяется. 2. Боевая функция, собираемая как тест. `ai/test_demo_provider.py` импортировал на уровне модуля `integrations.services.test_integration`; pytest считает тестом любое имя `test_*` в тестовом модуле и падал на ненайденных фикстурах `context` и `integration`. Функция не переименована намеренно: в `integrations/tests.py` и `integrations/test_email.py` она уже импортируется под алиасом `run_integration_test` — конвенция в проекте есть, в этом файле её забыли применить. Добавлен алиас и комментарий, зачем он. Проверка: сбор — 625 позиций за 15 с вместо падения через 2:46; полный прогон — 624 passed, 0 failed (21 мин). Остальные наборы зелёные: internal-ui vitest 76/76, typecheck internal-ui и web-chat, CLI 9/9. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b2bc951f68
commit
6a93cfcbd7
2 files changed
+18
-2
No files matched your search
@@ -9,7 +9,13 @@ from chatballs.ai.runtime import HANDOFF_TOKEN
|
||||
from chatballs.identity.bootstrap import bootstrap_owner
|
||||
from chatballs.identity.models import Organization
|
||||
from chatballs.integrations.models import Integration, IntegrationKind, IntegrationProvider, IntegrationStatus
|
||||
from chatballs.integrations.services import IntegrationInput, create_integration, test_integration
|
||||
from chatballs.integrations.services import (
|
||||
IntegrationInput,
|
||||
create_integration,
|
||||
# Алиас обязателен: имя test_* на уровне модуля pytest собирает как тест
|
||||
# и падает на ненайденных фикстурах (как в integrations/tests.py).
|
||||
test_integration as run_integration_test,
|
||||
)
|
||||
from chatballs.testing import system_tenant_context
|
||||
|
||||
KNOWLEDGE = (
|
||||
@@ -73,6 +79,6 @@ class DemoIntegrationTests(TestCase):
|
||||
self.assertEqual(integration.kind, IntegrationKind.LLM_PROVIDER)
|
||||
self.assertEqual(integration.config["default_model"], "demo")
|
||||
self.assertTrue(integration.secret)
|
||||
checked = test_integration(context=self.context, integration=integration)
|
||||
checked = run_integration_test(context=self.context, integration=integration)
|
||||
self.assertEqual(checked.status, IntegrationStatus.OK)
|
||||
self.assertIsInstance(_provider_from_integration(Integration.objects.get(pk=integration.pk)), DemoProvider)
|
||||
@@ -1,3 +1,13 @@
|
||||
[pytest]
|
||||
DJANGO_SETTINGS_MODULE = chatballs_backend.settings
|
||||
python_files = tests.py test_*.py *_tests.py
|
||||
|
||||
# Область сбора. Без неё pytest без аргументов обходит весь каталог backend,
|
||||
# включая примонтированный media/ с каталогом на каждую организацию: на живой
|
||||
# установке это сотни тысяч файлов, и сбор падает раньше первого теста
|
||||
# (OSError: Cannot allocate memory). Тесты живут только в двух пакетах.
|
||||
testpaths = chatballs chatballs_backend
|
||||
|
||||
# Страховка на случай запуска с явным путём или из другого каталога:
|
||||
# media и staticfiles — данные и артефакты сборки, тестов там нет.
|
||||
norecursedirs = media staticfiles .venv node_modules __pycache__ *.egg-info
|
||||
Reference in new issue
Block a user