Skip to content

fix: Dialogue Quota Verification - #7932

Merged
shaohuzhang1 merged 1 commit into
v3from
pr@v3@fix_token_quota
Nov 16, 2026
Merged

shaohuzhang1 merged 1 commit into
v3from
pr@v3@fix_token_quota

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: Dialogue Quota Verification

save_failure_record.assert_called_once()

def test_available_quota_lets_workflow_run(self):
"""配额未用尽时,前置校验不拦截,正常进入工作流。"""

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch is syntactically fine and the new mock/assertion will work. Main review points:

  • Weak assertion: save_failure_record.assert_called_once() only checks that it was called once. It does not verify the failure details. Prefer assert_called_once_with(...) or inspect call_args to confirm the expected exception/context is passed.
  • Test name/scope: The test name only mentions “rejected before workflow runs,” but the test now also verifies failure-record persistence. Consider renaming it or splitting the assertion into a separate test.
  • Missing negative coverage: In test_available_quota_lets_workflow_run, consider patching save_failure_record and asserting assert_not_called() so a success path cannot accidentally save a failure record.
  • Alias naming: save_failure_record shadows the patched method name. A clearer alias such as save_failure_record_mock would improve readability.
  • Line length: The added line is about 87 characters. If the project enforces 79-character lines, wrap it or use a shorter alias.
  • Signature validation: Consider patch.object(..., autospec=True) if you want the mock to catch signature mismatches.
  • Persistence not verified: If save_failure_record writes to a DB or external system, this unit test only verifies the call, not that the record is actually persisted. Add an integration test if that behavior matters.

No blocking issue with patch ordering or context-manager usage.

@shaohuzhang1
shaohuzhang1 merged commit b0c89fe into v3 Nov 16, 2026
3 of 4 checks passed
@shaohuzhang1
shaohuzhang1 deleted the pr@v3@fix_token_quota branch November 16, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant