Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s
72 lines
1.9 KiB
Python
72 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Ownership-boundary tests for the global chat API."""
|
|
|
|
from types import SimpleNamespace
|
|
from unittest.mock import AsyncMock
|
|
|
|
import pytest
|
|
from fastapi import HTTPException
|
|
|
|
from qwenpaw.app.chats.api import get_chat, list_chats
|
|
from qwenpaw.app.chats.models import ChatSpec
|
|
|
|
|
|
def _chat(chat_id: str, *, app_id: str | None = None) -> ChatSpec:
|
|
meta = (
|
|
{
|
|
"pawapp": {
|
|
"app_id": app_id,
|
|
"agent_id": "datapaw",
|
|
},
|
|
}
|
|
if app_id
|
|
else {}
|
|
)
|
|
return ChatSpec(
|
|
id=chat_id,
|
|
session_id=f"console:{chat_id}",
|
|
user_id="default",
|
|
channel="console",
|
|
meta=meta,
|
|
)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_chats_can_exclude_app_owned_dialogues():
|
|
normal = _chat("normal")
|
|
app_owned = _chat("app-owned", app_id="datapaw")
|
|
manager = SimpleNamespace(
|
|
list_chats=AsyncMock(return_value=[normal, app_owned]),
|
|
)
|
|
tracker = SimpleNamespace(get_status=AsyncMock(return_value="idle"))
|
|
|
|
result = await list_chats(
|
|
user_id=None,
|
|
channel=None,
|
|
archived=False,
|
|
include_app_owned=False,
|
|
mgr=manager,
|
|
workspace=SimpleNamespace(task_tracker=tracker),
|
|
)
|
|
|
|
assert [chat.id for chat in result] == ["normal"]
|
|
tracker.get_status.assert_awaited_once_with("normal")
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_chat_hides_app_owned_dialogue_when_caller_opts_out():
|
|
manager = SimpleNamespace(
|
|
get_chat=AsyncMock(return_value=_chat("app-owned", app_id="datapaw")),
|
|
)
|
|
|
|
with pytest.raises(HTTPException) as raised:
|
|
await get_chat(
|
|
chat_id="app-owned",
|
|
include_app_owned=False,
|
|
mgr=manager,
|
|
session=SimpleNamespace(),
|
|
workspace=SimpleNamespace(),
|
|
)
|
|
|
|
assert raised.value.status_code == 404
|