mirror of
https://github.com/DeeJanuz/frametop.git
synced 2026-10-06 03:00:06 +02:00
af2ea7c put _stay_awake between exportSession and its @Slot, so the
window's Export button called a method QML couldn't see. A new test checks
every backend call in main.qml against Backend's slots and properties.
Export and Upload now say Exporting…/Uploading… with a spinner the moment
they're pressed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""main.qml against ft_handrec.Backend: every backend.name(...) the window calls is a slot, and
|
|
every backend.name it reads is a property or a slot. A method that lost its @Slot shows up in
|
|
QML only as "is not a function" when its button is pressed (2026-10-03: Export did nothing).
|
|
Needs PySide6 (the dev container); skipped without it.
|
|
|
|
python3 hands/rec/tests/test_qml_backend.py
|
|
"""
|
|
import os
|
|
import re
|
|
import sys
|
|
import unittest
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
REC = os.path.dirname(HERE)
|
|
sys.path.insert(0, REC)
|
|
|
|
|
|
class QmlBackendTest(unittest.TestCase):
|
|
def setUp(self):
|
|
try:
|
|
import ft_handrec
|
|
except ImportError as e:
|
|
self.skipTest(f"no PySide6: {e}")
|
|
meta = ft_handrec.Backend.staticMetaObject
|
|
self.slots = {bytes(meta.method(i).name()).decode() for i in range(meta.methodCount())}
|
|
self.props = {meta.property(i).name() for i in range(meta.propertyCount())}
|
|
with open(os.path.join(REC, "main.qml")) as f:
|
|
self.qml = f.read()
|
|
|
|
def test_calls_are_slots(self):
|
|
called = set(re.findall(r"\bbackend\.(\w+)\s*\(", self.qml))
|
|
self.assertTrue(called)
|
|
self.assertEqual(sorted(called - self.slots), [], "called from main.qml but not a slot")
|
|
|
|
def test_reads_exist(self):
|
|
read = set(re.findall(r"\bbackend\.(\w+)\b(?!\s*\()", self.qml))
|
|
self.assertTrue(read)
|
|
self.assertEqual(sorted(read - self.props - self.slots), [], "read in main.qml but not on Backend")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|