Read SAB cat as category
Treat SAB history cat/category fields equivalently for #20.
This commit is contained in:
@@ -30,7 +30,8 @@ def classify_history_item(item: dict[str, Any], active_nzo_ids: set[str], catego
|
|||||||
nzo_id = str(item.get("nzo_id") or item.get("nzoid") or "")
|
nzo_id = str(item.get("nzo_id") or item.get("nzoid") or "")
|
||||||
if not force_status and nzo_id and nzo_id in active_nzo_ids:
|
if not force_status and nzo_id and nzo_id in active_nzo_ids:
|
||||||
return Readiness("processing", "SAB job is still present in queue")
|
return Readiness("processing", "SAB job is still present in queue")
|
||||||
if str(item.get("category") or "") != category:
|
item_category = str(item.get("category") or item.get("cat") or "")
|
||||||
|
if item_category != category:
|
||||||
return Readiness("ignored", "SAB category is not owned by Importarr")
|
return Readiness("ignored", "SAB category is not owned by Importarr")
|
||||||
status = str(item.get("status") or "")
|
status = str(item.get("status") or "")
|
||||||
if not force_status and status == "Failed":
|
if not force_status and status == "Failed":
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ def test_wrong_category_ignored():
|
|||||||
assert result.state == "ignored"
|
assert result.state == "ignored"
|
||||||
|
|
||||||
|
|
||||||
|
def test_sab_cat_field_is_treated_as_category():
|
||||||
|
result = classify_history_item(item(category=None, cat="manual"), set(), "manual", ROOT)
|
||||||
|
assert result.ready
|
||||||
|
|
||||||
|
|
||||||
def test_queue_item_not_ready():
|
def test_queue_item_not_ready():
|
||||||
result = classify_history_item(item(), {"1"}, "manual", ROOT)
|
result = classify_history_item(item(), {"1"}, "manual", ROOT)
|
||||||
assert result.state == "processing"
|
assert result.state == "processing"
|
||||||
|
|||||||
Reference in New Issue
Block a user