{"id":"e0e23b6a-290e-4e04-b390-7342253a385c", "recipient":"12fc3f23-17c6-442c-9554-505e87d2791f", "sender":"12fc3f23-17c6-442c-9554-505e87d2791f/task-555", "priority":"MESSAGE_PRIORITY_HIGH", "timestamp":"2026-11-19T05:09:31.778694996Z", "renderDetails":{"messageTitle":"Run modular integration tests finished"}, "content":"Task id \"12fc3f23-17c6-442c-9554-505e87d2791f/task-555\" finished with result:\nThe tool's output was truncated due to being too long. You can find the full output in a file at file:///root/.gemini/antigravity-cli/brain/12fc3f23-17c6-442c-9554-505e87d2791f/.system_generated/steps/555/output.txt.\n\nHere is a preview with the middle of the output truncated:\nCommand exited with code 1.\n\nCommand output:\n============================= test session starts ==============================\r\nplatform linux -- Python 3.12.3, pytest-9.2.0, pluggy-1.7.0 -- /root/telegram-saas/.venv/bin/python3\r\ncachedir: .pytest_cache\r\nrootdir: /root/telegram-saas\r\nconfigfile: pyproject.toml\r\nplugins: anyio-4.16.0, asyncio-1.5.0\r\nasyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function\r\ncollecting ... \rcollected 1 item                                                               \r\n\r\ntests/integration/test_bot_modular_api_and_execution.py::test_bot_modular_api_and_execution_lifecycle FAILED [100%]\r\n\r\n=================================== FAILURES ===================================\r\n_________________ test_bot_modular_api_and_execution_lifecycle _________________\r\n\r\nasync_client = <httpx.AsyncClient object at 0x7d0915a4b740>\r\ndb_session = <sqlalchemy.ext.asyncio.session.AsyncSession object at 0x7d0915aa7d40>\r\n\r\n    @pytest.mark.asyncio\r\n    async def test_bot_modular_api_and_execution_lifecycle(\r\n        async_client: AsyncClient,\r\n        db_session: AsyncSession,\r\n    ):\r\n        # --------------------------------------------------------------------------\r\n        # 1. Setup Tenant, User, and Bot\r\n        # --------------------------------------------------------------------------\r\n        user_email = f\"mod_dev_{uuid.uuid4().hex[:6]}@example.com\"\r\n        reg_resp = await async_client.post(\r\n            \"/api/v1/auth/register\",\r\n            json={\"email\": user_email, \"password\": \"PasswordM123!\", \"full_name\": \"Modular Dev\"},\r\n        )\r\n        user_token = reg_resp.json()[\"data\"][\"access_token\"]\r\n    \r\n        tenant_resp = await async_client.post(\r\n            \"/api/v1/tenants\",\r\n            headers={\"Authorization\": f\"Bearer {user_token}\"},\r\n            json={\"name\": \"Modular Fleet Org\", \"slug\": f\"mod-{uuid.uuid4().hex[:6]}\"},\r\n        )\r\n        tenant_id = uuid.UUID(tenant_resp.json()[\"data\"][\"id\"])\r\n        headers = {\r\n            \"Authorization\": f\"Bearer {user_token}\",\r\n            \"X-Tenant-ID\": str(tenant_id),\r\n        }\r\n    \r\n        # Register Bot\r\n        bot_token = f\"token_modular_{uuid.uuid4().hex[:8]}_test\"\r\n        bot_username = f\"modular_bot_{uuid.uuid4().hex[:6]}\"\r\n        TelegramApiService.register_mock_bot(bot_token, bot_username, \"Modular Bot\")\r\n    \r\n        bot_reg_resp = await async_client.post(\r\n            \"/api/v1/bots\",\r\n            headers=headers,\r\n            json={\"token\": bot_token, \"name\": \"Nexus Modular Bot\", \"default_locale\": \"en\"},\r\n        )\r\n        assert bot_reg_resp.status_code == 201\r\n        bot_data = bot_reg_resp.json()[\"data\"]\r\n        bot_id = uuid.UUID(bot_data[\"id\"])\r\n    \r\n        # --------------------------------------------------------------------------\r\n        # 2. Query Bot Modules API: GET /api/v1/bots/{bot_id}/modules\r\n        # --------------------------------------------------------------------------\r\n        modules_resp = await async_client.get(f\"/api/v1/bots/{bot_id}/modules\", headers=headers)\r\n        assert modules_resp.status_code == 200\r\n        mods = modules_resp.json()[\"data\"]\r\n        assert len(mods) == 11\r\n        assert \"redeem_codes\" in [m[\"id\"] for m in mods]\r\n    \r\n        mod_map = {m[\"id\"]: m for m in mods}\r\n        # Auto-provisioned foundational modules should be active\r\n        assert mod_map[\"welcome_message\"][\"is_enabled\"] is True\r\n        assert mod_map[\"broadcasts\"][\"is_enabled\"] is True\r\n        # Others installed on-demand\r\n        assert mod_map[\"referrals\"][\"is_enabled\"] is False\r\n    \r\n        # --------------------------------------------------------------------------\r\n        # 3. Install & Toggle Modules via API\r\n        # --------------------------------------------------------------------------\r\n        # Activate Referrals\r\n        toggle_ref = await async_client.post(\r\n            f\"/api/v1/bots/{bot_id}/modules/referrals/toggle\",\r\n            headers=headers,\r\n            json={\"is_enabled\": True},\r\n        )\r\n        assert toggle_ref.status_code == 200\r\n        assert toggle_ref.json()[\"data\"][\"is_enabled\"] is True\r\n    \r\n        # Activate Subscriptions\r\n        toggle_sub = await async_client.post(\r\n            f\"/api/v1/bots/{bot_id}/modules/subscriptions/toggle\",\r\n            headers=headers,\r\n            json={\"is_enabled\": True},\r\n        )\r\n        assert toggle_sub.status_code == 200\r\n        assert toggle_sub.json()[\"data\"][\"is_enabled\"] is True\r\n    \r\n        # Update Auto Filter Config & Toggle\r\n        cfg_resp = await async_client.patch(\r\n            f\"/api/v1/bots/{bot_id}/modules/auto_filter/config\",\r\n            headers=headers,\r\n            json={\r\n                \"config\": {\r\n                    \"rules\": [{\"trigger\": \"catalog\", \"match_type\": \"contains\", \"response\": \"📦 120 Products Available in Store.\"}],\r\n                    \"blocked_words\": [\"malw\n<truncated 6194 of 16092 bytes from the middle of the output>\ns,\r\n            json={\r\n                \"update_id\": 10005,\r\n                \"message\": {\r\n                    \"from\": {\"id\": 555222, \"username\": \"promouser\"},\r\n                    \"chat\": {\"id\": 555222},\r\n                    \"text\": \"/redeem PROMO2026\",\r\n                },\r\n            },\r\n        )\r\n        assert resp_redeem.status_code == 200\r\n        sent_redeem = TelegramApiService.get_sent_messages()\r\n        assert len(sent_redeem) >= 1\r\n        assert \"Redemption Successful\" in sent_redeem[-1][\"text\"]\r\n    \r\n        # 5.5 Test 3-Way Trigger Toggle API\r\n        # Turn OFF commands for redeem_codes\r\n        trigger_patch = await async_client.patch(\r\n            f\"/api/v1/bots/{bot_id}/modules/redeem_codes/triggers\",\r\n            headers=headers,\r\n            json={\r\n                \"enable_command\": False,\r\n                \"enable_inline_button\": True,\r\n                \"enable_menu_button\": False,\r\n            },\r\n        )\r\n        assert trigger_patch.status_code == 200\r\n        trigger_data = trigger_patch.json()[\"data\"]\r\n        assert trigger_data[\"enable_command\"] is False\r\n        assert trigger_data[\"enable_inline_button\"] is True\r\n        assert trigger_data[\"enable_menu_button\"] is False\r\n    \r\n        # 5.6 Now sending /redeem should be blocked because enable_command is False\r\n        TelegramApiService.clear_sent_messages()\r\n        resp_redeem_blocked = await async_client.post(\r\n            f\"/webhooks/telegram/{bot_id}\",\r\n            headers=webhook_headers,\r\n            json={\r\n                \"update_id\": 10006,\r\n                \"message\": {\r\n                    \"from\": {\"id\": 555333, \"username\": \"blockeduser\"},\r\n                    \"chat\": {\"id\": 555333},\r\n                    \"text\": \"/redeem PROMO2026\",\r\n                },\r\n            },\r\n        )\r\n        assert resp_redeem_blocked.status_code == 200\r\n        sent_blocked = TelegramApiService.get_sent_messages()\r\n        assert len(sent_blocked) >= 1\r\n>       assert \"command trigger is disabled\" in sent_blocked[-1][\"text\"]\r\nE       AssertionError: assert 'command trigger is disabled' in '⚠️ <i>The command /redeem has been turned off by the bot administrator.</i>'\r\n\r\ntests/integration/test_bot_modular_api_and_execution.py:300: AssertionError\r\n----------------------------- Captured stdout call -----------------------------\r\n2026-11-19 05:09:22 [info     ] dispatching_domain_event       event_id=4d3ddec4-681a-4418-9d82-7ff74d9239d9 event_type=TenantCreatedEvent handlers_count=1\r\n2026-11-19 05:09:22 [info     ] domain_event_recorded          event_id=4d3ddec4-681a-4418-9d82-7ff74d9239d9 event_type=TenantCreatedEvent tenant_id=e15e5290-57c3-407d-9311-e1833682daad user_id=None\r\n2026-11-19 05:09:22 [info     ] dispatching_domain_event       event_id=107d6f21-e2f0-4ab6-b972-b438cc51c346 event_type=UserRegisteredEvent handlers_count=1\r\n2026-11-19 05:09:22 [info     ] domain_event_recorded          event_id=107d6f21-e2f0-4ab6-b972-b438cc51c346 event_type=UserRegisteredEvent tenant_id=None user_id=ae171292-c86b-45ce-a4dc-a0a6be37b216\r\n2026-11-19 05:09:22 [info     ] dispatching_domain_event       event_id=cf050130-0a8a-4817-895c-45da4e298ef5 event_type=TenantCreatedEvent handlers_count=1\r\n2026-11-19 05:09:22 [info     ] domain_event_recorded          event_id=cf050130-0a8a-4817-895c-45da4e298ef5 event_type=TenantCreatedEvent tenant_id=8943e9e9-0bd1-4cae-ac68-21d1a3be0d6c user_id=None\r\n2026-11-19 05:09:22 [info     ] bot_registered_successfully    bot_id=6dbf7417-10ac-49d8-8fe6-dfe6800d5960 tenant_id=8943e9e9-0bd1-4cae-ac68-21d1a3be0d6c username=modular_bot_acd225\r\n2026-11-19 05:09:23 [warning  ] celery_enqueue_fallback_to_sync bot_id=6dbf7417-10ac-49d8-8fe6-dfe6800d5960 error='[Errno 111] Connection refused'\r\n2026-11-19 05:09:24 [warning  ] celery_enqueue_fallback_to_sync bot_id=6dbf7417-10ac-49d8-8fe6-dfe6800d5960 error='[Errno 111] Connection refused'\r\n2026-11-19 05:09:25 [warning  ] celery_enqueue_fallback_to_sync bot_id=6dbf7417-10ac-49d8-8fe6-dfe6800d5960 error='[Errno 111] Connection refused'\r\n2026-11-19 05:09:26 [warning  ] celery_enqueue_fallback_to_sync bot_id=6dbf7417-10ac-49d8-8fe6-dfe6800d5960 error='[Errno 111] Connection refused'\r\n2026-11-19 05:09:27 [warning  ] celery_enqueue_fallback_to_sync bot_id=6dbf7417-10ac-49d8-8fe6-dfe6800d5960 error='[Errno 111] Connection refused'\r\n2026-11-19 05:09:28 [warning  ] celery_enqueue_fallback_to_sync bot_id=6dbf7417-10ac-49d8-8fe6-dfe6800d5960 error='[Errno 111] Connection refused'\r\n------------------------------ Captured log call -------------------------------\r\nWARNING  kombu.connection:connection.py:760 No hostname was supplied. Reverting to default 'localhost'\r\n=========================== short test summary info ============================\r\nFAILED tests/integration/test_bot_modular_api_and_execution.py::test_bot_modular_api_and_execution_lifecycle\r\n============================== 1 failed in 7.12s ===============================\r\n\nLog: file:///root/.gemini/antigravity-cli/brain/12fc3f23-17c6-442c-9554-505e87d2791f/.system_generated/tasks/task-555.log", "sourceMetadata":{"tool":{"conversationId":"12fc3f23-17c6-442c-9554-505e87d2791f", "stepIndex":555, "toolCall":{"id":"call_6531431810456749363", "name":"run_command", "argumentsJson":"{\"CommandLine\":\"/root/telegram-saas/.venv/bin/pytest tests/integration/test_bot_modular_api_and_execution.py -v\",\"WaitMsBeforeAsync\":8000,\"toolSummary\":\"Run modular integration tests\"}", "thinkingSignature":"EvoBCvcBAWkUfRMPq/OAXs+CIPLVG+keq95Y+g4DszSQCuH1ZpcICa9uLLX6cM81OTI4BrB3EqPfnC8DBlks44kpjs1ieQqDMuycRQ2wHPGCp2zG82ol3aa+1ohxLLK7ppnuRq5Q51lyHLzoivAIUCFjSPxm2hdwkHPEitoL+B1LLNwuDBvh74jp8yxR8w+sEwVaVV5hpnA00FxHHW3hwB9XMia2XTfeZefOjLrd+e6EOkz2OaqZTNELY12oXVkvJWf5j4z8XFZD9XJSwqe12ERe7mtJ563u4vthKh613LD6TNoApJxIA7vl7FCW8v71q1INabcNIsi3qQTZvQ=="}}}}