Created At: 2026-11-18T07:55:22Z Completed At: 2026-11-18T07:55:30Z Command exited with code 1. Command output: ============================= test session starts ============================== platform linux -- Python 3.12.3, pytest-9.2.0, pluggy-1.7.0 -- /root/telegram-saas/.venv/bin/python3 cachedir: .pytest_cache rootdir: /root/telegram-saas configfile: pyproject.toml testpaths: tests plugins: anyio-4.16.0, asyncio-1.5.0 asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function collecting ... collected 56 items tests/integration/test_auth.py::test_auth_workflow PASSED [ 1%] tests/integration/test_celery_telegram_tasks.py::test_telegram_update_task_execution PASSED [ 3%] tests/integration/test_emojis_api.py::test_search_emojis_by_term PASSED [ 5%] tests/integration/test_emojis_api.py::test_search_emojis_by_category PASSED [ 7%] tests/integration/test_emojis_api.py::test_get_categories_list PASSED [ 8%] tests/integration/test_health.py::test_health_liveness PASSED [ 10%] tests/integration/test_health.py::test_health_readiness FAILED [ 12%] tests/integration/test_i18n_api.py::test_get_locales_list PASSED [ 14%] tests/integration/test_i18n_api.py::test_get_translation_bundle PASSED [ 16%] tests/integration/test_i18n_api.py::test_update_user_locale PASSED [ 17%] tests/integration/test_i18n_api.py::test_save_custom_translation_override PASSED [ 19%] tests/integration/test_message_studio_api.py::test_bot_message_studio_lifecycle PASSED [ 21%] tests/integration/test_multi_bot_engine.py::test_multi_tenant_multi_bot_engine_lifecycle FAILED [ 23%] tests/integration/test_text_designer_api.py::test_text_designer_api_endpoints PASSED [ 25%] tests/tenant_isolation/test_tenant_isolation.py::test_strict_tenant_isolation PASSED [ 26%] tests/unit/test_bot_engine.py::test_bot_token_validation_with_getme PASSED [ 28%] tests/unit/test_bot_engine.py::test_bot_token_encryption_and_decryption PASSED [ 30%] tests/unit/test_bot_engine.py::test_webhook_secret_generation_and_verification PASSED [ 32%] tests/unit/test_bot_engine.py::test_rate_limit_retry_handling PASSED [ 33%] tests/unit/test_emojis.py::test_telegram_html_emoji_formatting PASSED [ 35%] tests/unit/test_emojis.py::test_telegram_markdown_emoji_formatting PASSED [ 37%] tests/unit/test_emojis.py::test_id_precision_is_preserved_as_string PASSED [ 39%] tests/unit/test_formatter_and_engine.py::test_box_header_formatting PASSED [ 41%] tests/unit/test_formatter_and_engine.py::test_separator_presets PASSED [ 42%] tests/unit/test_formatter_and_engine.py::test_info_block_formatting PASSED [ 44%] tests/unit/test_formatter_and_engine.py::test_progress_bar_generation PASSED [ 46%] tests/unit/test_formatter_and_engine.py::test_progress_step_header PASSED [ 48%] tests/unit/test_formatter_and_engine.py::test_telegram_message_builder PASSED [ 50%] tests/unit/test_i18n.py::test_supported_locales_catalog PASSED [ 51%] tests/unit/test_i18n.py::test_rtl_detection PASSED [ 53%] tests/unit/test_i18n.py::test_plural_rules PASSED [ 55%] tests/unit/test_i18n.py::test_formatting PASSED [ 57%] tests/unit/test_i18n.py::test_fallback_resolution PASSED [ 58%] tests/unit/test_i18n.py::test_translation_engine PASSED [ 60%] tests/unit/test_i18n.py::test_interpolation PASSED [ 62%] tests/unit/test_i18n.py::test_missing_translation_fallback PASSED [ 64%] tests/unit/test_i18n.py::test_telegram_keyboard_builder PASSED [ 66%] tests/unit/test_message_studio.py::test_variable_interpolation PASSED [ 67%] tests/unit/test_message_studio.py::test_missing_variables_fallback PASSED [ 69%] tests/unit/test_message_studio.py::test_keyboard_matrix_ordering PASSED [ 71%] tests/unit/test_message_studio.py::test_aiogram_keyboard_generation PASSED [ 73%] tests/unit/test_message_studio.py::test_default_system_templates PASSED [ 75%] tests/unit/test_security.py::test_password_hashing PASSED [ 76%] tests/unit/test_security.py::test_aes_256_gcm_encryption PASSED [ 78%] tests/unit/test_security.py::test_jwt_tokens PASSED [ 80%] tests/unit/test_security.py::test_token_hashing PASSED [ 82%] tests/unit/test_unicode_styler.py::test_small_caps_transformation PASSED [ 83%] tests/unit/test_unicode_styler.py::test_tag_and_variable_preservation PASSED [ 85%] tests/unit/test_unicode_styler.py::test_other_unicode_styles PASSED [ 87%] tests/unit/test_unicode_styler.py::test_symbol_catalog_contents PASSED [ 89%] tests/unit/test_validators_and_presets.py::test_html_validator_valid PASSED [ 91%] tests/unit/test_validators_and_presets.py::test_html_validator_invalid_tags PASSED [ 92%] tests/unit/test_validators_and_presets.py::test_html_validator_unclosed_tags PASSED [ 94%] tests/unit/test_validators_and_presets.py::test_message_length_validator PASSED [ 96%] tests/unit/test_validators_and_presets.py::test_callback_data_validator PASSED [ 98%] tests/unit/test_validators_and_presets.py::test_preset_manager_loads_all_presets PASSED [100%] =================================== FAILURES =================================== ____________________________ test_health_readiness _____________________________ async_client = @pytest.mark.asyncio async def test_health_readiness(async_client: AsyncClient): response = await async_client.get("/api/v1/health/detailed") > assert response.status_code == 200 E assert 503 == 200 E + where 503 = .status_code tests/integration/test_health.py:17: AssertionError ----------------------------- Captured stdout call ----------------------------- 2026-11-18 07:55:27 [info ] initializing_redis_pool url=redis://127.0.0.1:6379/0 ------------------------------ Captured log call ------------------------------- ERROR sqlalchemy.pool.impl.AsyncAdaptedQueuePool:base.py:389 Exception terminating connection > Traceback (most recent call last): File "asyncpg/protocol/protocol.pyx", line 585, in asyncpg.protocol.protocol.BaseProtocol.close File "asyncpg/protocol/protocol.pyx", line 677, in _drain_cancels File "asyncpg/protocol/protocol.pyx", line 624, in asyncpg.protocol.protocol.BaseProtocol._request_cancel File "/root/telegram-saas/.venv/lib/python3.12/site-packages/asyncpg/connection.py", line 1712, in _cancel_current_command self._cancellations.add(self._loop.create_task( ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/asyncio/base_events.py", line 456, in create_task self._check_closed() File "/usr/lib/python3.12/asyncio/base_events.py", line 541, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/root/telegram-saas/.venv/lib/python3.12/site-packages/asyncpg/connection.py", line 1536, in close await self._protocol.close(timeout) File "asyncpg/protocol/protocol.pyx", line 610, in close File "asyncpg/protocol/protocol.pyx", line 697, in asyncpg.protocol.protocol.BaseProtocol._handle_waiter_on_connection_lost File "/usr/lib/python3.12/asyncio/base_events.py", line 795, in call_soon self._check_closed() File "/usr/lib/python3.12/asyncio/base_events.py", line 541, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/root/telegram-saas/.venv/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 370, in _close_connection self._dialect.do_terminate(connection) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 1190, in do_terminate dbapi_connection.terminate() File "/root/telegram-saas/.venv/lib/python3.12/site-packages/sqlalchemy/connectors/asyncio.py", line 440, in terminate await_(asyncio.shield(self._terminate_graceful_close())) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/sqlalchemy/util/concurrency.py", line 171, in await_ return current.parent.switch(awaitable) # type: ignore[no-any-return] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/telegram-saas/.venv/lib/python3.12/site-packages/sqlalchemy/util/concurrency.py", line 209, in greenlet_spawn value = await result ^^^^^^^^^^^^ File "/root/telegram-saas/.venv/lib/python3.12/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 955, in _terminate_graceful_close await self._connection.close(timeout=2) File "/root/telegram-saas/.venv/lib/python3.12/site-packages/asyncpg/connection.py", line 1539, in close self._abort() File "/root/telegram-saas/.venv/lib/python3.12/site-packages/asyncpg/connection.py", line 1600, in _abort self._protocol.abort() File "asyncpg/protocol/protocol.pyx", line 567, in asyncpg.protocol.protocol.BaseProtocol.abort File "/usr/lib/python3.12/asyncio/sslproto.py", line 250, in abort self._force_close(None) File "/usr/lib/python3.12/asyncio/sslproto.py", line 255, in _force_close self._ssl_protocol._abort(exc) File "/usr/lib/python3.12/asyncio/sslproto.py", line 671, in _abort self._transport._force_close(exc) File "/usr/lib/python3.12/asyncio/selector_events.py", line 906, in _force_close self._loop.call_soon(self._call_connection_lost, exc) File "/usr/lib/python3.12/asyncio/base_events.py", line 795, in call_soon self._check_closed() File "/usr/lib/python3.12/asyncio/base_events.py", line 541, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed _________________ test_multi_tenant_multi_bot_engine_lifecycle _________________ async_client = db_session = @pytest.mark.asyncio async def test_multi_tenant_multi_bot_engine_lifecycle( async_client: AsyncClient, db_session: AsyncSession, ): # ------------------------------------------------------------- # 1. Setup Mock Bot Tokens # ------------------------------------------------------------- token_a1 = f"token_a1_{uuid.uuid4().hex[:8]}_test" token_a2 = f"token_a2_{uuid.uuid4().hex[:8]}_test" token_b1 = f"token_b1_{uuid.uuid4().hex[:8]}_test" TelegramApiService.register_mock_bot(token_a1, "alpha_bot_1", "Alpha One") TelegramApiService.register_mock_bot(token_a2, "alpha_bot_2", "Alpha Two") TelegramApiService.register_mock_bot(token_b1, "beta_bot_1", "Beta One") # ------------------------------------------------------------- # 2. Register User A & Tenant Alpha # ------------------------------------------------------------- user_a_email = f"user_a_{uuid.uuid4().hex[:6]}@example.com" resp_a = await async_client.post( "/api/v1/auth/register", json={"email": user_a_email, "password": "PasswordA123!", "full_name": "Alice Alpha"}, ) token_user_a = resp_a.json()["data"]["access_token"] tenant_a_resp = await async_client.post( "/api/v1/tenants", headers={"Authorization": f"Bearer {token_user_a}"}, json={"name": "Tenant Alpha Org", "slug": f"alpha-{uuid.uuid4().hex[:6]}"}, ) tenant_a_id = tenant_a_resp.json()["data"]["id"] headers_a = { "Authorization": f"Bearer {token_user_a}", "X-Tenant-ID": str(tenant_a_id), } # ------------------------------------------------------------- # 3. Register User B & Tenant Beta # ------------------------------------------------------------- user_b_email = f"user_b_{uuid.uuid4().hex[:6]}@example.com" resp_b = await async_client.post( "/api/v1/auth/register", json={"email": user_b_email, "password": "PasswordB123!", "full_name": "Bob Beta"}, ) token_user_b = resp_b.json()["data"]["access_token"] tenant_b_resp = await async_client.post( "/api/v1/tenants", headers={"Authorization": f"Bearer {token_user_b}"}, json={"name": "Tenant Beta Org", "slug": f"beta-{uuid.uuid4().hex[:6]}"}, ) tenant_b_id = tenant_b_resp.json()["data"]["id"] headers_b = { "Authorization": f"Bearer {token_user_b}", "X-Tenant-ID": str(tenant_b_id), } # ------------------------------------------------------------- # 4. Tenant Alpha Registers Bot A1 and Bot A2 # ------------------------------------------------------------- reg_a1 = await async_client.post( "/api/v1/bots", headers=headers_a, json={"token": token_a1, "name": "Alpha Bot 1", "default_locale": "en"}, ) > assert reg_a1.status_code == 201, reg_a1.text E AssertionError: {"success":false,"message":"Telegram bot @alpha_bot_1 is already registered on this platform","error":{"code":"CONFLICT","message":"Telegram bot @alpha_bot_1 is already registered on this platform","details":{}}} E assert 409 == 201 E + where 409 = .status_code tests/integration/test_multi_bot_engine.py:78: AssertionError ----------------------------- Captured stdout call ----------------------------- 2026-11-18 07:55:28 [info ] dispatching_domain_event event_id=093b0f04-5d01-4a37-81f3-5fca9166c351 event_type=UserRegisteredEvent handlers_count=0 2026-11-18 07:55:28 [info ] dispatching_domain_event event_id=1251efed-9085-4aad-acb4-7841edcb3fc7 event_type=TenantCreatedEvent handlers_count=0 2026-11-18 07:55:28 [info ] dispatching_domain_event event_id=310bd80e-ed9a-4083-8c6f-5331197c15e4 event_type=UserRegisteredEvent handlers_count=0 2026-11-18 07:55:28 [info ] dispatching_domain_event event_id=d9231cbc-5287-489b-aa80-1ca33c91e89c event_type=TenantCreatedEvent handlers_count=0 2026-11-18 07:55:28 [warning ] app_exception_handled error_code=CONFLICT message='Telegram bot @alpha_bot_1 is already registered on this platform' method=POST path=/api/v1/bots =============================== warnings summary =============================== tests/integration/test_message_studio_api.py::test_bot_message_studio_lifecycle /usr/lib/python3.12/asyncio/locks.py:167: RuntimeWarning: coroutine 'Connection._cancel' was never awaited self._waiters = collections.deque() Enable tracemalloc to get traceback where the object was allocated. See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info. -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =========================== short test summary info ============================ FAILED tests/integration/test_health.py::test_health_readiness - assert 503 =... FAILED tests/integration/test_multi_bot_engine.py::test_multi_tenant_multi_bot_engine_lifecycle =================== 2 failed, 54 passed, 1 warning in 2.90s ====================