Load a job record that holds unknown fields

A downgrade of Bindery no longer stops at the start.
This commit is contained in:
tim
2026-10-02 23:37:33 +02:00
parent 98c4a66da1
commit 9c9c5b7dac
2 changed files with 12 additions and 2 deletions
+8
View File
@@ -1,5 +1,6 @@
"""The job queue: shared jobs, order, cancelling and the job history."""
import json
from datetime import datetime, timedelta
from bindery import config
@@ -167,3 +168,10 @@ def test_the_api_form_of_a_job_hides_the_path_of_an_upload():
job = Job(mode=DownloadMode.IMPORT_FILE, options={"path": "/config/uploads/x.epub", "name": "x.epub"})
assert job.to_dict()["options"] == {"name": "x.epub"}
assert Job.from_record(job.to_record()).options == job.options
def test_a_record_of_a_newer_bindery_loads_without_its_unknown_fields():
job = Job(mode=DownloadMode.NEW, story_id=3)
record = json.dumps({**json.loads(job.to_record()), "priority": 5})
loaded = Job.from_record(record)
assert (loaded.id, loaded.story_id, loaded.mode) == (job.id, 3, DownloadMode.NEW)