Files
NODEDC_MISSION_CORE/tests/test_infrastructure_idle_pending.py
DCCONSTRUCTIONS f48411f8fe feat(simulation): integrate infrastructure jobs and semantic scene editing
Integrate infrastructure preparation and qualified map delivery with local scenes. Add semantic editing, object provenance, survey caching and operator scene tools.
2026-10-29 09:10:01 +03:00

35 lines
1.5 KiB
Python

"""Idle polls do no provider hashing; queued work still verifies current code."""
import pytest
from test_infrastructure_jobs import world
from k1link.simulation.ai_polygon import infrastructure_jobs as module
@pytest.mark.parametrize("status,released", [("running", False), ("ready", False),
("failed", True), ("ready", True)])
def test_pending_without_queue_does_not_read_source_tree(tmp_path, monkeypatch, status, released):
store = module.InfrastructureJobs(tmp_path)
monkeypatch.setattr(module, "provider_identity", lambda: "f" * 64)
row = store.request(world())
row.update(status=status, released=released)
module.write_json(store.path(row["key"]), row)
def forbidden():
raise AssertionError("idle poll hashed provider source")
monkeypatch.setattr(module, "provider_identity", forbidden)
result = store.pending()
assert result == (row if status == "running" or not released else None)
store.path(row["key"]).unlink()
assert store.pending() is None
def test_queued_work_rechecks_identity_and_rejects_source_change(tmp_path, monkeypatch):
store = module.InfrastructureJobs(tmp_path)
monkeypatch.setattr(module, "provider_identity", lambda: "f" * 64)
row = store.request(world())
assert store.pending()["key"] == row["key"]
monkeypatch.setattr(module, "provider_identity", lambda: "e" * 64)
assert store.pending() is None
assert store.get(row["key"])["status"] == "failed"