2026-06-24 01:47:07 +02:00
|
|
|
"""Extension SDK base class tests."""
|
|
|
|
|
|
2026-06-24 07:57:40 +02:00
|
|
|
import pytest
|
|
|
|
|
|
2026-06-24 01:47:07 +02:00
|
|
|
from sandboxer.extensions.base import SandboxExtension
|
|
|
|
|
from sandboxer.extensions.compose_ssh import ComposeSSHExtension
|
|
|
|
|
from sandboxer.extensions.vm_packer import VMPackerExtension
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_reference_extensions_subclass_base() -> None:
|
|
|
|
|
assert issubclass(ComposeSSHExtension, SandboxExtension)
|
|
|
|
|
assert issubclass(VMPackerExtension, SandboxExtension)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_new_sandbox_id_from_inputs() -> None:
|
|
|
|
|
assert SandboxExtension.new_sandbox_id({"sandbox_id": "fixed123"}) == "fixed123"
|
|
|
|
|
generated = SandboxExtension.new_sandbox_id({})
|
2026-06-24 07:57:40 +02:00
|
|
|
assert len(generated) == 8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_default_snapshot_not_supported() -> None:
|
|
|
|
|
class MinimalExtension(SandboxExtension):
|
|
|
|
|
def provision(self, profile, inputs, host):
|
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
def wait_ready(self, handle):
|
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
def teardown(self, handle):
|
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
ext = MinimalExtension()
|
|
|
|
|
assert ext.supports_snapshots() is False
|
|
|
|
|
with pytest.raises(NotImplementedError):
|
|
|
|
|
ext.snapshot({})
|