pyLyricFlow/tests/test_project_state_compat.py
2026-02-24 13:22:10 -06:00

33 lines
914 B
Python

import unittest
from src.gui.main_window import MainWindow
class TestProjectStateCompat(unittest.TestCase):
def test_legacy_project_without_cursor_positions(self):
legacy = {
"name": "demo",
"open_files": ["C:/demo/song.lmd"],
"active_file": "C:/demo/song.lmd",
}
self.assertEqual({}, MainWindow._extract_cursor_positions(legacy))
def test_cursor_positions_parsing_is_defensive(self):
data = {
"cursor_positions": {
"C:/demo/song.lmd": "42",
"C:/demo/song2.lmd": -5,
"C:/demo/song3.lmd": "bad",
123: 7,
}
}
expected = {
"C:/demo/song.lmd": 42,
"C:/demo/song2.lmd": 0,
}
self.assertEqual(expected, MainWindow._extract_cursor_positions(data))
if __name__ == "__main__":
unittest.main()