6.8 KiB
6.8 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, must_haves
| phase | plan | type | wave | depends_on | files_modified | autonomous | requirements | must_haves | |||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 06-wire-icon-intunewin | 01 | execute | 1 |
|
true |
|
|
Purpose: Closes the PKG-04 gap — icon upload exists (Phase 5) but the .intunewin builder never receives the icon file. This is the last unsatisfied v1 requirement. Output: Modified packages.py with icon lookup + copy, two new integration tests in test_packages.py.
<execution_context> @C:/Users/SebastienQUEROL/.claude/get-shit-done/workflows/execute-plan.md @C:/Users/SebastienQUEROL/.claude/get-shit-done/templates/summary.md </execution_context>
@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md @.planning/phases/06-wire-icon-intunewin/06-RESEARCH.mdFrom imptune/db/models.py:
class Icon(BaseModel):
printer = ForeignKeyField(Printer, unique=True, backref="icons")
sha256 = CharField()
original_filename = CharField()
size_bytes = IntegerField()
uploaded_at = DateTimeField(default=datetime.utcnow)
class Meta:
table_name = "icon"
From imptune/config.py:
ICONS_DIR = str(Path(DATA_DIR) / "icons")
From imptune/api/packages.py (insertion point — line 146, after driver extraction, before build_intunewin):
# Line 132: with tempfile.TemporaryDirectory(prefix="imptune_") as tmpdir:
# Lines 134-139: write install.ps1, uninstall.ps1, detect.ps1
# Lines 142-145: extract driver ZIP into tmpdir/drivers/
# >>> INSERT ICON COPY HERE <<<
# Line 148: output_path = os.path.join(tmpdir, "out.intunewin")
# Line 149: build_intunewin(tmpdir, "install.ps1", output_path)
From tests/test_packages.py (existing fixtures):
@pytest.fixture
def setup_printer_with_driver(tmp_data_dir, driver_zip_bytes):
# Creates Driver + Printer records, writes driver ZIP to cfg.DRIVERS_DIR
# Returns (printer, driver)
1. `test_intunewin_includes_icon(self, client, setup_printer_with_driver, tmp_data_dir, monkeypatch)`:
- Create a 256x256 RGBA PNG using `PIL.Image.new("RGBA", (256, 256), color="red")`
- POST it to `/printers/{printer.id}/icon` as multipart file upload
- Assert upload returns 200
- Define `fake_build(source_dir, setup_file, output_path)` that captures `os.listdir(source_dir)` into a list and writes `b"FAKE"` to output_path
- Monkeypatch `imptune.api.packages.build_intunewin` with fake_build
- GET `/printers/{printer.id}/packages/intunewin`
- Assert status 200 and `"icon.png"` in captured staged files
2. `test_intunewin_without_icon_succeeds(self, client, setup_printer_with_driver, monkeypatch)`:
- Same fake_build monkeypatch (no icon upload)
- GET `/printers/{printer.id}/packages/intunewin`
- Assert status 200
Run tests — both MUST fail (icon.png not staged, and second test should actually pass since no icon code yet — if it passes, that is acceptable for the baseline).
GREEN phase — modify imptune/api/packages.py:
1. Add `import shutil` at top
2. Add `from imptune.db.models import Icon` to the existing models import (line 12 area — add Icon next to Printer)
3. Inside `get_intunewin_package()`, after the driver ZIP extraction block (after line 145) and BEFORE `build_intunewin()` (line 149), insert:
```python
# Copy icon into staging if one exists for this printer
icon_record = Icon.get_or_none(Icon.printer == printer.id)
if icon_record is not None:
icon_src = os.path.join(cfg.ICONS_DIR, icon_record.sha256)
if os.path.isfile(icon_src):
shutil.copy2(icon_src, os.path.join(tmpdir, "icon.png"))
```
This is 4 lines of production code. The icon is optional — missing DB record or missing file on disk both result in silent skip (no error, export proceeds without icon).
Run tests again — both MUST pass.
<success_criteria>
- Printers with an uploaded icon have icon.png included in .intunewin staging directory
- Printers without an icon export successfully with no error
- All existing tests pass without modification
- PKG-04 requirement satisfied </success_criteria>