Fix no-op assertion in MaxCompute run_sql test#69406
Conversation
The test asserted `mock_client.run_sql.asssert_called_once_with(...)` with a misspelled `asssert`. On a MagicMock that attribute is auto-created, so calling it returns a truthy mock and the wrapping `assert` always passed, leaving the hook's argument forwarding to `client.run_sql` unverified, including the branch that derives `priority` from the `odps.instance.priority` hint. Use the real `assert_called_once_with` and parametrize the test to cover explicit priority, priority derived from hints, and no priority so the forwarded arguments are actually checked. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
|
Confirmed the root cause against the hook source. The old line was |
The
test_run_sqlcase in the Alibaba provider assertedmock_client.run_sql.asssert_called_once_with(...)with a misspelledasssert(three s's). On a
MagicMock, that attribute is auto-created as a child mock, socalling it returns a truthy mock and the wrapping
assertalways passed. This isthe only assertion of
MaxComputeHook.run_sql's argument forwarding toclient.run_sql, so the forwarded keyword arguments were never actually checked,including the branch that derives
priorityfrom theodps.instance.priorityhint when no explicit priority is given.
This replaces the no-op with a real
assert_called_once_with(a bare statement,matching the sibling
test_get_instance/test_stop_instance_successcases) andparametrizes the test over three cases so the forwarded arguments are genuinely
verified:
explicit-priority: an explicitpriorityis forwarded unchanged (derivationbranch not taken).
priority-from-hints:priority=Nonewithhints={"odps.instance.priority": 5}is derived to
5(derivation branch taken, previously untested).no-priority:priority=Noneandhints=NonestaysNone.Test-only change. Confirmed red -> green: correcting the assertion turns it from
always-passing into a real check, and disabling the derivation branch in the hook
makes only the
priority-from-hintscase fail.rg "asssert"across the repo nowreturns zero matches.
Was generative AI tooling used to co-author this PR?