Newer
Older
SmTIAS-LightSim / tests / scene / conftest.py
"""scene テスト共通フィクスチャ.

有効な最小構成 YAML 文字列を提供する.
異常系テストはこの文字列を replace するか,dict を直接組み立てて検証する.
"""

import pytest


@pytest.fixture
def valid_minimal_yaml() -> str:
    """必須 6 セクション(name, geometry, materials, lights, sensor, render)のみの最小 YAML.

    各テストで replace/加工のベースとして使う.
    """
    return """\
name: test_scene
geometry:
  meshes:
    - id: housing
      path: configs/meshes/housing.stl
      unit: mm
      material: mat_diffuse
materials:
  mat_diffuse:
    type: diffuse
    reflectance: 0.5
lights:
  - id: led_top
    type: point
    position: [0.0, 0.0, 50.0]
    intensity: [1.0, 1.0, 1.0]
    profile: lambertian
sensor:
  type: perspective
  position: [0.0, 0.0, 100.0]
  target: [0.0, 0.0, 0.0]
  up: [0.0, 1.0, 0.0]
  fov_deg: 60.0
  film:
    width: 1920
    height: 1080
render:
  variant: llvm_ad_rgb
  integrator: path
  max_depth: 8
  spp: 256
"""


@pytest.fixture
def valid_minimal_dict() -> dict:
    """valid_minimal_yaml と同内容の Python dict.モデル直接検証に使う."""
    return {
        "name": "test_scene",
        "geometry": {
            "meshes": [
                {
                    "id": "housing",
                    "path": "configs/meshes/housing.stl",
                    "unit": "mm",
                    "material": "mat_diffuse",
                }
            ]
        },
        "materials": {
            "mat_diffuse": {"type": "diffuse", "reflectance": 0.5},
        },
        "lights": [
            {
                "id": "led_top",
                "type": "point",
                "position": [0.0, 0.0, 50.0],
                "intensity": [1.0, 1.0, 1.0],
                "profile": "lambertian",
            }
        ],
        "sensor": {
            "type": "perspective",
            "position": [0.0, 0.0, 100.0],
            "target": [0.0, 0.0, 0.0],
            "up": [0.0, 1.0, 0.0],
            "fov_deg": 60.0,
            "film": {"width": 1920, "height": 1080},
        },
        "render": {
            "variant": "llvm_ad_rgb",
            "integrator": "path",
            "max_depth": 8,
            "spp": 256,
        },
    }