mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-21 10:15:04 +02:00
fix(queue): send the copy count for a cross-model print (issue #3101)
Selecting sliced files for two printer models and asking for 25 copies queued one item. The queue emptied as soon as it dispatched and the Batches tab stayed empty, because no batch is created at quantity 1. A multi-plate file moves the run count off the modal's Quantity field onto a stepper beside each plate (#342), hiding the field. The cross-model submit (#671) posts that field, which in this combination nothing can set, so it stayed at its initial 1. The modal read "19 runs in total" above a button that queued one. Per-plate steppers do not fit a cross-model job: its plate is chosen per candidate, in the alternatives list, so there is one number to give. Exclude cross-model from the per-plate mode and the global field comes back. Drop the plate selector in that mode too. Its choice never reached the request; it only keyed the filament-requirements query, so picking plate 3 for a candidate while plate 1 stayed ticked above produced overrides computed from a plate the job would not print. That query now follows the primary file's own dropdown. Dispatch needed nothing -- it already gives each copy its own candidate rows -- but naming did. A cross-model job carries neither archive_id nor library_file_id, because the candidates are the files, so both branches that name a batch missed and every such order would have read "Batch" in the tab the reporter went looking in. Name it after the first candidate. The existing cross-model tests all mock a single-plate file, which is why the pair was never covered; the multi-plate case is added.
This commit is contained in:
@@ -295,3 +295,28 @@ class TestQueueWithVariants:
|
||||
assert len(item_ids) == 3
|
||||
total = (await db_session.execute(select(PrintQueueVariant))).scalars().all()
|
||||
assert len(total) == 6
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.integration
|
||||
async def test_quantity_batch_is_named_after_the_first_candidate(
|
||||
self, async_client, db_session, sliced_file_factory, printer_factory
|
||||
):
|
||||
"""A cross-model job has no archive_id and no library_file_id -- the
|
||||
candidates are the files -- so the batch name has to come from one of
|
||||
them or every such order reads "Batch" in the Batches tab (#3101)."""
|
||||
from backend.app.models.print_batch import PrintBatch
|
||||
|
||||
await printer_factory(model="H2S")
|
||||
await printer_factory(model="H2C")
|
||||
h2s = await sliced_file_factory("H2S", filename="bloom.gcode.3mf")
|
||||
h2c = await sliced_file_factory("H2C")
|
||||
|
||||
r = await _queue_variants(async_client, h2s.id, h2c.id, quantity=4)
|
||||
assert r.status_code == 200
|
||||
|
||||
batch = (await db_session.execute(select(PrintBatch))).scalars().one()
|
||||
assert batch.name == "bloom ×4"
|
||||
# Both stay null: the row cannot name one source without disowning the
|
||||
# others, and every consumer derives progress from the items instead.
|
||||
assert batch.archive_id is None
|
||||
assert batch.library_file_id is None
|
||||
|
||||
Reference in New Issue
Block a user