gateway/tests/functional/test_kpi_path.py
ValueOn AG c8b7517209 refactor: modules/services/ abgeloest durch serviceCenter + serviceHub
serviceCenter = DI-Container (Resolver, Registry, Context) fuer Service-Instanziierung
serviceHub = Consumer-facing Aggregation (DB-Interfaces, Runtime-State, lazy Service-Resolution via serviceCenter)

- modules/serviceHub/ erstellt: ServiceHub, PublicService, getInterface()
- 22 Consumer-Dateien migriert (routes, features, tests): imports von modules.services auf serviceHub bzw. serviceCenter umgestellt
- resolver.py: legacy fallback auf altes services/ entfernt
- modules/services/ komplett geloescht (83 Dateien inkl. dead code mainAiChat.py)
- pre-extraction: progress callback durch chunk-pipeline propagiert, operationType DATA_EXTRACT->DATA_ANALYSE fuer guenstigeres Modell
2026-03-14 11:51:45 +01:00

68 lines
1.9 KiB
Python

# Copyright (c) 2025 Patrick Motsch
# All rights reserved.
"""Test KPI path extraction"""
import json
import sys
import os
# Add gateway directory to path
_gateway_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
if _gateway_path not in sys.path:
sys.path.insert(0, _gateway_path)
from modules.serviceCenter.services.serviceAi.subJsonResponseHandling import JsonResponseHandler
# Test JSON matching the actual response
test_json = {
"metadata": {
"split_strategy": "single_document",
"source_documents": [],
"extraction_method": "ai_generation"
},
"documents": [
{
"id": "doc_1",
"title": "Prime Numbers Table",
"filename": "prime_numbers.json",
"sections": [
{
"id": "section_prime_numbers_table",
"content_type": "table",
"elements": [
{
"headers": ["Column 1", "Column 2"],
"rows": [
[2, 3, 5, 7, 11],
[13, 17, 19, 23, 29]
]
}
]
}
]
}
]
}
# Test path from KPI definition
path = "documents[0].sections[0].elements[0].rows"
print(f"Testing path: {path}")
print(f"JSON structure: documents[0].sections[0].elements[0].rows")
print()
try:
value = JsonResponseHandler._extractValueByPath(test_json, path)
print(f"✅ Extracted value: {type(value)}")
print(f" Value: {value}")
if isinstance(value, list):
count = len(value)
print(f" Count: {count}")
else:
print(f" Not a list!")
except Exception as e:
print(f"❌ Error: {e}")
import traceback
traceback.print_exc()