test(06-01): add failing test for icon inclusion in .intunewin export
- test_intunewin_includes_icon: uploads PNG icon, asserts icon.png in staged files - test_intunewin_without_icon_succeeds: baseline no-icon export passes (already green)
This commit is contained in:
@@ -189,3 +189,58 @@ class TestCommandPreview:
|
||||
html = resp.text
|
||||
assert f"/printers/{printer.id}/icon" in html
|
||||
assert "icon-status" in html
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Icon inclusion in .intunewin export
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TestIntunewinIconInclusion:
|
||||
def test_intunewin_includes_icon(self, client, setup_printer_with_driver, tmp_data_dir, monkeypatch):
|
||||
"""When a printer has an uploaded icon, icon.png must appear in the .intunewin staging directory."""
|
||||
import io as _io
|
||||
import os
|
||||
|
||||
from PIL import Image
|
||||
|
||||
printer, _ = setup_printer_with_driver
|
||||
|
||||
# Upload a 256x256 PNG icon for the printer
|
||||
buf = _io.BytesIO()
|
||||
Image.new("RGBA", (256, 256), color="red").save(buf, format="PNG")
|
||||
buf.seek(0)
|
||||
upload_resp = client.post(
|
||||
f"/printers/{printer.id}/icon",
|
||||
files={"file": ("icon.png", buf, "image/png")},
|
||||
)
|
||||
assert upload_resp.status_code == 200
|
||||
|
||||
# Monkeypatch build_intunewin to capture staged files and write a fake output
|
||||
staged_files: list[str] = []
|
||||
|
||||
def fake_build(source_dir, setup_file, output_path):
|
||||
staged_files.extend(os.listdir(source_dir))
|
||||
with open(output_path, "wb") as f:
|
||||
f.write(b"FAKE")
|
||||
|
||||
monkeypatch.setattr("imptune.api.packages.build_intunewin", fake_build)
|
||||
|
||||
resp = client.get(f"/printers/{printer.id}/packages/intunewin")
|
||||
assert resp.status_code == 200
|
||||
assert "icon.png" in staged_files
|
||||
|
||||
def test_intunewin_without_icon_succeeds(self, client, setup_printer_with_driver, monkeypatch):
|
||||
"""When a printer has no icon, .intunewin export must succeed without error."""
|
||||
import os
|
||||
|
||||
# Monkeypatch build_intunewin to write a fake output
|
||||
def fake_build(source_dir, setup_file, output_path):
|
||||
with open(output_path, "wb") as f:
|
||||
f.write(b"FAKE")
|
||||
|
||||
monkeypatch.setattr("imptune.api.packages.build_intunewin", fake_build)
|
||||
|
||||
printer, _ = setup_printer_with_driver
|
||||
resp = client.get(f"/printers/{printer.id}/packages/intunewin")
|
||||
assert resp.status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user