fix: set body_html on mock response; remove dangling log assertion
- _make_mock_llm_response now sets body_html/raw_text (not just text). _create_blog_post writes body_html into blog.post.content; an unset MagicMock attr stringified to ~66 chars, failing the 500-char assertion. - Remove leftover `assert log.tokens_used` in then_tokens_used_recorded that referenced a variable deleted in the prior router-level rewrite. Full suite: 69 passed, 0 failed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a0d2ba5506
commit
42cd6c7aa5
1 changed files with 7 additions and 4 deletions
|
|
@ -98,7 +98,13 @@ def given_invalid_api_key(odoo_env, ctx):
|
||||||
|
|
||||||
def _make_mock_llm_response(topic='AI Trends'):
|
def _make_mock_llm_response(topic='AI Trends'):
|
||||||
resp = MagicMock()
|
resp = MagicMock()
|
||||||
resp.text = f'<h1>{topic}</h1>' + '<p>' + ('Content. ' * 60) + '</p>'
|
# _create_blog_post writes llm_response.body_html into blog.post.content,
|
||||||
|
# so body_html must be a real string (not an auto-MagicMock) and long
|
||||||
|
# enough to satisfy the 500-char content assertion.
|
||||||
|
body = f'<h1>{topic}</h1>' + '<p>' + ('Content. ' * 60) + '</p>'
|
||||||
|
resp.text = body
|
||||||
|
resp.body_html = body
|
||||||
|
resp.raw_text = body
|
||||||
resp.tokens_used = 850
|
resp.tokens_used = 850
|
||||||
resp.title = topic
|
resp.title = topic
|
||||||
resp.meta_title = f'{topic} — Enterprise Guide 2026'[:60]
|
resp.meta_title = f'{topic} — Enterprise Guide 2026'[:60]
|
||||||
|
|
@ -345,9 +351,6 @@ def then_tokens_used_recorded(ctx, min_tokens):
|
||||||
assert result.tokens_used > min_tokens, (
|
assert result.tokens_used > min_tokens, (
|
||||||
f"Expected tokens_used > {min_tokens}, got {result.tokens_used}"
|
f"Expected tokens_used > {min_tokens}, got {result.tokens_used}"
|
||||||
)
|
)
|
||||||
assert log.tokens_used > min_tokens, (
|
|
||||||
f"tokens_used={log.tokens_used} must be > {min_tokens}"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# ================================================================= #
|
# ================================================================= #
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue