with allure.step(
f"Этап 2. Ожидание пуш-нотификации {ReportConst.REPORT_DATA_EXPORTED_NOTIFICATION} о готовности отчёта"
):
report_state.notification = await t_utils.poll_for_report_export_notification(
ws_client=ws_client,
parser=parser,
total_wait_seconds=ReportConst.NOTIFICATION_TIMEOUT_SECONDS,
poll_interval_seconds=ReportConst.LIST_POLL_INTERVAL_SECONDS,
debug_context=str(request_payload),
)
StepCheck("Получена пуш-нотификация о готовности отчёта", "notification").actual(
report_state.notification
).is_not_none()
StepCheck("Проверка статуса пуш-нотификации", "replyStatus").actual(
report_state.notification.replyStatus if report_state.notification else None
).expected(ReplyStatus.OK.value).equal_to()
StepCheck("Проверка наличия контента нотификации", "replyContent").actual(
report_state.notification.replyContent if report_state.notification else None
).is_not_none()
StepCheck("Проверка exportStatus в нотификации", "exportStatus").actual(
report_state.notification.replyContent.exportStatus
if report_state.notification and report_state.notification.replyContent
else None
).expected(ExportStatus.DONE).equal_to()
StepCheck("Проверка отсутствия ошибки в нотификации", "errorMessage").actual(
(report_state.notification.replyContent.errorMessage or "")
if report_state.notification and report_state.notification.replyContent
else None
).expected("").equal_to()
with allure.step(
f"Этап 3. Лонг-поллинг {ReportConst.GET_EXPORTED_FILES_LIST_REQUEST} до появления отчёта в списке"
):
report_state.report_item = await t_utils.poll_for_exported_file(
ws_client=ws_client,
parser=parser,
tu_id=cfg.tu_id,
expected_data_type=ExportedDataType.LEAKS_REPORT,
name_substring=ReportConst.LEAKS_REPORT_NAME_PART,
period_start=report_state.period_start,
period_end=report_state.period_end,
total_wait_seconds=ReportConst.LIST_POLL_TOTAL_WAIT_SECONDS,
poll_interval_seconds=ReportConst.LIST_POLL_INTERVAL_SECONDS,
debug_context=(
f"notification_id="
f"{report_state.notification.replyContent.id}"
if report_state.notification and report_state.notification.replyContent
else "notification отсутствует"
)
+ f", period={report_state.period_start} — {report_state.period_end}",
)
StepCheck("Отчёт найден в списке сформированных файлов", "report_item").actual(
report_state.report_item
).is_not_none()
report_item = report_state.report_item
allure.attach(
f"id={report_item.id}, name={report_item.name}, "
f"exportedDataType={report_item.exportedDataType}, "
f"start={report_item.start}, end={report_item.end}",
name="Найденный отчёт в списке",
attachment_type=allure.attachment_type.TEXT,
)
report_state.report_file_name = report_item.name + ReportConst.XLSX_EXTENSION