Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
test(SKY-12248): unbreak main — make file-upload log assertion order-independent (#7304)
Suchintan9ceee3272608
diff --git a/tests/unit/test_file_upload_prompt.py b/tests/unit/test_file_upload_prompt.pyindex 6c8022ff4..821daedf5 100644--- a/tests/unit/test_file_upload_prompt.py+++ b/tests/unit/test_file_upload_prompt.py@@ -1,7 +1,6 @@from __future__ import annotationsimport json-import loggingimport unicodedatafrom datetime import UTC, datetimefrom pathlib import Path@@ -10,6 +9,8 @@ from unittest.mock import AsyncMock, MagicMock, patchimport libcst as cstimport pytest+import structlog+import structlog.testingfrom skyvern.core.script_generations.generate_script import _build_file_upload_statementfrom skyvern.forge.prompts import prompt_engine@@ -322,17 +323,17 @@ async def test_prompt_requires_exact_match_for_nfc_collisions(tmp_path: Path) ->@pytest.mark.asyncioasync def test_prompt_selecting_zero_files_completes_and_records_empty_output(tmp_path: Path,- caplog: pytest.LogCaptureFixture,) -> None:download_dir = tmp_path / "downloads"_write_candidates(download_dir)response = {"reasoning": "No candidates match.", "files_to_upload": []}- execution = await _execute_file_upload(- _file_upload_block("Only upload XML files."),- download_dir,- llm_response=response,- )+ with structlog.testing.capture_logs() as captured_logs:+ execution = await _execute_file_upload(+ _file_upload_block("Only upload XML files."),+ download_dir,+ llm_response=response,+ )assert execution.result.success is Trueassert execution.result.status == BlockStatus.completed@@ -344,9 +345,9 @@ async def test_prompt_selecting_zero_files_completes_and_records_empty_output([],)zero_selection_warnings = [- record- for record in caplog.records- if record.levelno == logging.WARNING and "prompt selected no files" in record.getMessage()+ event+ for event in captured_logs+ if event.get("log_level") == "warning" and "prompt selected no files" in event.get("event", "")]assert len(zero_selection_warnings) == 1expected_fields = {@@ -356,14 +357,9 @@ async def test_prompt_selecting_zero_files_completes_and_records_empty_output("selected_count": 0,"reasoning": "No candidates match.",}- warning_record = zero_selection_warnings[0]- if isinstance(warning_record.msg, dict):- for field, value in expected_fields.items():- assert warning_record.msg[field] == value- else:- warning_message = warning_record.getMessage()- for field, value in expected_fields.items():- assert f"{field}={value}" in warning_message+ warning_event = zero_selection_warnings[0]+ for field, value in expected_fields.items():+ assert warning_event[field] == value@pytest.mark.asyncio