feat(cv-import): ground reviewed facts in revisioned career profiles
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
from cv_import_ai import ImportAiConfig, analyse
|
||||
|
||||
BLOCKS = [{"id": "b0001", "text": "Engineer at Example AS, 2020. Python.", "kind": "paragraph", "page": 1}]
|
||||
|
||||
|
||||
def test_disabled_adapter_never_invokes_transport():
|
||||
def forbidden(*args):
|
||||
raise AssertionError("Disabled inference invoked")
|
||||
assert analyse(BLOCKS, ImportAiConfig(), forbidden) == []
|
||||
|
||||
|
||||
def test_grounded_suggestion_is_explicitly_unverified_model_output():
|
||||
result = analyse(BLOCKS, ImportAiConfig(enabled=True, model="test-double"), lambda *_: json.dumps({"suggestions": [{"field": "skills.0", "value": "Python", "block_id": "b0001", "quote": "Python"}]}))
|
||||
assert result[0]["method"] == "model-assisted"
|
||||
assert result[0]["review_state"] == "needs_review"
|
||||
assert "confidence" not in result[0]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("suggestion", [
|
||||
{"field": "jobs.0.start", "value": "2020-01", "block_id": "b0001", "quote": "2020"},
|
||||
{"field": "education.0.qualification", "value": "PhD", "block_id": "b0001", "quote": "Python"},
|
||||
{"field": "metadata.owner", "value": "Python", "block_id": "b0001", "quote": "Python"},
|
||||
{"field": "skills.0", "value": "Python", "block_id": "missing", "quote": "Python"},
|
||||
{"field": "skills.0", "value": "Python", "block_id": "b0001", "quote": "Python", "confidence": 100},
|
||||
])
|
||||
def test_invalid_or_unsupported_suggestions_fail_closed(suggestion):
|
||||
with pytest.raises(ValueError):
|
||||
analyse(BLOCKS, ImportAiConfig(enabled=True, model="test-double"), lambda *_: json.dumps({"suggestions": [suggestion]}))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("url", ["https://external.example.test", "http://169.254.169.254", "file:///etc/passwd", "http://user:pass@localhost:11434"])
|
||||
def test_provider_configuration_refuses_external_or_unsafe_destinations(url):
|
||||
with pytest.raises(ValueError):
|
||||
analyse(BLOCKS, ImportAiConfig(enabled=True, model="test-double", base_url=url), lambda *_: '{"suggestions":[]}')
|
||||
Reference in New Issue
Block a user