Files
wehub-resource-sync 7a0da7932b
Backwards Compatibility / Verify Encryption Constants (push) Waiting to run
Backwards Compatibility / PyPI Version Compatibility (push) Waiting to run
Backwards Compatibility / Database Migration Tests (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Blocked by required conditions
Docker Tests (Consolidated) / detect-changes (push) Waiting to run
Docker Tests (Consolidated) / Build Test Image (push) Waiting to run
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Blocked by required conditions
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Blocked by required conditions
Docker Tests (Consolidated) / Accessibility Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Unit Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / LLM Example Tests (push) Blocked by required conditions
Docker Tests (Consolidated) / Production Image Smoke Test (push) Blocked by required conditions
Docker Tests (Consolidated) / Infrastructure Tests (push) Blocked by required conditions
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Waiting to run
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:08:55 +08:00

121 lines
3.1 KiB
Python

"""
Fixtures for library API tests.
Provides test data and helpers for testing library/collection/RAG endpoints.
"""
import hashlib
import uuid
import pytest
from local_deep_research.database.models.library import (
DocumentStatus,
)
@pytest.fixture
def sample_source_type_data():
"""Sample source type data for test documents."""
return {
"id": str(uuid.uuid4()),
"name": "test_upload",
"display_name": "Test Upload",
"description": "Test documents for API tests",
"icon": "fas fa-file",
}
@pytest.fixture
def sample_collection_data():
"""Sample collection data for tests."""
return {
"name": f"Test Collection {uuid.uuid4().hex[:8]}",
"description": "A test collection for API tests",
"type": "user_uploads",
}
@pytest.fixture
def sample_document_data():
"""Sample document data for tests."""
content = "This is sample text content for testing API endpoints."
return {
"id": str(uuid.uuid4()),
"document_hash": hashlib.sha256(content.encode()).hexdigest(),
"file_size": len(content),
"file_type": "text",
"text_content": content,
"title": "Test Document for API",
"status": DocumentStatus.COMPLETED,
}
def create_test_collection(client, name=None, description=None):
"""
Helper to create a collection via API.
Args:
client: Flask test client (authenticated)
name: Collection name (optional, auto-generated if not provided)
description: Collection description (optional)
Returns:
dict: Created collection data or None if failed
"""
payload = {
"name": name or f"Test Collection {uuid.uuid4().hex[:8]}",
"description": description or "Test collection",
"type": "user_uploads",
}
response = client.post(
"/library/api/collections",
json=payload,
content_type="application/json",
)
if response.status_code == 200:
data = response.get_json()
if data.get("success"):
return data.get("collection")
return None
def delete_test_collection(client, collection_id):
"""
Helper to delete a collection via API.
Args:
client: Flask test client (authenticated)
collection_id: ID of collection to delete
Returns:
bool: True if deleted successfully
"""
response = client.delete(f"/library/api/collections/{collection_id}")
return response.status_code == 200
@pytest.fixture
def create_collection_helper(authenticated_client):
"""Fixture that returns a helper function to create collections."""
created_collections = []
def _create(name=None, description=None):
collection = create_test_collection(
authenticated_client, name, description
)
if collection:
created_collections.append(collection["id"])
return collection
yield _create
# Cleanup: delete all created collections
for coll_id in created_collections:
try:
delete_test_collection(authenticated_client, coll_id)
except Exception:
pass