From 42cd6c7aa5f9bcd32968c8cdc0e1bfe5e7d8567c Mon Sep 17 00:00:00 2001 From: Nicholas Riegel Date: Sat, 30 May 2026 03:14:38 -0400 Subject: [PATCH] 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 --- addons/itsulu_blog_publisher/tests/test_bdd_steps.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/itsulu_blog_publisher/tests/test_bdd_steps.py b/addons/itsulu_blog_publisher/tests/test_bdd_steps.py index 027d748..acc2c03 100644 --- a/addons/itsulu_blog_publisher/tests/test_bdd_steps.py +++ b/addons/itsulu_blog_publisher/tests/test_bdd_steps.py @@ -98,7 +98,13 @@ def given_invalid_api_key(odoo_env, ctx): def _make_mock_llm_response(topic='AI Trends'): resp = MagicMock() - resp.text = f'

{topic}

' + '

' + ('Content. ' * 60) + '

' + # _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'

{topic}

' + '

' + ('Content. ' * 60) + '

' + resp.text = body + resp.body_html = body + resp.raw_text = body resp.tokens_used = 850 resp.title = topic 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, ( 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}" - ) # ================================================================= #