Eric's spec, all nine points. Two committed local-only stores follow
the local_games.json pattern — furniture.json (units of openings with
interior dims; a dimensionless opening is a virtual spot like a travel
case) and locations.json (game key -> opening + note). Shelf layouts
are nobody's data but the owner's; nothing touches upload.
The Shelves page builds furniture without hand-editing JSON — the
acceptance bar (two double-wides above three rows of four cubes, two
bookcases, a travel case) is a TEST, driven entirely through the
endpoints the UI calls. Presets for Kallax/Billy/custom/virtual,
grid creation with A1-style labels, openings editable/deletable/
reorderable. Units render as grids: zone, count, fill bar (stacked
thinnest-axis vs interior height), ⚠ on overfull or any resident that
can't fit. Openings open as a modal — a bottom sheet at phone widths,
search-first with thumb-sized targets for the moving-day loop.
Unshelved games list alongside with one-tap suggestions (only openings
they verifiably fit, with room).
Containment composes: a game stored inside another box inherits its
container's location, rides along in the opening's resident list
(marked), and refuses direct assignment naming its container. The
detail page's where-it-lives card gains the picker (openings grouped
by unit, each labeled fits / doesn't fit / can't verify) plus virtual
notes ("lent to Sarah, June"); the Library list shows a location line,
filters by unit or unshelved, and search matches location text and
zones.
bggpipe dims drops its hardcoded Kallax for the user's actual
furniture: per-opening capacity, overfull and misfit warnings,
unshelved count. bggpipe shelve --import loads a name,opening CSV
(ids or labels), rejecting — never guessing — unknown names, ambiguous
copies, unknown/ambiguous openings, misfits, and contained games.
Ten new tests incl. the acceptance flow, inheritance, CSV rejects,
and a phone-sheet smoke; 372 total.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016jXZFSTZQKzAC8fqpWSz9g
106 lines
3.2 KiB
Python
106 lines
3.2 KiB
Python
"""The shelf-space report: fit math, coverage buckets, honest unknowns."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
import pytest
|
|
import typer
|
|
|
|
from bggpipe.config import Config
|
|
from bggpipe.dims import run_dims_report
|
|
from bggpipe.shelves import save_furniture, save_locations
|
|
|
|
|
|
def test_report_buckets_misfits_and_unknowns(tmp_path, capsys):
|
|
cfg = Config(data_dir=tmp_path / "data")
|
|
cfg.data_dir.mkdir(parents=True)
|
|
cfg.games_path.write_text(
|
|
json.dumps(
|
|
{
|
|
"1": {
|
|
"name": "Fits Fine",
|
|
"dims": {
|
|
"width_in": 11.6,
|
|
"length_in": 11.6,
|
|
"depth_in": 2.8,
|
|
"weight_lb": 4,
|
|
"source": "version",
|
|
},
|
|
},
|
|
"2": {
|
|
"name": "Monster Box",
|
|
"dims": {
|
|
"width_in": 16.2,
|
|
"length_in": 16.2,
|
|
"depth_in": 4.0,
|
|
"weight_lb": 7,
|
|
"source": "unanimous",
|
|
},
|
|
},
|
|
"3": {
|
|
"name": "Argued About",
|
|
"dims": {
|
|
"width_in": None,
|
|
"length_in": None,
|
|
"depth_in": None,
|
|
"weight_lb": None,
|
|
"source": "conflicting",
|
|
},
|
|
},
|
|
"4": {"name": "Never Measured"}, # pre-dims entry: absent
|
|
}
|
|
)
|
|
)
|
|
# no furniture yet: sizes-only report, pointed at the Shelves page
|
|
summary = run_dims_report(cfg)
|
|
assert summary["by_source"] == {
|
|
"version": 1,
|
|
"unanimous": 1,
|
|
"conflicting": 1,
|
|
"absent": 1,
|
|
}
|
|
assert summary["misfits"] == []
|
|
assert summary["unknown"] == ["Argued About", "Never Measured"]
|
|
out = capsys.readouterr().out
|
|
assert "No furniture on file" in out
|
|
|
|
# with furniture: per-opening capacity, misfit and overfull warnings
|
|
save_furniture(
|
|
cfg,
|
|
[
|
|
{
|
|
"name": "Den",
|
|
"openings": [
|
|
{
|
|
"id": "den-a1",
|
|
"label": "A1",
|
|
"zone": "",
|
|
"width_in": 13.25,
|
|
"height_in": 13.25,
|
|
"depth_in": 15.4,
|
|
}
|
|
],
|
|
}
|
|
],
|
|
)
|
|
save_locations(
|
|
cfg,
|
|
{
|
|
"1": {"opening_id": "den-a1", "note": ""},
|
|
"2": {"opening_id": "den-a1", "note": ""},
|
|
},
|
|
)
|
|
summary = run_dims_report(cfg)
|
|
assert summary["misfits"] == ["Monster Box"]
|
|
out = capsys.readouterr().out
|
|
assert "doesn't fit: Monster Box" in out
|
|
assert "unshelved" in out # the conflicting + absent games have no home
|
|
assert "can't be size-verified" in out and "Never Measured" in out
|
|
|
|
|
|
def test_report_without_games_json_exits_with_guidance(tmp_path):
|
|
cfg = Config(data_dir=tmp_path / "data")
|
|
with pytest.raises(typer.Exit):
|
|
run_dims_report(cfg)
|