45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
from reuse_surface.interactive import NonInteractiveError, format_patch_summary, prompt_batch
|
||
|
|
|
||
|
|
|
||
|
|
def test_format_patch_summary():
|
||
|
|
text = format_patch_summary(
|
||
|
|
{
|
||
|
|
"capability_id": "capability.demo.sample",
|
||
|
|
"kind": "vector_sync",
|
||
|
|
"confidence": "high",
|
||
|
|
"rationale": "drift",
|
||
|
|
"value": "D2 / A0 / C0 / R0",
|
||
|
|
}
|
||
|
|
)
|
||
|
|
assert "vector_sync" in text
|
||
|
|
|
||
|
|
|
||
|
|
def test_prompt_batch_non_tty_raises():
|
||
|
|
with pytest.raises(NonInteractiveError):
|
||
|
|
prompt_batch(
|
||
|
|
[
|
||
|
|
{
|
||
|
|
"capability_id": "capability.demo.sample",
|
||
|
|
"kind": "vector_sync",
|
||
|
|
"confidence": "high",
|
||
|
|
"rationale": "drift",
|
||
|
|
"value": "D2 / A0 / C0 / R0",
|
||
|
|
}
|
||
|
|
]
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def test_prompt_batch_assume_yes():
|
||
|
|
patch = {
|
||
|
|
"capability_id": "capability.demo.sample",
|
||
|
|
"kind": "vector_sync",
|
||
|
|
"confidence": "high",
|
||
|
|
"rationale": "drift",
|
||
|
|
"value": "D2 / A0 / C0 / R0",
|
||
|
|
}
|
||
|
|
selected = prompt_batch([patch], assume_yes=True)
|
||
|
|
assert selected == [patch]
|