Add integration tests for deduplication and ref_count

- Add test_integration_uploads.py with 12 tests for duplicate upload scenarios
- Add test_ref_count.py with 7 tests for ref_count management
- Fix ArtifactDetailResponse to include sha256 and checksum fields
- Fix health check SQL warning by wrapping in text()
- Update tests to use unique content per test run for idempotency
This commit is contained in:
Mondo Diaz
2026-01-05 14:29:12 -06:00
parent d2abfe671a
commit 7c31b6a244
5 changed files with 702 additions and 3 deletions

View File

@@ -13,7 +13,7 @@ from fastapi import (
)
from fastapi.responses import StreamingResponse, RedirectResponse
from sqlalchemy.orm import Session
from sqlalchemy import or_, func
from sqlalchemy import or_, func, text
from typing import List, Optional, Literal
import math
import re
@@ -263,7 +263,7 @@ def health_check(
# Check database connectivity
try:
db.execute("SELECT 1")
db.execute(text("SELECT 1"))
database_healthy = True
except Exception as e:
logger.warning(f"Database health check failed: {e}")
@@ -2131,9 +2131,13 @@ def get_artifact(artifact_id: str, db: Session = Depends(get_db)):
return ArtifactDetailResponse(
id=artifact.id,
sha256=artifact.id, # SHA256 hash is the artifact ID
size=artifact.size,
content_type=artifact.content_type,
original_name=artifact.original_name,
checksum_md5=artifact.checksum_md5,
checksum_sha1=artifact.checksum_sha1,
s3_etag=artifact.s3_etag,
created_at=artifact.created_at,
created_by=artifact.created_by,
ref_count=artifact.ref_count,