geng
This commit is contained in:
@@ -298,7 +298,7 @@ def test_action_visibility_requires_exact_canonical_permissions(
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_refresh_generation_ignores_late_results(
|
||||
def test_refresh_generation_ignores_late_results(
|
||||
application: QApplication,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
@@ -318,11 +318,81 @@ def test_refresh_generation_ignores_late_results(
|
||||
application.processEvents()
|
||||
|
||||
assert page.table.rowCount() == 1
|
||||
assert page.table.item(0, 0).text().startswith("902")
|
||||
page.close()
|
||||
|
||||
|
||||
def test_current_appointment_is_the_only_prescription_authority(
|
||||
assert page.table.item(0, 0).text().startswith("902")
|
||||
page.close()
|
||||
|
||||
|
||||
def test_identical_silent_refresh_has_zero_model_reset_and_fixed_widget_budget(
|
||||
application: QApplication,
|
||||
immediate_async: None,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
class Repository:
|
||||
calls = 0
|
||||
|
||||
def list_consultations(self, **_kwargs: Any) -> dict[str, Any]:
|
||||
self.calls += 1
|
||||
return {"lists": [_row()], "count": 1}
|
||||
|
||||
repository = Repository()
|
||||
page = ConsultationsPage(repository, permissions=PermissionSet(["*"]))
|
||||
page.refresh(silent=True)
|
||||
page.table.selectRow(0)
|
||||
model = page.table_host.model
|
||||
action_widget = page.table_host.fixed.indexWidget(model.index(0, 11))
|
||||
video_widget = page.table_host.fixed.indexWidget(model.index(0, 10))
|
||||
resets: list[str] = []
|
||||
model.modelAboutToBeReset.connect(lambda: resets.append("begin"))
|
||||
model.modelReset.connect(lambda: resets.append("end"))
|
||||
install_calls: list[None] = []
|
||||
original_install = page.table_host._install_fixed_widgets
|
||||
|
||||
def count_install() -> None:
|
||||
install_calls.append(None)
|
||||
original_install()
|
||||
|
||||
monkeypatch.setattr(page.table_host, "_install_fixed_widgets", count_install)
|
||||
page.refresh(silent=True)
|
||||
|
||||
assert repository.calls == 2
|
||||
assert resets == []
|
||||
assert install_calls == []
|
||||
assert page.table_host.fixed.indexWidget(model.index(0, 11)) is action_widget
|
||||
assert page.table_host.fixed.indexWidget(model.index(0, 10)) is video_widget
|
||||
assert page.table.currentIndex().row() == 0
|
||||
page.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_timer_poll_has_one_request_budget_while_refresh_is_in_flight(
|
||||
application: QApplication,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
jobs: list[dict[str, Any]] = []
|
||||
|
||||
def queue_async(_function: Any, **options: Any) -> object:
|
||||
jobs.append(options)
|
||||
return object()
|
||||
|
||||
monkeypatch.setattr(consultations_module, "run_async", queue_async)
|
||||
page = ConsultationsPage(SimpleNamespace(), permissions=PermissionSet(["*"]))
|
||||
monkeypatch.setattr(page, "isVisible", lambda: True)
|
||||
monkeypatch.setattr(page, "_refresh_counts", lambda: None)
|
||||
|
||||
page._poll_refresh()
|
||||
page._poll_refresh()
|
||||
page._poll_refresh()
|
||||
|
||||
assert len(jobs) == 1
|
||||
assert page._loading
|
||||
jobs[0]["on_success"]({"lists": [_row()], "count": 1})
|
||||
jobs[0]["on_finished"]()
|
||||
assert not page._loading
|
||||
page.close()
|
||||
application.processEvents()
|
||||
|
||||
|
||||
def test_current_appointment_is_the_only_prescription_authority(
|
||||
application: QApplication,
|
||||
) -> None:
|
||||
calls: list[tuple[str, int]] = []
|
||||
|
||||
Reference in New Issue
Block a user