kokhlo opened a new pull request, #44437:
URL: https://github.com/apache/superset/pull/44437

   ## Summary
   
   Fixes the six master-red tests in 
`tests/unit_tests/commands/test_base_restore_version_command.py` (#44436) so 
`unit-tests-required` stops reddening every PR built against master's tip.
   
   The two failing drivers feed `run()` a bare `MagicMock()` entity. Since 
#44015, `_do_restore()` issues a real locking re-read 
(`populate_existing().with_for_update()`) *before* `resolve_version`, and the 
mock's auto-created `id` cannot bind into that query 
(`sqlite3.ProgrammingError`). The `@transaction(catches=(SQLAlchemyError, 
LookupError))` wrapper translates the binding error into `failed_exc`, so the 
patched `resolve_version` / `restore_version` seams are never reached — 
producing exactly the six reported failures (wrong `__cause__`, and the "passes 
through untranslated" driver seeing a translated error).
   
   Fix is test-side, per the issue: `_validate_context` now gives the mock 
entity a real integer `id` and stubs `superset.commands.version_restore.db` 
with a self-returning query chain whose `one_or_none()` hands the entity back — 
the same wiring `test_restore_version_concurrency.py` already uses for the lock 
itself. `validate()`-only tests are unaffected; the row lock in `_do_restore()` 
is untouched.
   
   ## Test plan
   
   - [x] RED on pristine master: exactly the six tests from the issue fail (`6 
failed, 6 passed`)
   - [x] GREEN with the patch: `12 passed` for the full file
   - [x] Neighbours unaffected: `test_restore_version_concurrency.py` + 
`tests/unit_tests/versioning` = `291 passed`
   - [x] `ruff check` + `ruff format --check` clean
   
   Closes #44436


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to