test_external_print_confirmation_1898.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. """Ask for the outcome of prints Bambuddy did not start (#1898 follow-up).
  2. The ask-for-outcome flag rides from a queue item onto the archive at dispatch.
  3. On a farm where most jobs are started at the printer's screen, in Bambu Studio
  4. or in the Handy app there is no queue item to ride from, so every archive
  5. ``on_print_start`` created had ``confirm_requested`` false and the feature
  6. looked broken. ``confirm_outcome_external_prints`` is the missing source.
  7. Both archive-creating branches of ``on_print_start`` are driven here against a
  8. real database: the no-3MF fallback (what a P1S/A1 farm actually hits) and the
  9. normal path that archives a downloaded 3MF.
  10. """
  11. from contextlib import ExitStack
  12. from datetime import datetime, timezone
  13. from unittest.mock import AsyncMock, MagicMock, patch
  14. import pytest
  15. from sqlalchemy import select
  16. from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
  17. from backend.app.main import (
  18. _active_prints,
  19. _expected_print_creators,
  20. _expected_print_registered_at,
  21. _expected_prints,
  22. _print_ams_mappings,
  23. )
  24. from backend.app.models.archive import PrintArchive
  25. from backend.app.models.print_queue import PrintQueueItem
  26. from backend.app.models.settings import Settings
  27. DISPATCH = "/data/Metadata/plate_1.gcode"
  28. SUBTASK = "Bracket_plate_1"
  29. @pytest.fixture(autouse=True)
  30. def _clear_print_state():
  31. dicts = (
  32. _expected_prints,
  33. _expected_print_registered_at,
  34. _expected_print_creators,
  35. _print_ams_mappings,
  36. _active_prints,
  37. )
  38. for d in dicts:
  39. d.clear()
  40. yield
  41. for d in dicts:
  42. d.clear()
  43. class _StubArchiveService:
  44. """Stands in for ArchiveService on the downloaded-3MF branch.
  45. Writes the row the real service would write, without needing a parseable
  46. 3MF on disk. Everything this test asserts happens *after* the row exists.
  47. """
  48. def __init__(self, db):
  49. self.db = db
  50. async def archive_print(self, **kwargs):
  51. archive = PrintArchive(
  52. printer_id=kwargs.get("printer_id"),
  53. filename=f"{SUBTASK}.gcode.3mf",
  54. file_path=f"archives/test/{SUBTASK}.gcode.3mf",
  55. file_size=2048,
  56. print_name=SUBTASK,
  57. status="printing",
  58. started_at=datetime.now(timezone.utc),
  59. )
  60. self.db.add(archive)
  61. await self.db.commit()
  62. await self.db.refresh(archive)
  63. return archive
  64. async def _drive_print_start(test_engine, printer, *, download_ok: bool) -> None:
  65. """Run ``on_print_start`` against the test database.
  66. ``download_ok`` picks the branch: False leaves the 3MF unreachable and the
  67. no-3MF fallback archive is written inline; True takes the ArchiveService
  68. branch.
  69. """
  70. session_maker = async_sessionmaker(test_engine, class_=AsyncSession, expire_on_commit=False)
  71. state = MagicMock(
  72. current_project_url=f"ftp://{SUBTASK}.gcode.3mf",
  73. sdcard=True,
  74. sdcard_reported=True,
  75. )
  76. patches = [
  77. patch("backend.app.main.async_session", session_maker),
  78. patch("backend.app.core.database.async_session", session_maker),
  79. patch("backend.app.main.download_file_async", new=AsyncMock(return_value=download_ok)),
  80. patch("backend.app.main.download_file_try_paths_async", new=AsyncMock(return_value=None)),
  81. patch("backend.app.main.get_cached_3mf", return_value=None),
  82. patch("backend.app.main.cache_3mf_download"),
  83. patch("backend.app.main.peek_plate_index_in_3mf", return_value=None),
  84. patch("backend.app.main.ArchiveService", _StubArchiveService),
  85. # Imported inside the function, so patching it anywhere else lets the
  86. # directory walk open real sockets.
  87. patch("backend.app.services.bambu_ftp.list_files_async", new=AsyncMock(return_value=[])),
  88. patch("backend.app.main.ftps_handshake_blocked", return_value=False),
  89. patch("backend.app.main.get_ftp_retry_settings", new=AsyncMock(return_value=(False, 3, 2.0, 30))),
  90. patch("backend.app.main._record_energy_start", new_callable=AsyncMock),
  91. patch("backend.app.main._send_print_start_notification", new_callable=AsyncMock),
  92. patch("backend.app.main._maybe_start_layer_timelapse"),
  93. patch("backend.app.main._capture_timelapse_baseline_at_start", new_callable=AsyncMock),
  94. # Real, it would spawn a task that outlives the test by a minute.
  95. patch("backend.app.main._schedule_fallback_3mf_retry"),
  96. patch("backend.app.main._store_spoolman_print_data", new_callable=AsyncMock),
  97. # Imported inside on_print_start; it would try to persist the mocked
  98. # printer state's AMS trays and fail on the MagicMock values.
  99. patch("backend.app.services.usage_tracker.on_print_start", new_callable=AsyncMock),
  100. ]
  101. with ExitStack() as stack:
  102. for p in patches:
  103. stack.enter_context(p)
  104. notif = stack.enter_context(patch("backend.app.main.notification_service"))
  105. plug = stack.enter_context(patch("backend.app.main.smart_plug_manager"))
  106. ws = stack.enter_context(patch("backend.app.main.ws_manager"))
  107. relay = stack.enter_context(patch("backend.app.main.mqtt_relay"))
  108. pm = stack.enter_context(patch("backend.app.main.printer_manager"))
  109. notif.on_print_start = AsyncMock()
  110. plug.on_print_start = AsyncMock()
  111. ws.send_print_start = AsyncMock()
  112. ws.send_archive_created = AsyncMock()
  113. ws.send_archive_updated = AsyncMock()
  114. relay.on_print_start = AsyncMock()
  115. relay.on_archive_created = AsyncMock()
  116. pm.get_status = MagicMock(return_value=state)
  117. pm.get_printer = MagicMock(return_value=MagicMock(serial_number="TEST1898"))
  118. from backend.app.main import on_print_start
  119. await on_print_start(printer.id, {"filename": DISPATCH, "subtask_name": SUBTASK})
  120. async def _set_setting(db_session, key: str, value: str) -> None:
  121. db_session.add(Settings(key=key, value=value))
  122. await db_session.commit()
  123. async def _created_archive(db_session, printer_id: int) -> PrintArchive:
  124. db_session.expire_all()
  125. archive = await db_session.scalar(
  126. select(PrintArchive).where(PrintArchive.printer_id == printer_id).order_by(PrintArchive.id.desc()).limit(1)
  127. )
  128. assert archive is not None, "on_print_start created no archive"
  129. return archive
  130. class TestExternalPrintGetsTheOutcomePrompt:
  131. @pytest.mark.asyncio
  132. @pytest.mark.integration
  133. async def test_no_3mf_fallback_asks_when_the_setting_is_on(self, test_engine, db_session, printer_factory):
  134. """The P1S/A1 case: the 3MF cannot be fetched, the archive is written
  135. inline — and that is the row the completion path reads the flag off."""
  136. printer = await printer_factory()
  137. await _set_setting(db_session, "confirm_outcome_external_prints", "true")
  138. await _drive_print_start(test_engine, printer, download_ok=False)
  139. archive = await _created_archive(db_session, printer.id)
  140. assert archive.extra_data.get("no_3mf_available") is True
  141. assert archive.confirm_requested is True
  142. # What the completion path gates the prompt on.
  143. assert archive.user_verdict is None
  144. @pytest.mark.asyncio
  145. @pytest.mark.integration
  146. async def test_the_archive_reaches_the_rest_of_the_1898_machinery(self, test_engine, db_session, printer_factory):
  147. """An externally started print is now a pending confirmation like any
  148. other: the prompt the completion path emits is gated on exactly these
  149. two fields, and the plate-release default resolves the same row."""
  150. from backend.app.services.print_confirmation import resolve_pending_confirmation_as_good
  151. printer = await printer_factory()
  152. printer_id = printer.id
  153. await _set_setting(db_session, "confirm_outcome_external_prints", "true")
  154. await _drive_print_start(test_engine, printer, download_ok=False)
  155. archive = await _created_archive(db_session, printer_id)
  156. archive.status = "completed"
  157. await db_session.commit()
  158. assert await resolve_pending_confirmation_as_good(db_session, printer_id) == archive.id
  159. @pytest.mark.asyncio
  160. @pytest.mark.integration
  161. async def test_downloaded_3mf_archive_asks_when_the_setting_is_on(self, test_engine, db_session, printer_factory):
  162. """The other creation branch: the 3MF arrived and ArchiveService wrote
  163. the row. The flag is set on the row afterwards rather than passed into
  164. archive_print, which also serves the queue dispatcher."""
  165. printer = await printer_factory()
  166. await _set_setting(db_session, "confirm_outcome_external_prints", "true")
  167. await _drive_print_start(test_engine, printer, download_ok=True)
  168. archive = await _created_archive(db_session, printer.id)
  169. assert archive.file_path.endswith(".3mf")
  170. assert archive.confirm_requested is True
  171. @pytest.mark.asyncio
  172. @pytest.mark.integration
  173. async def test_default_leaves_external_prints_alone(self, test_engine, db_session, printer_factory):
  174. """Default off: nothing about today's behaviour changes for an install
  175. that never touches the new setting — no row for it at all."""
  176. printer = await printer_factory()
  177. await _drive_print_start(test_engine, printer, download_ok=False)
  178. archive = await _created_archive(db_session, printer.id)
  179. assert archive.confirm_requested is False
  180. @pytest.mark.asyncio
  181. @pytest.mark.integration
  182. async def test_setting_off_does_not_ask(self, test_engine, db_session, printer_factory):
  183. printer = await printer_factory()
  184. await _set_setting(db_session, "confirm_outcome_external_prints", "false")
  185. await _drive_print_start(test_engine, printer, download_ok=False)
  186. assert (await _created_archive(db_session, printer.id)).confirm_requested is False
  187. @pytest.mark.asyncio
  188. @pytest.mark.integration
  189. async def test_an_odd_stored_value_counts_as_off(self, test_engine, db_session, printer_factory):
  190. """Settings live in a VARCHAR column and every other reader treats
  191. anything that is not "true" as off."""
  192. printer = await printer_factory()
  193. await _set_setting(db_session, "confirm_outcome_external_prints", "None")
  194. await _drive_print_start(test_engine, printer, download_ok=False)
  195. assert (await _created_archive(db_session, printer.id)).confirm_requested is False
  196. class TestAQueuedPrintStillDecidesForItself:
  197. @pytest.mark.asyncio
  198. @pytest.mark.integration
  199. async def test_a_dispatched_job_is_not_overridden_by_the_setting(
  200. self, test_engine, db_session, printer_factory, archive_factory
  201. ):
  202. """A queue item that deliberately has the ask-for-outcome flag off must
  203. stay off. A restart mid-print empties the expected-print registry, so
  204. the queue row — which the scheduler commits to "printing" before the
  205. MQTT send — is the durable record that Bambuddy started this."""
  206. printer = await printer_factory()
  207. # Dispatched but not yet reported as started: the archive the scheduler
  208. # attached to the row only turns "printing" once on_print_start runs, so
  209. # the name-match resume above cannot find it and the queue row is the
  210. # only record that Bambuddy sent this print.
  211. source = await archive_factory(printer.id, filename=f"{SUBTASK}.gcode.3mf", status="pending", with_run=False)
  212. db_session.add(
  213. PrintQueueItem(
  214. printer_id=printer.id,
  215. archive_id=source.id,
  216. status="printing",
  217. confirm_outcome=False,
  218. )
  219. )
  220. await db_session.commit()
  221. await _set_setting(db_session, "confirm_outcome_external_prints", "true")
  222. await _drive_print_start(test_engine, printer, download_ok=False)
  223. archive = await _created_archive(db_session, printer.id)
  224. assert archive.confirm_requested is False
  225. @pytest.mark.asyncio
  226. @pytest.mark.integration
  227. async def test_a_queue_items_own_yes_survives_print_start(
  228. self, test_engine, db_session, printer_factory, archive_factory
  229. ):
  230. """The dispatcher copies ``confirm_outcome`` onto the archive before
  231. the print starts; the expected-print branch of ``on_print_start`` must
  232. leave that alone even while the external-print setting is off."""
  233. from backend.app.main import register_expected_print
  234. printer = await printer_factory()
  235. archive = await archive_factory(
  236. printer.id,
  237. filename=f"{SUBTASK}.gcode.3mf",
  238. status="pending",
  239. confirm_requested=True,
  240. with_run=False,
  241. )
  242. db_session.add(
  243. PrintQueueItem(
  244. printer_id=printer.id,
  245. archive_id=archive.id,
  246. status="printing",
  247. confirm_outcome=True,
  248. )
  249. )
  250. await db_session.commit()
  251. archive_id, printer_id = archive.id, printer.id
  252. register_expected_print(printer_id, f"{SUBTASK}.gcode.3mf", archive_id)
  253. await _drive_print_start(test_engine, printer, download_ok=False)
  254. db_session.expire_all()
  255. refreshed = await db_session.get(PrintArchive, archive_id)
  256. assert refreshed.status == "printing"
  257. assert refreshed.confirm_requested is True
  258. # No second row for the same print.
  259. rows = (await db_session.scalars(select(PrintArchive).where(PrintArchive.printer_id == printer_id))).all()
  260. assert len(rows) == 1
  261. class TestSettingsRoundTrip:
  262. @pytest.mark.asyncio
  263. @pytest.mark.integration
  264. async def test_defaults_to_off_and_round_trips(self, async_client):
  265. response = await async_client.get("/api/v1/settings/")
  266. assert response.status_code == 200
  267. assert response.json()["confirm_outcome_external_prints"] is False
  268. response = await async_client.put("/api/v1/settings/", json={"confirm_outcome_external_prints": True})
  269. assert response.status_code == 200
  270. assert response.json()["confirm_outcome_external_prints"] is True
  271. assert (await async_client.get("/api/v1/settings/")).json()["confirm_outcome_external_prints"] is True
  272. response = await async_client.put("/api/v1/settings/", json={"confirm_outcome_external_prints": False})
  273. assert response.status_code == 200
  274. assert (await async_client.get("/api/v1/settings/")).json()["confirm_outcome_external_prints"] is False
  275. @pytest.mark.asyncio
  276. @pytest.mark.integration
  277. async def test_updating_it_leaves_the_per_job_default_alone(self, async_client):
  278. """Two different questions: one seeds the per-job toggle in the print
  279. dialog, the other covers prints that never see that dialog."""
  280. await async_client.put("/api/v1/settings/", json={"default_confirm_outcome": True})
  281. body = (await async_client.put("/api/v1/settings/", json={"confirm_outcome_external_prints": True})).json()
  282. assert body["default_confirm_outcome"] is True
  283. assert body["confirm_outcome_external_prints"] is True
  284. class TestAStrandedQueueRowDoesNotMuteTheSetting:
  285. """A ``printing`` row is not proof that Bambuddy started what is printing now.
  286. ``_completion_belongs_to_queue_item`` deliberately leaves a row open when a
  287. completion's subtask name disagrees with the file it was dispatched with,
  288. and the scheduler's stranded sweep only takes it back once the printer has
  289. sat connected and terminal for minutes. Treating any such row as "we
  290. dispatched this" switched the setting off for every screen-started print in
  291. between -- the exact symptom the setting exists to cure.
  292. """
  293. @pytest.mark.asyncio
  294. @pytest.mark.integration
  295. async def test_a_row_left_open_for_another_file_still_asks(
  296. self, test_engine, db_session, printer_factory, archive_factory
  297. ):
  298. printer = await printer_factory()
  299. stranded_for = await archive_factory(
  300. printer.id, filename="SomeOtherJob.gcode.3mf", status="printing", with_run=False
  301. )
  302. db_session.add(
  303. PrintQueueItem(
  304. printer_id=printer.id,
  305. archive_id=stranded_for.id,
  306. status="printing",
  307. confirm_outcome=False,
  308. )
  309. )
  310. await db_session.commit()
  311. await _set_setting(db_session, "confirm_outcome_external_prints", "true")
  312. stranded_filename = stranded_for.filename
  313. await _drive_print_start(test_engine, printer, download_ok=False)
  314. archive = await _created_archive(db_session, printer.id)
  315. assert archive.filename != stranded_filename
  316. assert archive.confirm_requested is True
  317. class TestAReprintAsksAgain:
  318. """The reprint reuses the archive row, and the completion prompt is gated on
  319. ``user_verdict is None`` -- so without a reset the second run inherits the
  320. first run's answer and is never asked about."""
  321. @pytest.mark.asyncio
  322. @pytest.mark.integration
  323. async def test_the_previous_runs_verdict_does_not_carry_over(
  324. self, test_engine, db_session, printer_factory, archive_factory
  325. ):
  326. from backend.app.main import register_expected_print
  327. printer = await printer_factory()
  328. archive = await archive_factory(
  329. printer.id,
  330. filename=f"{SUBTASK}.gcode.3mf",
  331. status="completed",
  332. confirm_requested=True,
  333. user_verdict="good",
  334. confirm_token="token-from-the-first-run",
  335. with_run=False,
  336. )
  337. archive_id, printer_id = archive.id, printer.id
  338. register_expected_print(printer_id, f"{SUBTASK}.gcode.3mf", archive_id)
  339. await _drive_print_start(test_engine, printer, download_ok=False)
  340. db_session.expire_all()
  341. refreshed = await db_session.get(PrintArchive, archive_id)
  342. assert refreshed.status == "printing"
  343. assert refreshed.confirm_requested is True
  344. assert refreshed.user_verdict is None
  345. assert refreshed.confirm_token is None
  346. # And the completion really does ask again, which is the point.
  347. refreshed.status = "completed"
  348. await db_session.commit()
  349. sent, ws, notif = await _dispatch(db_session, printer_id, archive_id)
  350. assert sent is True
  351. ws.send_print_confirm_request.assert_awaited_once()
  352. notif.on_print_confirm_request.assert_awaited_once()
  353. @pytest.mark.asyncio
  354. @pytest.mark.integration
  355. async def test_an_archive_that_was_never_asked_about_keeps_its_verdict(
  356. self, test_engine, db_session, printer_factory, archive_factory
  357. ):
  358. """The reset is scoped to rows that ask. An archive answered once and
  359. later reprinted with the flag off must keep the answer it has."""
  360. from backend.app.main import register_expected_print
  361. printer = await printer_factory()
  362. archive = await archive_factory(
  363. printer.id,
  364. filename=f"{SUBTASK}.gcode.3mf",
  365. status="completed",
  366. confirm_requested=False,
  367. user_verdict="reject",
  368. with_run=False,
  369. )
  370. archive_id = archive.id
  371. register_expected_print(printer.id, f"{SUBTASK}.gcode.3mf", archive_id)
  372. await _drive_print_start(test_engine, printer, download_ok=False)
  373. db_session.expire_all()
  374. assert (await db_session.get(PrintArchive, archive_id)).user_verdict == "reject"
  375. async def _dispatch(db_session, printer_id: int, archive_id: int, **kwargs):
  376. """Run the completion path's outcome dispatch with the two emitters mocked."""
  377. from backend.app.main import dispatch_outcome_confirmation
  378. with (
  379. patch("backend.app.main.ws_manager") as ws,
  380. patch("backend.app.main.notification_service") as notif,
  381. ):
  382. ws.send_print_confirm_request = AsyncMock()
  383. notif.on_print_confirm_request = AsyncMock()
  384. sent = await dispatch_outcome_confirmation(
  385. db_session,
  386. printer_id,
  387. "Bench P1S",
  388. {"subtask_name": SUBTASK},
  389. archive_id,
  390. **kwargs,
  391. )
  392. return sent, ws, notif
  393. class TestTheCompletionEmitsThePrompt:
  394. """The half of the feature the user actually sees.
  395. Everything else here asserts a column value; this drives the block
  396. ``on_print_complete``'s notification task runs -- which is wrapped in a bare
  397. ``except Exception`` that only logs, so a regression in it is invisible
  398. unless something pins it.
  399. """
  400. @pytest.mark.asyncio
  401. @pytest.mark.integration
  402. async def test_an_external_print_gets_a_prompt_with_one_tap_links(self, test_engine, db_session, printer_factory):
  403. printer = await printer_factory()
  404. printer_id = printer.id
  405. await _set_setting(db_session, "confirm_outcome_external_prints", "true")
  406. await _set_setting(db_session, "external_url", "https://farm.example.com/")
  407. await _drive_print_start(test_engine, printer, download_ok=False)
  408. archive = await _created_archive(db_session, printer_id)
  409. archive_id = archive.id
  410. assert archive.confirm_requested is True
  411. archive.status = "completed"
  412. await db_session.commit()
  413. sent, ws, notif = await _dispatch(db_session, printer_id, archive_id)
  414. assert sent is True
  415. ws.send_print_confirm_request.assert_awaited_once()
  416. assert ws.send_print_confirm_request.await_args.args[1]["archive_id"] == archive_id
  417. notif.on_print_confirm_request.assert_awaited_once()
  418. kwargs = notif.on_print_confirm_request.await_args.kwargs
  419. token = (await db_session.get(PrintArchive, archive_id)).confirm_token
  420. assert token, "the one-tap links need a minted capability token"
  421. assert kwargs["good_url"] == f"https://farm.example.com/api/v1/archives/confirm/{token}/good"
  422. assert kwargs["reject_url"] == f"https://farm.example.com/api/v1/archives/confirm/{token}/reject"
  423. assert kwargs["confirm_url"] == f"https://farm.example.com/archives?confirm={archive_id}"
  424. @pytest.mark.asyncio
  425. @pytest.mark.integration
  426. async def test_the_links_stay_absolute_without_an_external_url(self, test_engine, db_session, printer_factory):
  427. """Telegram's inline keyboard and ntfy's action buttons are both dropped
  428. for a relative URL, so an install that never set external_url used to
  429. get a message carrying two unusable paths and no buttons at all."""
  430. printer = await printer_factory()
  431. printer_id = printer.id
  432. await _set_setting(db_session, "confirm_outcome_external_prints", "true")
  433. await _drive_print_start(test_engine, printer, download_ok=False)
  434. archive = await _created_archive(db_session, printer_id)
  435. archive_id = archive.id
  436. archive.status = "completed"
  437. await db_session.commit()
  438. _, _, notif = await _dispatch(db_session, printer_id, archive_id)
  439. kwargs = notif.on_print_confirm_request.await_args.kwargs
  440. assert kwargs["good_url"].startswith("http")
  441. assert kwargs["reject_url"].startswith("http")
  442. assert kwargs["confirm_url"].startswith("http")
  443. @pytest.mark.asyncio
  444. @pytest.mark.integration
  445. async def test_an_already_answered_archive_is_not_asked_again(self, db_session, printer_factory, archive_factory):
  446. printer = await printer_factory()
  447. archive = await archive_factory(
  448. printer.id, status="completed", confirm_requested=True, user_verdict="good", with_run=False
  449. )
  450. sent, ws, notif = await _dispatch(db_session, printer.id, archive.id)
  451. assert sent is False
  452. ws.send_print_confirm_request.assert_not_awaited()
  453. notif.on_print_confirm_request.assert_not_awaited()
  454. @pytest.mark.asyncio
  455. @pytest.mark.integration
  456. async def test_an_archive_that_never_opted_in_is_not_asked(self, db_session, printer_factory, archive_factory):
  457. printer = await printer_factory()
  458. archive = await archive_factory(printer.id, status="completed", confirm_requested=False, with_run=False)
  459. sent, _, notif = await _dispatch(db_session, printer.id, archive.id)
  460. assert sent is False
  461. notif.on_print_confirm_request.assert_not_awaited()