# -*- coding: utf-8 -*-
"""Refactor safety net: the Millionaire game must keep its recorded behaviour (docs/plan/millionaire-refactor).

Replays the golden demo scenarios of scripts/game_harness/golden.py headless (real game modal, adapter, controller and
demo content, fixed random seed) and compares every WCS.Game.* property the modern card reads, the focus and the screen
after each step with scripts/game_harness/golden/*.headless.json. Live frames: `game.py golden verify --live`.

Run: python3 tests/test_millionaire_golden.py
"""
import os
import subprocess
import sys
import unittest

ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
GAME = os.path.join(ROOT, 'scripts', 'game_harness', 'game.py')


class GoldenRunsTests(unittest.TestCase):
    def test_the_game_behaves_as_recorded(self):
        # a process of its own: the harness installs its own fake Kodi modules and time scale
        result = subprocess.run([sys.executable, GAME, 'golden', 'verify'], capture_output=True, text=True,
                                timeout=600)
        self.assertEqual(result.returncode, 0, result.stdout + result.stderr)


if __name__ == '__main__':
    unittest.main()
