| from pathlib import Path | |
| from src.jobs import _job_result | |
| class FakeJob: | |
| id = "abc123" | |
| url = None | |
| class status: | |
| stage = "RUNNING" | |
| def test_job_result_reconstructs_job_url_from_job_id_and_bucket_owner(): | |
| result = _job_result(FakeJob(), run_id="run-1", kind="test", bucket_source="fffiloni/space-factory-runs") | |
| assert result["job_id"] == "abc123" | |
| assert result["job_url"] == "https://huggingface.co/jobs/fffiloni/abc123" | |
| assert result["created_by"] == "fffiloni" | |
| def test_job_result_supports_dict_job_payloads(): | |
| result = _job_result({"job_id": "xyz789", "status": {"stage": "RUNNING"}}, run_id="run-2", kind="test", bucket_source="alice/runs") | |
| assert result["job_id"] == "xyz789" | |
| assert result["job_url"] == "https://huggingface.co/jobs/alice/xyz789" | |
| assert result["status"] == "RUNNING" | |
| def test_app_does_not_resume_latest_run_on_startup(): | |
| js = Path("web/static/app.js").read_text(encoding="utf-8") | |
| load_app = js.split("async function loadAppInfo", 1)[1].split("function renderSignedOut", 1)[0] | |
| assert "bootstrapRunRecovery()" not in load_app | |
| assert "restoreActiveRun()" not in load_app | |
| assert "clearSavedRun()" in load_app | |
| assert "resumeLatestRun" in js | |