from app.services.agent_asset_spreadsheet import RuleSpreadsheetMeta
from app.services.agent_assets import AgentAssetService


def test_rule_spreadsheet_onlyoffice_key_uses_safe_characters() -> None:
    metadata = RuleSpreadsheetMeta(
        file_name="公司差旅费报销规则.xlsx",
        storage_key="rules/finance-rules/公司差旅费报销规则.xlsx",
        mime_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
        size_bytes=1,
        checksum="abc123",
        updated_at="2026-05-17T14:32:00+00:00",
        updated_by="system",
    )

    key = AgentAssetService._build_onlyoffice_document_key(
        "asset:id",
        metadata,
    )

    assert key == "asset_id-abc123"
    assert ":" not in key
