Cleanup: Delete ALL 242 shims, update ALL consumer imports
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 41s
CI / test-go-edu-search (push) Successful in 32s
CI / test-python-klausur (push) Failing after 2m41s
CI / test-python-agent-core (push) Successful in 34s
CI / test-nodejs-website (push) Successful in 39s

klausur-service: 183 shims deleted, 26 test files + 8 source files updated
backend-lehrer: 59 shims deleted, main.py + 8 source files updated

All imports now use the new package paths directly.
Zero shims remaining in the entire codebase.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-04-26 00:11:33 +02:00
parent d093a4d388
commit 5f2ed44654
288 changed files with 214 additions and 1182 deletions

View File

@@ -124,8 +124,8 @@ class TestSessionCreation:
@pytest.mark.asyncio
async def test_create_session_success(self, mock_db_pool):
"""Test successful session creation."""
from ocr_labeling_api import SessionCreate
from metrics_db import create_ocr_labeling_session
from ocr.labeling.api import SessionCreate
from metrics.db import create_ocr_labeling_session
pool, conn = mock_db_pool
conn.execute.return_value = None
@@ -144,7 +144,7 @@ class TestSessionCreation:
def test_session_create_model_validation(self):
"""Test SessionCreate model validation."""
from ocr_labeling_api import SessionCreate
from ocr.labeling.api import SessionCreate
# Valid session
session = SessionCreate(
@@ -158,7 +158,7 @@ class TestSessionCreation:
def test_session_create_with_custom_model(self):
"""Test SessionCreate with custom OCR model."""
from ocr_labeling_api import SessionCreate
from ocr.labeling.api import SessionCreate
session = SessionCreate(
name="TrOCR Session",
@@ -174,7 +174,7 @@ class TestSessionListing:
@pytest.mark.asyncio
async def test_get_sessions_empty(self):
"""Test getting sessions when none exist."""
from metrics_db import get_ocr_labeling_sessions
from metrics.db import get_ocr_labeling_sessions
with patch('metrics_db.get_pool', new_callable=AsyncMock, return_value=None):
sessions = await get_ocr_labeling_sessions()
@@ -183,7 +183,7 @@ class TestSessionListing:
@pytest.mark.asyncio
async def test_get_session_not_found(self):
"""Test getting a non-existent session."""
from metrics_db import get_ocr_labeling_session
from metrics.db import get_ocr_labeling_session
with patch('metrics_db.get_pool', new_callable=AsyncMock, return_value=None):
session = await get_ocr_labeling_session("non-existent-id")
@@ -199,7 +199,7 @@ class TestImageUpload:
def test_compute_image_hash(self):
"""Test image hash computation."""
from ocr_labeling_api import compute_image_hash
from ocr.labeling.api import compute_image_hash
image_data = b"\x89PNG fake image data"
hash1 = compute_image_hash(image_data)
@@ -211,7 +211,7 @@ class TestImageUpload:
def test_compute_image_hash_different_data(self):
"""Test that different images produce different hashes."""
from ocr_labeling_api import compute_image_hash
from ocr.labeling.api import compute_image_hash
hash1 = compute_image_hash(b"image 1 data")
hash2 = compute_image_hash(b"image 2 data")
@@ -220,11 +220,11 @@ class TestImageUpload:
def test_save_image_locally(self, tmp_path):
"""Test local image saving."""
from ocr_labeling_api import save_image_locally, LOCAL_STORAGE_PATH
from ocr.labeling.api import save_image_locally, LOCAL_STORAGE_PATH
# Temporarily override storage path
with patch('ocr_labeling_api.LOCAL_STORAGE_PATH', str(tmp_path)):
from ocr_labeling_api import save_image_locally
from ocr.labeling.api import save_image_locally
image_data = b"\x89PNG fake image data"
filepath = save_image_locally(
@@ -241,7 +241,7 @@ class TestImageUpload:
def test_get_image_url_local(self):
"""Test URL generation for local images."""
from ocr_labeling_api import get_image_url, LOCAL_STORAGE_PATH
from ocr.labeling.api import get_image_url, LOCAL_STORAGE_PATH
local_path = f"{LOCAL_STORAGE_PATH}/session-123/item-456.png"
url = get_image_url(local_path)
@@ -250,7 +250,7 @@ class TestImageUpload:
def test_get_image_url_minio(self):
"""Test URL for MinIO images (passthrough)."""
from ocr_labeling_api import get_image_url
from ocr.labeling.api import get_image_url
minio_path = "ocr-labeling/session-123/item-456.png"
url = get_image_url(minio_path)
@@ -269,7 +269,7 @@ class TestConfirmLabel:
@pytest.mark.asyncio
async def test_confirm_label_success(self, mock_db_pool):
"""Test successful label confirmation."""
from metrics_db import confirm_ocr_label
from metrics.db import confirm_ocr_label
pool, conn = mock_db_pool
conn.fetchrow.return_value = {"ocr_text": "Test text"}
@@ -287,7 +287,7 @@ class TestConfirmLabel:
def test_confirm_request_validation(self):
"""Test ConfirmRequest model validation."""
from ocr_labeling_api import ConfirmRequest
from ocr.labeling.api import ConfirmRequest
request = ConfirmRequest(
item_id="item-456",
@@ -303,7 +303,7 @@ class TestCorrectLabel:
@pytest.mark.asyncio
async def test_correct_label_success(self, mock_db_pool):
"""Test successful label correction."""
from metrics_db import correct_ocr_label
from metrics.db import correct_ocr_label
pool, conn = mock_db_pool
conn.execute.return_value = None
@@ -321,7 +321,7 @@ class TestCorrectLabel:
def test_correct_request_validation(self):
"""Test CorrectRequest model validation."""
from ocr_labeling_api import CorrectRequest
from ocr.labeling.api import CorrectRequest
request = CorrectRequest(
item_id="item-456",
@@ -338,7 +338,7 @@ class TestSkipItem:
@pytest.mark.asyncio
async def test_skip_item_success(self, mock_db_pool):
"""Test successful item skip."""
from metrics_db import skip_ocr_item
from metrics.db import skip_ocr_item
pool, conn = mock_db_pool
conn.execute.return_value = None
@@ -363,7 +363,7 @@ class TestLabelingStats:
@pytest.mark.asyncio
async def test_get_stats_no_db(self):
"""Test stats when database is not available."""
from metrics_db import get_ocr_labeling_stats
from metrics.db import get_ocr_labeling_stats
with patch('metrics_db.get_pool', new_callable=AsyncMock, return_value=None):
stats = await get_ocr_labeling_stats()
@@ -371,7 +371,7 @@ class TestLabelingStats:
def test_stats_response_model(self):
"""Test StatsResponse model structure."""
from ocr_labeling_api import StatsResponse
from ocr.labeling.api import StatsResponse
stats = StatsResponse(
total_items=100,
@@ -395,7 +395,7 @@ class TestTrainingExport:
def test_export_request_validation(self):
"""Test ExportRequest model validation."""
from ocr_labeling_api import ExportRequest
from ocr.labeling.api import ExportRequest
# Default format is generic
request = ExportRequest()
@@ -412,7 +412,7 @@ class TestTrainingExport:
@pytest.mark.asyncio
async def test_export_training_samples(self, mock_db_pool):
"""Test training sample export from database."""
from metrics_db import export_training_samples
from metrics.db import export_training_samples
pool, conn = mock_db_pool
conn.fetch.return_value = [
@@ -495,7 +495,7 @@ class TestOCRProcessing:
@pytest.mark.asyncio
async def test_run_ocr_on_image_no_service(self):
"""Test OCR when service is not available."""
from ocr_labeling_api import run_ocr_on_image
from ocr.labeling.api import run_ocr_on_image
with patch('ocr_labeling_api.VISION_OCR_AVAILABLE', False), \
patch('ocr_labeling_api.PADDLEOCR_AVAILABLE', False), \
@@ -512,7 +512,7 @@ class TestOCRProcessing:
@pytest.mark.asyncio
async def test_run_ocr_on_image_success(self, mock_vision_ocr):
"""Test successful OCR processing."""
from ocr_labeling_api import run_ocr_on_image
from ocr.labeling.api import run_ocr_on_image
text, confidence = await run_ocr_on_image(
image_data=b"fake image",
@@ -533,7 +533,7 @@ class TestOCRModelDispatcher:
@pytest.mark.asyncio
async def test_dispatcher_vision_model_default(self, mock_vision_ocr):
"""Test dispatcher uses Vision OCR by default."""
from ocr_labeling_api import run_ocr_on_image
from ocr.labeling.api import run_ocr_on_image
text, confidence = await run_ocr_on_image(
image_data=b"fake image",
@@ -547,7 +547,7 @@ class TestOCRModelDispatcher:
@pytest.mark.asyncio
async def test_dispatcher_paddleocr_model(self):
"""Test dispatcher routes to PaddleOCR."""
from ocr_labeling_api import run_ocr_on_image
from ocr.labeling.api import run_ocr_on_image
# Mock PaddleOCR
mock_regions = []
@@ -567,7 +567,7 @@ class TestOCRModelDispatcher:
@pytest.mark.asyncio
async def test_dispatcher_paddleocr_fallback_to_vision(self, mock_vision_ocr):
"""Test PaddleOCR falls back to Vision OCR when unavailable."""
from ocr_labeling_api import run_ocr_on_image
from ocr.labeling.api import run_ocr_on_image
with patch('ocr_labeling_api.PADDLEOCR_AVAILABLE', False):
text, confidence = await run_ocr_on_image(
@@ -583,7 +583,7 @@ class TestOCRModelDispatcher:
@pytest.mark.asyncio
async def test_dispatcher_trocr_model(self):
"""Test dispatcher routes to TrOCR."""
from ocr_labeling_api import run_ocr_on_image
from ocr.labeling.api import run_ocr_on_image
async def mock_trocr(image_data):
return "TrOCR erkannter Text", 0.85
@@ -603,7 +603,7 @@ class TestOCRModelDispatcher:
@pytest.mark.asyncio
async def test_dispatcher_donut_model(self):
"""Test dispatcher routes to Donut."""
from ocr_labeling_api import run_ocr_on_image
from ocr.labeling.api import run_ocr_on_image
async def mock_donut(image_data):
return "Donut erkannter Text", 0.80
@@ -623,7 +623,7 @@ class TestOCRModelDispatcher:
@pytest.mark.asyncio
async def test_dispatcher_unknown_model_uses_vision(self, mock_vision_ocr):
"""Test dispatcher uses Vision OCR for unknown models."""
from ocr_labeling_api import run_ocr_on_image
from ocr.labeling.api import run_ocr_on_image
text, confidence = await run_ocr_on_image(
image_data=b"fake image",
@@ -641,7 +641,7 @@ class TestOCRModelTypes:
def test_session_with_paddleocr_model(self):
"""Test session creation with PaddleOCR model."""
from ocr_labeling_api import SessionCreate
from ocr.labeling.api import SessionCreate
session = SessionCreate(
name="PaddleOCR Session",
@@ -653,7 +653,7 @@ class TestOCRModelTypes:
def test_session_with_donut_model(self):
"""Test session creation with Donut model."""
from ocr_labeling_api import SessionCreate
from ocr.labeling.api import SessionCreate
session = SessionCreate(
name="Donut Session",
@@ -665,7 +665,7 @@ class TestOCRModelTypes:
def test_session_with_trocr_model(self):
"""Test session creation with TrOCR model."""
from ocr_labeling_api import SessionCreate
from ocr.labeling.api import SessionCreate
session = SessionCreate(
name="TrOCR Session",
@@ -685,7 +685,7 @@ class TestResponseModels:
def test_session_response_model(self):
"""Test SessionResponse model."""
from ocr_labeling_api import SessionResponse
from ocr.labeling.api import SessionResponse
session = SessionResponse(
id="session-123",
@@ -706,7 +706,7 @@ class TestResponseModels:
def test_item_response_model(self):
"""Test ItemResponse model."""
from ocr_labeling_api import ItemResponse
from ocr.labeling.api import ItemResponse
item = ItemResponse(
id="item-456",
@@ -735,7 +735,7 @@ class TestDeduplication:
def test_hash_based_deduplication(self):
"""Test that same images produce same hash for deduplication."""
from ocr_labeling_api import compute_image_hash
from ocr.labeling.api import compute_image_hash
# Same content should be detected as duplicate
image1 = b"\x89PNG\x0d\x0a\x1a\x0a test image content"
@@ -748,7 +748,7 @@ class TestDeduplication:
def test_unique_images_different_hash(self):
"""Test that different images produce different hashes."""
from ocr_labeling_api import compute_image_hash
from ocr.labeling.api import compute_image_hash
image1 = b"\x89PNG unique content 1"
image2 = b"\x89PNG unique content 2"