| from pathlib import Path | |
| from src.worker_payload import UNIVERSAL_MODEL_CARD_WORKER_SCRIPT, encoded_universal_model_card_worker_script | |
| def test_universal_payload_compiles(): | |
| compile(UNIVERSAL_MODEL_CARD_WORKER_SCRIPT, "<universal_worker>", "exec") | |
| def test_universal_payload_encoded(): | |
| assert encoded_universal_model_card_worker_script() | |
| def test_universal_initial_workspace_renders_without_name_error(tmp_path): | |
| namespace = {} | |
| exec(compile(UNIVERSAL_MODEL_CARD_WORKER_SCRIPT, "<universal_worker>", "exec"), namespace) | |
| workspace = tmp_path / "workspace" | |
| files = namespace["create_initial_workspace"]( | |
| workspace, | |
| "Tongyi-MAI/Z-Image-Turbo", | |
| "fffiloni/test-space", | |
| "cpu-basic", | |
| "", | |
| False, | |
| "full-inference-gated", | |
| {"pipeline_tag": "text-to-image", "library_name": "diffusers", "tags": [], "siblings": []}, | |
| ) | |
| assert "app.py" in files | |
| app_py = (workspace / "app.py").read_text(encoding="utf-8") | |
| assert "MODEL_ID = 'Tongyi-MAI/Z-Image-Turbo'" in app_py | |
| assert "{MODEL_ID}" in app_py | |
| assert "GOAL.md" in files | |