- introduce `LyricFlow.Core.Backend` with shared DTOs, rhyme/spellcheck engines, and REST endpoints - wire Python GUI/core to run and call the backend via new bridge/client modules - add backend parity/integration tests and update packaging/ignore settings
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
import os
|
|
import tempfile
|
|
import unittest
|
|
|
|
from PyQt6.QtCore import QCoreApplication, QSettings
|
|
|
|
from src.utils.app_settings import AppPreferences, AppSettingsStore
|
|
|
|
|
|
class TestAppSettingsStore(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
cls._app = QCoreApplication.instance() or QCoreApplication([])
|
|
|
|
def _make_store(self, root: str) -> AppSettingsStore:
|
|
settings_path = os.path.join(root, "app_settings.ini")
|
|
settings = QSettings(settings_path, QSettings.Format.IniFormat)
|
|
settings.clear()
|
|
settings.sync()
|
|
return AppSettingsStore(settings)
|
|
|
|
def test_defaults(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
store = self._make_store(tmp)
|
|
prefs = store.load()
|
|
self.assertTrue(prefs.reopen_last_project)
|
|
self.assertTrue(prefs.restore_unsaved_tabs)
|
|
self.assertFalse(prefs.word_wrap_default)
|
|
self.assertTrue(prefs.show_left_sidebar)
|
|
self.assertTrue(prefs.show_right_sidebar)
|
|
self.assertEqual("", prefs.last_project_file)
|
|
self.assertIsNone(prefs.window_geometry)
|
|
self.assertIsNone(prefs.splitter_sizes)
|
|
|
|
def test_round_trip(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
store = self._make_store(tmp)
|
|
original = AppPreferences(
|
|
reopen_last_project=False,
|
|
restore_unsaved_tabs=False,
|
|
word_wrap_default=True,
|
|
show_left_sidebar=False,
|
|
show_right_sidebar=True,
|
|
last_project_file="C:/demo/.lyricproject",
|
|
window_geometry=b"\x01\x02\x03",
|
|
splitter_sizes=[111, 777, 222, 333],
|
|
)
|
|
store.save(original)
|
|
loaded = store.load()
|
|
self.assertEqual(original, loaded)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|