Refactor DataSource classes and enhance testing framework

- Removed outdated comments and documentation from CsvSessionSource and DemoSource classes.
- Introduced new unit tests for CsvSource and DataSource functionalities, ensuring robust validation of CSV loading and session handling.
- Added UI smoke tests to verify window instantiation and menu actions without hardware dependencies.
- Implemented VisionEngine tests to validate demo snapshots and alignment state logic.
This commit is contained in:
Your Name
2026-05-28 11:09:53 -07:00
parent 81fd015520
commit 958fde9050
6 changed files with 311 additions and 66 deletions
+34
View File
@@ -0,0 +1,34 @@
"""DataSource TODO anchors for future headless tests."""
from __future__ import annotations
import unittest
from wafer_edge.DataSources import DemoSource, CsvSessionSource
from wafer_edge.VisionEngine import VisionEngine
from wafer_edge.Calibration import BaselineCalibration
from pathlib import Path
import tempfile
import MASTER_SD
MASTER_SD = Path(__file__).resolve().parents[1] / "MASTER_SD"
class DataSourcesTest(unittest.TestCase):
def test_demo_source_snapshot(self) -> None:
sources = DemoSource(VisionEngine())
snapshot = sources.latest_snapshot(BaselineCalibration())
self.assertEqual(len(snapshot.camera_readings), 4)
self.assertEqual(snapshot.source_label, "User App - Simulated Data")
self.assertLess(snapshot.sigma_mm, 0.01)
def test_csv_session_source_snapshot(self) -> None:
source = CsvSessionSource(MASTER_SD, VisionEngine())
snapshot = source.latest_snapshot(BaselineCalibration())
self.assertEqual(len(snapshot.camera_readings), 4)
self.assertEqual(snapshot.system_status, "Ready")
self.assertEqual(snapshot.source_label, "Session: MASTER_SD (4 cams)")
def test_csv_session_source_missing_or_invalid_seed(self)-> None:
with tempfile.TemporaryDirectory() as tmp:
with self.assertRaises(FileNotFoundError):
CsvSessionSource(Path(tmp), VisionEngine())