Add unit tests for service functionality and model caching

- Implement tests for ben2 and da3 model caching to ensure models are reused for matching runtime keys.
- Verify service state management, including client registration, job cancellation, and client expiration.
- Test discovery file creation and removal based on service ownership.
- Ensure frame extraction functionality works without models and produces expected results.
This commit is contained in:
2026-08-13 00:35:40 +08:00
parent 7d0983529e
commit 92d2cea1d1
21 changed files with 935 additions and 887 deletions

View File

@@ -2,7 +2,7 @@ from pathlib import Path
import bpy
from .runtime import device_enum_items
from .client import device_enum_items
class SnapFormPreferences(bpy.types.AddonPreferences):
@@ -11,7 +11,7 @@ class SnapFormPreferences(bpy.types.AddonPreferences):
storage_root: bpy.props.StringProperty(
name="Storage Root",
description=(
"Shared user-writable storage for Backend Environment, models and jobs; "
"Shared user-writable storage for the environment, models and jobs; "
"all Blender versions can use the same directory"
),
subtype="DIR_PATH",
@@ -29,27 +29,27 @@ class SnapFormPreferences(bpy.types.AddonPreferences):
def draw(self, _context):
from .operators import active_job
from .runtime import runtime_directory, runtime_ready
from .client import venv_directory, env_installed
layout = self.layout
layout.prop(self, "storage_root")
layout.prop(self, "device")
layout.separator()
layout.label(text=f"Backend Environment: {runtime_directory()}")
if runtime_ready():
layout.label(text="Backend Environment is ready", icon="CHECKMARK")
layout.label(text=f"Environment: {venv_directory()}")
if env_installed():
layout.label(text="Environment is installed", icon="CHECKMARK")
else:
install_row = layout.row()
install_row.enabled = active_job() is None
operator = install_row.operator(
"snapform.run_job",
text="Install Backend",
text="Install Environment",
icon="IMPORT",
)
operator.job_type = "INSTALL_RUNTIME"
operator.job_type = "INSTALL_ENV"
layout.separator()
operator = layout.operator(
"snapform.control_host",
"snapform.control_service",
text="Open Service Log",
icon="TEXT",
)