New router intelligence modules (26 files): alert_ingest/store, audit_store, architecture_pressure, backlog_generator/store, cost_analyzer, data_governance, dependency_scanner, drift_analyzer, incident_* (5 files), llm_enrichment, platform_priority_digest, provider_budget, release_check_runner, risk_* (6 files), signature_state_store, sofiia_auto_router, tool_governance New services: - sofiia-console: Dockerfile, adapters/, monitor/nodes/ops/voice modules, launchd, react static - memory-service: integration_endpoints, integrations, voice_endpoints, static UI - aurora-service: full app suite (analysis, job_store, orchestrator, reporting, schemas, subagents) - sofiia-supervisor: new supervisor service - aistalk-bridge-lite: Telegram bridge lite - calendar-service: CalDAV calendar service with reminders - mlx-stt-service / mlx-tts-service: Apple Silicon speech services - binance-bot-monitor: market monitor service - node-worker: STT/TTS memory providers New tools (9): agent_email, browser_tool, contract_tool, observability_tool, oncall_tool, pr_reviewer_tool, repo_tool, safe_code_executor, secure_vault New crews: agromatrix_crew (10 modules: depth_classifier, doc_facts, doc_focus, farm_state, light_reply, llm_factory, memory_manager, proactivity, reflection_engine, session_context, style_adapter, telemetry) Tests: 85+ test files for all new modules Made-with: Cursor
63 lines
2.2 KiB
Python
63 lines
2.2 KiB
Python
"""Tests for doc_facts.extract_doc_facts — rule-based number extraction."""
|
||
import sys
|
||
import os
|
||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
||
|
||
from crews.agromatrix_crew.doc_facts import extract_doc_facts
|
||
|
||
|
||
def test_profit_uah():
|
||
text = "У звіті є прибуток — 5 972 016 грн."
|
||
facts = extract_doc_facts(text)
|
||
assert "profit_uah" in facts, f"Expected profit_uah, got {facts}"
|
||
assert abs(facts["profit_uah"] - 5972016) < 1
|
||
|
||
|
||
def test_fertilizer_uah():
|
||
text = "Загальні витрати на добрива складають 1 521 084 грн на 497 га."
|
||
facts = extract_doc_facts(text)
|
||
assert "fertilizer_uah" in facts, f"Expected fertilizer_uah, got {facts}"
|
||
assert abs(facts["fertilizer_uah"] - 1521084) < 1
|
||
|
||
|
||
def test_area_ha():
|
||
text = "Загальна площа обробки — 497 гектарів."
|
||
facts = extract_doc_facts(text)
|
||
assert "area_ha" in facts, f"Expected area_ha, got {facts}"
|
||
assert abs(facts["area_ha"] - 497) < 0.5
|
||
|
||
|
||
def test_profit_per_ha():
|
||
text = "Прибуток на гектар: 12 016.13 грн/га."
|
||
facts = extract_doc_facts(text)
|
||
assert "profit_uah_per_ha" in facts, f"Expected profit_uah_per_ha, got {facts}"
|
||
assert abs(facts["profit_uah_per_ha"] - 12016.13) < 1
|
||
|
||
|
||
def test_total_cost():
|
||
text = "Загальні витрати на виробництво — 9 684 737 гривень."
|
||
facts = extract_doc_facts(text)
|
||
assert "cost_total_uah" in facts, f"Expected cost_total_uah, got {facts}"
|
||
assert abs(facts["cost_total_uah"] - 9684737) < 1
|
||
|
||
|
||
def test_multiple_facts():
|
||
text = (
|
||
"Площа — 497 га. Прибуток — 5 972 016 грн. "
|
||
"Витрати на добрива 1 521 084 грн. Прибуток: 12 016.13 грн/га."
|
||
)
|
||
facts = extract_doc_facts(text)
|
||
assert "area_ha" in facts
|
||
assert "profit_uah" in facts
|
||
assert "fertilizer_uah" in facts
|
||
|
||
|
||
def test_empty_text():
|
||
assert extract_doc_facts("") == {}
|
||
assert extract_doc_facts(None) == {}
|
||
|
||
|
||
def test_no_numbers():
|
||
facts = extract_doc_facts("Документ містить лише текстовий опис без цифр.")
|
||
assert facts == {}
|