Files
site_aegisone/py_service/tests/test_smoke_server.py
T
angel 72b6879f4b v1.7.0: refactor max_bot to flat structure, add VCF+UserModel+NLP history context, portal pages and proxy fixes
- Refactored max_bot from nested packages to flat module structure
- Q2: Extended BotUser model (patronymic, email, org, address, vcf_raw, contact_hash, phone_verified, email_verified, last_interaction, total_conversations, total_tickets)
- Q2: VCF parser (FN, N, TEL, EMAIL, ORG, ADR), upsert on re-contact, NLP history context (_get_user_history_context -> YandexGPT)
- Q1: Broadcast preview modal with 10s confirmation timer
- Q3: CSS var(--white)->var(--bg-card), var(--text)->var(--text-primary)
- Q4: bot_settings showNotification(), editable max_bot_id
- Q5: Webhook secret passthrough via X-Max-Bot-Api-Secret
- Masking sensitive keys, dialog_cleared handler, migrate via _add_column_if_not_exists()
- Rate limit (asyncio.sleep 0.5 per 10), dead code removed, conv.intent context in contact.py
- Portal pages: bot_consent, bot_kb (edit), bot_settings, bot_test, bot_tickets, portal_settings
- Tests: 21/21 passing, added test_yandex_gpt.py, test_email_sender.py
- Deploy: deploy_full.sh, schema.sql, seed_knowledge_base.sql
2026-05-29 02:30:30 +03:00

89 lines
2.6 KiB
Python

"""Smoke test — проверяет что сервер отвечает на все основные маршруты.
Запуск: TEST_SERVER_URL=http://localhost:8000 pytest tests/test_smoke_server.py -v
Работает против запущенного сервера (локально или удалённо).
Не требует БД — просто проверяет что ответ не 404 и не 502.
"""
import os
import httpx
import pytest
SERVER_URL = os.environ.get("TEST_SERVER_URL", "http://localhost:8000")
# All GET routes from the sidebar + common pages
ROUTES_TO_CHECK = [
"/service/dashboard",
"/service/charts",
"/service/ceo",
"/service/customers",
"/service/objects",
"/service/sla",
"/service/questionnaire",
"/service/passports",
"/service/users",
"/service/assignments",
"/service/tasks",
"/service/reports",
"/service/incidents",
"/service/checklist",
"/service/documents/",
"/service/documents/tech-access",
"/service/blog",
"/service/cases",
"/service/ideas",
"/service/questionnaire-config",
"/service/formulas",
"/service/coefficients",
"/service/coefficients/test",
"/service/portal-settings",
"/service/role-settings",
"/service/quick-menu",
]
# API routes (should work with or without auth)
API_ROUTES = [
"/service/api/shs",
"/service/api/changelog",
"/service/api/quick-menu",
]
@pytest.fixture(scope="module")
def client():
with httpx.Client(base_url=SERVER_URL, follow_redirects=False, timeout=10) as c:
yield c
class TestServerReachable:
def test_health(self, client):
resp = client.get("/health")
assert resp.status_code == 200
def test_login_page(self, client):
resp = client.get("/service/login")
assert resp.status_code == 200
def test_root_redirect(self, client):
resp = client.get("/")
assert resp.status_code == 200 or resp.status_code == 302
class TestAuthPagesRedirect:
"""Without auth, should redirect to login (302) or show login page (200)."""
@pytest.mark.parametrize("path", ROUTES_TO_CHECK)
def test_redirect_to_login(self, client, path):
resp = client.get(path, follow_redirects=False)
assert resp.status_code in (200, 302, 403), \
f"GET {path}: got {resp.status_code} (expected 302 redirect or 200/403)"
class TestApiRoutes:
"""API routes bypass auth middleware — should not 404."""
@pytest.mark.parametrize("path", API_ROUTES)
def test_api_not_404(self, client, path):
resp = client.get(path)
assert resp.status_code != 404, f"API {path} returned 404 (route missing)"