mirror of
https://github.com/saphid/frame-control.git
synced 2026-10-06 04:04:21 +02:00
E2E: follow background jobs for Flatpak installs
The tabs UI (#4) runs Flatpak installs as server.start_job jobs, so a failed install answers 200 with a job id and reports the error on /api/job. The test now waits for the job instead of expecting an immediate 502. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b768162139
commit
19b9bc2dbe
2 files changed
+12
-5
No files matched your search
@@ -152,6 +152,12 @@ def ok(method, path, body=None, **kw):
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def finished(started, timeout=60):
|
||||||
|
"""Wait for a background job (server.start_job's {"job": id}); returns its final state."""
|
||||||
|
return wait_for(lambda: (lambda j: j['done'] and j)(ok('GET', f"/api/job?id={started['job']}")),
|
||||||
|
timeout, f"job {started['job']}")
|
||||||
|
|
||||||
|
|
||||||
def upload(path, mode, name=None):
|
def upload(path, mode, name=None):
|
||||||
with open(path, 'rb') as f:
|
with open(path, 'rb') as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ through the server against the fake Frame."""
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import harness
|
import harness
|
||||||
from harness import api, ctl, launches, ok, state, wait_for
|
from harness import api, ctl, finished, launches, ok, state, wait_for
|
||||||
|
|
||||||
harness.require()
|
harness.require()
|
||||||
|
|
||||||
@@ -46,13 +46,14 @@ class Device(harness.FrameTestCase):
|
|||||||
self.assertEqual(state()['clipboard'], [text])
|
self.assertEqual(state()['clipboard'], [text])
|
||||||
|
|
||||||
def test_flatpak_install_and_remove(self):
|
def test_flatpak_install_and_remove(self):
|
||||||
ok('POST', '/api/flatpak', {'id': 'org.videolan.VLC', 'action': 'install'})
|
# Installs run as background jobs (server.start_job); uninstall answers at once.
|
||||||
|
job = finished(ok('POST', '/api/flatpak', {'id': 'org.videolan.VLC', 'action': 'install'}))
|
||||||
|
self.assertIsNone(job['error'], job)
|
||||||
self.assertEqual([f['id'] for f in ok('GET', '/api/status')['flatpaks']], ['org.videolan.VLC'])
|
self.assertEqual([f['id'] for f in ok('GET', '/api/status')['flatpaks']], ['org.videolan.VLC'])
|
||||||
ok('POST', '/api/flatpak', {'id': 'org.videolan.VLC', 'action': 'uninstall'})
|
ok('POST', '/api/flatpak', {'id': 'org.videolan.VLC', 'action': 'uninstall'})
|
||||||
self.assertEqual(state()['flatpaks'], [])
|
self.assertEqual(state()['flatpaks'], [])
|
||||||
status, out, _ = api('POST', '/api/flatpak', {'id': 'org.example.missing', 'action': 'install'})
|
job = finished(ok('POST', '/api/flatpak', {'id': 'org.example.missing', 'action': 'install'}))
|
||||||
self.assertEqual(status, 502)
|
self.assertIn('Nothing matches org.example.missing', job['error'])
|
||||||
self.assertIn('Nothing matches org.example.missing', out['error'])
|
|
||||||
|
|
||||||
def test_desktop_capture(self):
|
def test_desktop_capture(self):
|
||||||
status, png, headers = api('GET', '/api/screenshot')
|
status, png, headers = api('GET', '/api/screenshot')
|
||||||
|
|||||||
Reference in new issue
Block a user