fix: BLS-Datenimport als Hintergrundjob gegen HTTP 504
Prüfung und Apply laufen serverseitig, die UI pollt nur noch den Status. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8e964509d7
commit
a07a668de2
6 files changed
+281
-35
No files matched your search
@@ -1,8 +1,10 @@
|
||||
import time
|
||||
from io import BytesIO
|
||||
|
||||
from openpyxl import Workbook
|
||||
|
||||
from bls.import_service import should_persist_value
|
||||
from bls.jobs import create_and_check, get_job
|
||||
from bls.parser import parse_components_xlsx, parse_foods_xlsx
|
||||
|
||||
|
||||
@@ -44,3 +46,20 @@ def test_persist_only_numeric_or_trace():
|
||||
assert should_persist_value({"value_num": 1.2, "is_trace": False})
|
||||
assert should_persist_value({"value_num": None, "is_trace": True})
|
||||
assert not should_persist_value({"value_num": None, "is_trace": False})
|
||||
|
||||
|
||||
def test_import_job_check_does_not_need_http():
|
||||
data = _xlsx([
|
||||
["BLS Code", "Name", "Food name", "ENERCC Energie [kcal/100g]", "ENERCC Herkunft", "ENERCC Referenz"],
|
||||
["C131000", "Hafer roh", "Oats raw", 350, "Analyse", "MRI"],
|
||||
])
|
||||
job_id = create_and_check("foods", data)
|
||||
job = None
|
||||
for _ in range(80):
|
||||
job = get_job(job_id)
|
||||
if job and job["status"] in ("checked", "error"):
|
||||
break
|
||||
time.sleep(0.05)
|
||||
assert job is not None
|
||||
assert job["status"] == "checked", job.get("error")
|
||||
assert job["check"]["foods"] == 1
|
||||
Reference in new issue
Block a user