Allow python and python3 as stitching commands. They are allowed. Move stitching tests into one file
This commit is contained in:
parent
98e71207c5
commit
48f6e1b369
3 changed files with 23 additions and 51 deletions
|
|
@ -21,6 +21,7 @@ from openflexure_microscope_server.stitching import (
|
|||
PreviewStitcher,
|
||||
StitcherValidationError,
|
||||
StitchingSettings,
|
||||
validate_command,
|
||||
)
|
||||
|
||||
from ..shared_utils.lt_test_utils import LabThingsTestEnv
|
||||
|
|
@ -32,6 +33,28 @@ THIS_DIR: str = os.path.dirname(os.path.realpath(__file__))
|
|||
MOCK_STITCHER: str = os.path.join(THIS_DIR, "mock_stitching", "mock-stitch.py")
|
||||
|
||||
|
||||
def test_validate_command_success():
|
||||
"""Test valid commands pass validation."""
|
||||
validate_command(["openflexure-stitch", "--stitching_mode", "all", "path/to/scan"])
|
||||
validate_command(["--resize", "0.5", "8192"])
|
||||
|
||||
|
||||
def test_validate_command_forbidden():
|
||||
"""Test forbidden commands raise error."""
|
||||
with pytest.raises(
|
||||
StitcherValidationError, match="Forbidden element 'sudo' detected"
|
||||
):
|
||||
validate_command(["sudo", "rm", "-rf", "/"])
|
||||
|
||||
with pytest.raises(StitcherValidationError, match="Forbidden element 'sh' detected"):
|
||||
validate_command(["sh", "-c", "whoami"])
|
||||
|
||||
with pytest.raises(
|
||||
StitcherValidationError, match="Forbidden element 'SUDO' detected"
|
||||
):
|
||||
validate_command(["SUDO", "ls"])
|
||||
|
||||
|
||||
def test_base_stitcher():
|
||||
"""Test the logic in BaseStitcher.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue