...FF.                                                                   [100%]
=================================== FAILURES ===================================
___________ test_sales_internal_telegram_sync_auto_creates_workspace ___________

    def test_sales_internal_telegram_sync_auto_creates_workspace():
        client = TestClient(sales_module.app)
    
        response = client.post(
            "/internal/sales-sync/telegram",
            json={
                "thread_id": "tg-thread-auto-01",
                "chat_id": "tg-chat-auto-01",
                "interaction_id": "int_tg_auto_01",
                "phone_number": "+77005550101",
                "display_name": "Telegram Prospect",
                "queue_id": "q_sales",
                "status": "new",
                "ai_state": "queued",
                "message_id": "msg_tg_auto_01",
                "external_message_id": "ext_tg_auto_01",
                "text": "Здравствуйте, нужен расчет и коммерческое предложение.",
                "direction": "inbound",
                "author_type": "customer",
                "author_id": "tg-user-01",
                "metadata": {"username": "sales_prospect"},
            },
            headers=_headers(),
        )
    
        assert response.status_code == 200
        workspace = response.json()
        assert workspace["deal"]["current_channel"] == "telegram"
        assert workspace["deal"]["preferred_channel"] == "telegram"
>       assert workspace["communications"][0]["channel_provider"] == "telegram"
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       KeyError: 'channel_provider'

tests/test_sales_service.py:220: KeyError
__________ test_sales_internal_voice_sync_creates_call_and_transcript __________

    def test_sales_internal_voice_sync_creates_call_and_transcript():
        client = TestClient(sales_module.app)
    
        response = client.post(
            "/internal/sales-sync/voice",
            json={
                "call_id": "call-auto-voice-01",
                "interaction_id": "int_voice_auto_01",
                "queue_id": "q_voice_sales",
                "queue_code": "voice_sales",
                "caller_number": "+77005550202",
                "caller_name": "Voice Prospect",
                "voice_session_id": "avs_auto_01",
                "ai_session_id": "ais_auto_01",
                "ai_state": "completed",
                "telephony_status": "ended",
                "call_status": "completed",
                "started_at": "2026-05-08T10:00:00Z",
                "ended_at": "2026-05-08T10:03:00Z",
                "summary": "Клиент запросил прайс и условия подключения.",
                "transcript_text": "customer: Добрый день, нужен прайс.\nassistant: Подготовлю информацию.",
                "metadata": {"agent_profile": "voice_sales"},
            },
            headers=_headers(),
        )
    
        assert response.status_code == 200
        workspace = response.json()
        assert workspace["deal"]["current_channel"] == "voice"
        assert workspace["communications"][0]["channel_type"] == "voice"
        assert workspace["communications"][0]["metadata"]["voice_session_id"] == "avs_auto_01"
        assert workspace["calls"][0]["external_call_id"] == "call-auto-voice-01"
>       assert workspace["transcripts"][0]["transcript_text"].startswith("customer:")
               ^^^^^^^^^^^^^^^^^^^^^^^^
E       KeyError: 'transcripts'

tests/test_sales_service.py:257: KeyError
=============================== warnings summary ===============================
tests/test_sales_service.py::test_sales_lead_creation_auto_creates_deal_and_workspace
  /Users/magzhanzhumabayev/Desktop/projects/kazakhtelecom/telecom-crm/call-center/services/telegram_adapter_service/app.py:1493: DeprecationWarning: 
          on_event is deprecated, use lifespan event handlers instead.
  
          Read more about it in the
          [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
          
    @app.on_event("startup")

tests/test_sales_service.py::test_sales_lead_creation_auto_creates_deal_and_workspace
tests/test_sales_service.py::test_sales_lead_creation_auto_creates_deal_and_workspace
tests/test_sales_service.py::test_sales_lead_creation_auto_creates_deal_and_workspace
tests/test_sales_service.py::test_sales_lead_creation_auto_creates_deal_and_workspace
  /Users/magzhanzhumabayev/Desktop/projects/kazakhtelecom/telecom-crm/call-center/.venv/lib/python3.11/site-packages/fastapi/applications.py:4495: DeprecationWarning: 
          on_event is deprecated, use lifespan event handlers instead.
  
          Read more about it in the
          [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
          
    return self.router.on_event(event_type)

tests/test_sales_service.py::test_sales_lead_creation_auto_creates_deal_and_workspace
  /Users/magzhanzhumabayev/Desktop/projects/kazakhtelecom/telecom-crm/call-center/services/telegram_adapter_service/app.py:1498: DeprecationWarning: 
          on_event is deprecated, use lifespan event handlers instead.
  
          Read more about it in the
          [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
          
    @app.on_event("shutdown")

tests/test_sales_service.py::test_sales_lead_creation_auto_creates_deal_and_workspace
  /Users/magzhanzhumabayev/Desktop/projects/kazakhtelecom/telecom-crm/call-center/services/asterisk_bridge_service/app.py:507: DeprecationWarning: 
          on_event is deprecated, use lifespan event handlers instead.
  
          Read more about it in the
          [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
          
    @app.on_event("startup")

tests/test_sales_service.py::test_sales_lead_creation_auto_creates_deal_and_workspace
  /Users/magzhanzhumabayev/Desktop/projects/kazakhtelecom/telecom-crm/call-center/services/asterisk_bridge_service/app.py:512: DeprecationWarning: 
          on_event is deprecated, use lifespan event handlers instead.
  
          Read more about it in the
          [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
          
    @app.on_event("shutdown")

tests/test_sales_service.py::test_sales_lead_creation_auto_creates_deal_and_workspace
  /Users/magzhanzhumabayev/Desktop/projects/kazakhtelecom/telecom-crm/call-center/services/shared/audioop_compat.py:8: DeprecationWarning: 'audioop' is deprecated and slated for removal in Python 3.13
    import audioop as _audioop

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_sales_service.py::test_sales_internal_telegram_sync_auto_creates_workspace
FAILED tests/test_sales_service.py::test_sales_internal_voice_sync_creates_call_and_transcript

EXIT_STATUS=1
