Builds PaperTrail from the base skeleton into a full evidence-verification platform for the "Built with Claude: Life Sciences" hackathon (Builder Track). New named-user features (Build Beyond the Bench): - Lab Notebook Companion — rough bench notes -> structured, searchable, grounded experiment records (lib/labNotebook, /console/lab-notebook, migration 0059) - Clinical Trial Matcher — de-identified patient notes -> ranked eligible ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning (lib/trialMatcher, /console/trial-matcher, migrations 0060) Platform: - Deterministic verification moat (biostats recompute, exact-span grounding) - 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar, PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier) - Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise governance (RBAC, /api/v1 gateway, metering, audit chain, retention) - 17 OSS projects assimilated into native TypeScript on our stack (backend/engines retained + credited in NOTICE) - Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site - Next.js 16 upgrade, benchmark harness (honest smoke-test caveat) Licensing: Apache-2.0 (LICENSE + NOTICE).
61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
import pytest
|
|
from unittest.mock import AsyncMock
|
|
from fastapi import WebSocket
|
|
from backend.server.server_utils import CustomLogsHandler
|
|
import os
|
|
import json
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_custom_logs_handler():
|
|
# Mock websocket
|
|
mock_websocket = AsyncMock()
|
|
mock_websocket.send_json = AsyncMock()
|
|
|
|
# Test initialization
|
|
handler = CustomLogsHandler(mock_websocket, "test_query")
|
|
|
|
# Verify log file creation
|
|
assert os.path.exists(handler.log_file)
|
|
|
|
# Test sending log data
|
|
test_data = {
|
|
"type": "logs",
|
|
"message": "Test log message"
|
|
}
|
|
|
|
await handler.send_json(test_data)
|
|
|
|
# Verify websocket was called with correct data
|
|
mock_websocket.send_json.assert_called_once_with(test_data)
|
|
|
|
# Verify log file contents
|
|
with open(handler.log_file, 'r') as f:
|
|
log_data = json.load(f)
|
|
assert len(log_data['events']) == 1
|
|
assert log_data['events'][0]['data'] == test_data
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_content_update():
|
|
"""Test handling of non-log type data that updates content"""
|
|
mock_websocket = AsyncMock()
|
|
mock_websocket.send_json = AsyncMock()
|
|
|
|
handler = CustomLogsHandler(mock_websocket, "test_query")
|
|
|
|
# Test content update
|
|
content_data = {
|
|
"query": "test query",
|
|
"sources": ["source1", "source2"],
|
|
"report": "test report"
|
|
}
|
|
|
|
await handler.send_json(content_data)
|
|
|
|
mock_websocket.send_json.assert_called_once_with(content_data)
|
|
|
|
# Verify log file contents
|
|
with open(handler.log_file, 'r') as f:
|
|
log_data = json.load(f)
|
|
assert log_data['content']['query'] == "test query"
|
|
assert log_data['content']['sources'] == ["source1", "source2"]
|
|
assert log_data['content']['report'] == "test report" |