Created At: 2026-11-18T06:22:20Z Completed At: 2026-11-18T06:22:27Z 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 33 items tests/integration/test_auth.py::test_auth_workflow PASSED [ 3%] tests/integration/test_emojis_api.py::test_search_emojis_by_term PASSED [ 6%] tests/integration/test_emojis_api.py::test_search_emojis_by_category PASSED [ 9%] tests/integration/test_emojis_api.py::test_get_categories_list PASSED [ 12%] tests/integration/test_health.py::test_health_liveness PASSED [ 15%] tests/integration/test_health.py::test_health_readiness PASSED [ 18%] tests/integration/test_i18n_api.py::test_get_locales_list PASSED [ 21%] tests/integration/test_i18n_api.py::test_get_translation_bundle PASSED [ 24%] tests/integration/test_i18n_api.py::test_update_user_locale PASSED [ 27%] tests/integration/test_i18n_api.py::test_save_custom_translation_override PASSED [ 30%] tests/integration/test_message_studio_api.py::test_bot_message_studio_lifecycle FAILED [ 33%] tests/tenant_isolation/test_tenant_isolation.py::test_strict_tenant_isolation PASSED [ 36%] tests/unit/test_emojis.py::test_telegram_html_emoji_formatting PASSED [ 39%] tests/unit/test_emojis.py::test_telegram_markdown_emoji_formatting PASSED [ 42%] tests/unit/test_emojis.py::test_id_precision_is_preserved_as_string PASSED [ 45%] tests/unit/test_i18n.py::test_supported_locales_catalog PASSED [ 48%] tests/unit/test_i18n.py::test_rtl_detection PASSED [ 51%] tests/unit/test_i18n.py::test_plural_rules PASSED [ 54%] tests/unit/test_i18n.py::test_formatting PASSED [ 57%] tests/unit/test_i18n.py::test_fallback_resolution PASSED [ 60%] tests/unit/test_i18n.py::test_translation_engine PASSED [ 63%] tests/unit/test_i18n.py::test_interpolation PASSED [ 66%] tests/unit/test_i18n.py::test_missing_translation_fallback PASSED [ 69%] tests/unit/test_i18n.py::test_telegram_keyboard_builder PASSED [ 72%] tests/unit/test_message_studio.py::test_variable_interpolation PASSED [ 75%] tests/unit/test_message_studio.py::test_missing_variables_fallback PASSED [ 78%] tests/unit/test_message_studio.py::test_keyboard_matrix_ordering PASSED [ 81%] tests/unit/test_message_studio.py::test_aiogram_keyboard_generation PASSED [ 84%] tests/unit/test_message_studio.py::test_default_system_templates PASSED [ 87%] tests/unit/test_security.py::test_password_hashing PASSED [ 90%] tests/unit/test_security.py::test_aes_256_gcm_encryption PASSED [ 93%] tests/unit/test_security.py::test_jwt_tokens PASSED [ 96%] tests/unit/test_security.py::test_token_hashing PASSED [100%] =================================== FAILURES =================================== ______________________ test_bot_message_studio_lifecycle _______________________ async_client = db_session = @pytest.mark.asyncio async def test_bot_message_studio_lifecycle(async_client: AsyncClient, db_session: AsyncSession): # 1. Setup User A & Tenant A user_a_email = f"user_studio_{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": "Studio Master"}, ) token_a = resp_a.json()["data"]["access_token"] tenant_resp = await async_client.post( "/api/v1/tenants", headers={"Authorization": f"Bearer {token_a}"}, json={"name": "Studio Tenant", "slug": f"studio-{uuid.uuid4().hex[:6]}"}, ) tenant_id = tenant_resp.json()["data"]["id"] headers_a = { "Authorization": f"Bearer {token_a}", "X-Tenant-ID": str(tenant_id), } # 2. Insert Bot A & Bot B into database for Tenant A bot_a = Bot( tenant_id=uuid.UUID(tenant_id), name="Business Bot A", username=f"biz_bot_a_{uuid.uuid4().hex[:6]}", status="active", default_locale="en", ) bot_b = Bot( tenant_id=uuid.UUID(tenant_id), name="Business Bot B", username=f"biz_bot_b_{uuid.uuid4().hex[:6]}", status="active", default_locale="en", ) db_session.add(bot_a) db_session.add(bot_b) await db_session.commit() await db_session.refresh(bot_a) await db_session.refresh(bot_b) bot_a_id = str(bot_a.id) bot_b_id = str(bot_b.id) # 3. Create a Message Template with Buttons create_payload = { "message_key": "welcome", "title": "Main Welcome Screen", "message_text": "🙏 Welcome, {first_name}!\n\nWelcome to our VIP club. Choose below:", "parse_mode": "HTML", "media_type": "none", "locale": "en", "is_active": True, "is_draft": False, "buttons": [ { "text": "💎 Buy Premium", "button_type": "callback_data", "action_value": "act:buy_premium", "row_position": 0, "column_position": 0, "sort_order": 0, }, { "text": "👤 My Account", "button_type": "callback_data", "action_value": "act:account", "row_position": 1, "column_position": 0, "sort_order": 0, }, { "text": "📞 Support", "button_type": "callback_data", "action_value": "act:support", "row_position": 1, "column_position": 1, "sort_order": 1, }, ], } post_resp = await async_client.post( f"/api/v1/bots/{bot_a_id}/messages", headers=headers_a, json=create_payload, ) assert post_resp.status_code == 201, post_resp.text data = post_resp.json()["data"] template_id = data["id"] assert data["message_key"] == "welcome" assert len(data["buttons"]) == 3 assert data["current_version"] == 1 # 4. Preview Template with Variables preview_resp = await async_client.post( f"/api/v1/bots/{bot_a_id}/messages/{template_id}/preview", headers=headers_a, json={"variables": {"first_name": "Karan"}}, ) assert preview_resp.status_code == 200 p_data = preview_resp.json()["data"] assert "Welcome, Karan!" in p_data["rendered_text"] assert len(p_data["keyboard"]) == 2 # 2 rows # 5. Update Template (creates Version 2) update_payload = { "title": "Updated Welcome Screen", "message_text": "🔥 Hello {first_name}! Welcome to the Updated Experience.", "buttons": [ { "text": "🚀 Get Started", "button_type": "callback_data", "action_value": "act:start", "row_position": 0, "column_position": 0, "sort_order": 0, } ], } patch_resp = await async_client.patch( f"/api/v1/bots/{bot_a_id}/messages/{template_id}", headers=headers_a, json=update_payload, ) assert patch_resp.status_code == 200 patched_data = patch_resp.json()["data"] assert patched_data["current_version"] == 2 > assert len(patched_data["buttons"]) == 1 E AssertionError: assert 3 == 1 E + where 3 = len([{'id': 'aa781589-a23a-455a-9f4b-6cd8f3d1f699', 'text': '💎 Buy Premium', 'button_type': 'callback_data', 'action_value': 'act:buy_premium', ...}, {'id': '8009e04b-5a84-4387-8e28-e2704bf2f68b', 'text': '👤 My Account', 'button_type': 'callback_data', 'action_value': 'act:account', ...}, {'id': 'e152ff91-c21f-471a-885c-2ad108ab8ab6', 'text': '📞 Support', 'button_type': 'callback_data', 'action_value': 'act:support', ...}]) tests/integration/test_message_studio_api.py:137: AssertionError ----------------------------- Captured stdout call ----------------------------- 2026-11-18 06:22:25 [info ] dispatching_domain_event event_id=3df7cf7c-a17f-43ed-85af-4069081c006b event_type=UserRegisteredEvent handlers_count=0 2026-11-18 06:22:25 [info ] dispatching_domain_event event_id=b0a1746f-2604-4488-a12c-f1fdc48f2ff7 event_type=TenantCreatedEvent handlers_count=0 2026-11-18 06:22:25 [warning ] cache_invalidation_failed error='Event loop is closed' =========================== short test summary info ============================ FAILED tests/integration/test_message_studio_api.py::test_bot_message_studio_lifecycle ========================= 1 failed, 32 passed in 2.19s =========================