mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 15:37:55 +08:00
test: cover the image gate
The gate has four entry points and each now has a test: `view_image` and `fetch_local` refuse with the message naming the config key, the registry drops a plugin tool's picture and says why, and the workspace helpers keep `None` (no host verdict) permissive. On the CLI side the verdict is asserted to follow the selected model, and to reach the tools once an instance is bound.
This commit is contained in:
@@ -9,10 +9,12 @@ from plyngent.tools import (
|
||||
check_command_allowed,
|
||||
get_trash_enabled,
|
||||
get_workspace_root,
|
||||
image_input_refusal,
|
||||
mode_covers,
|
||||
parse_access_mode,
|
||||
resolve_path,
|
||||
set_command_denylist,
|
||||
set_image_in,
|
||||
set_path_denylist,
|
||||
set_trash_enabled,
|
||||
)
|
||||
@@ -67,6 +69,34 @@ def test_trash_switch(workspace: object) -> None:
|
||||
assert get_trash_enabled() is True
|
||||
|
||||
|
||||
def test_image_switch(workspace: object) -> None:
|
||||
"""A picture is refused once the host says the model cannot take one."""
|
||||
del workspace
|
||||
assert image_input_refusal() is None
|
||||
|
||||
set_image_in(image_in=False)
|
||||
unnamed = image_input_refusal()
|
||||
assert unnamed is not None
|
||||
assert "does not accept image input" in unnamed
|
||||
|
||||
set_image_in(image_in=False, provider="ds", model="text-only")
|
||||
named = image_input_refusal()
|
||||
assert named is not None
|
||||
assert "model 'text-only' does not accept image input" in named
|
||||
assert '[providers.ds.models."text-only"]' in named
|
||||
|
||||
set_image_in(image_in=True, provider="ds", model="vision")
|
||||
assert image_input_refusal() is None
|
||||
|
||||
|
||||
def test_the_image_switch_needs_a_declaration(workspace: object) -> None:
|
||||
"""No host verdict (``None``) sends the picture: only ``False`` refuses."""
|
||||
del workspace
|
||||
policy = active_workspace_policy()
|
||||
assert policy.image_in is None
|
||||
assert image_input_refusal() is None
|
||||
|
||||
|
||||
def test_config_grant_modes(workspace: object, tmp_path_factory: pytest.TempPathFactory) -> None:
|
||||
del workspace
|
||||
outside = tmp_path_factory.mktemp("granted")
|
||||
|
||||
Reference in New Issue
Block a user