32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from owner_voice_pet.assets import REQUIRED_ASSET_STATES, validate_pet_assets
|
|
from owner_voice_pet.models import PipelineState
|
|
from owner_voice_pet.ui import ConsolePetWindow, PetStateController, PetVisualState
|
|
|
|
|
|
class UiAssetTests(unittest.TestCase):
|
|
def test_pipeline_state_maps_to_visual_state(self) -> None:
|
|
controller = PetStateController()
|
|
self.assertEqual(controller.apply_pipeline_state(PipelineState.SPEECH_DETECTING), PetVisualState.LISTENING)
|
|
self.assertEqual(controller.apply_pipeline_state(PipelineState.THINKING), PetVisualState.THINKING)
|
|
self.assertEqual(controller.apply_pipeline_state(PipelineState.ERROR_RECOVERING), PetVisualState.ERROR)
|
|
|
|
def test_console_window_fallback_records_history(self) -> None:
|
|
window = ConsolePetWindow()
|
|
self.assertEqual(window.update(PipelineState.SPEAKING), PetVisualState.SPEAKING)
|
|
self.assertEqual(window.history, [PetVisualState.SPEAKING])
|
|
|
|
def test_project_pet_assets_are_rgba_and_complete(self) -> None:
|
|
infos = validate_pet_assets(Path("assets/pet"))
|
|
self.assertEqual(len(infos), len(REQUIRED_ASSET_STATES))
|
|
self.assertTrue(all(info.width == 256 and info.height == 256 for info in infos))
|
|
self.assertTrue(all(info.has_transparency for info in infos))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|