Add test suite (box rules, Python, QML against a fake Jellyfin server) and local preview jobs
CI / Vérifications et paquet (push) Successful in 48s
CI / Release Gitea (push) Skipped

- freebox-jellyfin test: box-only rules (ES5, QtQuick 2.5, qmldir, singletons),
  tooling unit tests, qmltestrunner on tests/qml against fake_server.py
- freebox-jellyfin fake-server and preview --fake-server
- package enforces the box rules; CI runs the tests
- JetBrains run configs: Local Preview, Local Preview (faux serveur), Tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
stilobiqueandClaude Opus 5.5 committed 2026-11-15 00:08:03 +01:00
1 parent d0d019ac1e
commit 1b2acae316
19 files changed
+2097 -17

No files matched your search

+97
View File
@@ -0,0 +1,97 @@
import json
import os
import tarfile
import tempfile
import unittest
import urllib.error
import urllib.request
from freebox_jellyfin import fake_server, package
class PackageTest(unittest.TestCase):
def test_file_selection(self):
files = package.collect_files()
self.assertIn("manifest.json", files)
self.assertIn("Jellyfin.qml", files)
self.assertIn(os.path.join("Core", "qmldir"), files)
for name in files:
self.assertFalse(name.endswith((".fbxproject", ".user", ".py")), name)
self.assertFalse(any(part.startswith(".") for part in name.split(os.sep)), name)
def test_manifest_matches_client_version(self):
manifest = package.check_manifest(package.collect_files())
self.assertRegex(manifest["version"], r"^\d+\.\d+\.\d+$")
def test_archive_layout(self):
files = package.collect_files()
with tempfile.TemporaryDirectory() as folder:
output = os.path.join(folder, "p.tar.gz")
package.build_archive(files, output)
with tarfile.open(output) as archive:
names = archive.getnames()
self.assertIn("Core", names) # entrées de dossiers
self.assertIn("Core/Session.qml", names) # chemins relatifs à app/
self.assertEqual(archive.getmember("Core").type, tarfile.DIRTYPE)
class FakeServerTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.server = fake_server.start()
@classmethod
def tearDownClass(cls):
cls.server.shutdown()
cls.server.server_close()
def call(self, method, path, body=None, token=None):
headers = {"Content-Type": "application/json"}
if token:
headers["Authorization"] = 'MediaBrowser Client="t", Token="%s"' % token
data = json.dumps(body).encode() if body is not None else None
request = urllib.request.Request(self.server.url + path, data=data, method=method, headers=headers)
try:
with urllib.request.urlopen(request, timeout=5) as response:
raw = response.read()
return response.status, json.loads(raw) if raw and raw[:1] in b"[{\"tf" else raw
except urllib.error.HTTPError as error:
return error.code, None
def setUp(self):
self.call("POST", "/__reset")
def test_auth_required(self):
self.assertEqual(self.call("GET", "/UserViews")[0], 401)
status, data = self.call("POST", "/Users/AuthenticateByName", {"Username": "alice", "Pw": "secret"})
self.assertEqual(status, 200)
self.assertEqual(self.call("GET", "/UserViews", token=data["AccessToken"])[0], 200)
self.assertEqual(self.call("POST", "/Users/AuthenticateByName", {"Username": "alice", "Pw": "x"})[0], 401)
def test_paging(self):
token = "token-user-alice"
status, data = self.call("GET", "/Items?parentId=lib-movies&startIndex=20&limit=10", token=token)
self.assertEqual((len(data["Items"]), data["TotalRecordCount"]), (5, 25))
def test_mock_and_journal(self):
self.call("POST", "/__mock", {"path": "/Users/Public", "status": 503})
self.assertEqual(self.call("GET", "/Users/Public")[0], 503)
status, journal = self.call("GET", "/__requests")
self.assertEqual([r["path"] for r in journal], ["/Users/Public"])
self.call("POST", "/__reset")
self.assertEqual(self.call("GET", "/Users/Public")[0], 200)
def test_stop_updates_resume_point(self):
token = "token-user-alice"
self.call("POST", "/Sessions/Playing/Stopped", {"ItemId": "movie-01", "PositionTicks": 1234}, token=token)
status, item = self.call("GET", "/Items/movie-01", token=token)
self.assertEqual(item["UserData"]["PlaybackPositionTicks"], 1234)
def test_images_are_png(self):
status, data = self.call("GET", "/Items/movie-01/Images/Primary?tag=x")
self.assertEqual(status, 200)
self.assertTrue(data.startswith(b"\x89PNG"))
if __name__ == "__main__":
unittest.main()