From e83df03bd088b2d91bf2ed59be824fbc96acc446 Mon Sep 17 00:00:00 2001 From: Nicholas Riegel Date: Sat, 30 May 2026 02:48:00 -0400 Subject: [PATCH] fix: use _generate_template() and request.getfixturevalue() for Odoo 17 - mail.template has no generate_email() in Odoo 17; use _generate_template() which takes (res_ids, render_fields) and returns rendered values per res_id - Fix odoo_env fixture in test_bdd_steps.py to use request.getfixturevalue('env') so pytest-bdd can resolve the pytest-odoo env fixture at scenario runtime Co-Authored-By: Claude Sonnet 4.6 --- addons/itsulu_blog_publisher/tests/test_bdd_steps.py | 4 ++-- addons/itsulu_blog_publisher/tests/test_blog_post_social.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/itsulu_blog_publisher/tests/test_bdd_steps.py b/addons/itsulu_blog_publisher/tests/test_bdd_steps.py index c7fd5c4..c7a7a7a 100644 --- a/addons/itsulu_blog_publisher/tests/test_bdd_steps.py +++ b/addons/itsulu_blog_publisher/tests/test_bdd_steps.py @@ -24,9 +24,9 @@ scenarios('../features/notification_email.feature') # ================================================================= # @pytest.fixture -def odoo_env(env): +def odoo_env(request): """pytest-odoo's env fixture, re-exported for BDD step access.""" - return env + return request.getfixturevalue('env') @pytest.fixture diff --git a/addons/itsulu_blog_publisher/tests/test_blog_post_social.py b/addons/itsulu_blog_publisher/tests/test_blog_post_social.py index 3ab435c..24f0ffd 100644 --- a/addons/itsulu_blog_publisher/tests/test_blog_post_social.py +++ b/addons/itsulu_blog_publisher/tests/test_blog_post_social.py @@ -254,7 +254,7 @@ class TestNotificationEmail(TransactionCase): # ACT — render the template synchronously to check the subject template = self.env.ref('itsulu_blog_publisher.email_template_blog_published') - rendered = template.generate_email([log.id], fields=['subject']) + rendered = template._generate_template([log.id], fields=['subject']) # ASSERT subject = rendered[log.id].get('subject', '') @@ -300,7 +300,7 @@ class TestNotificationEmail(TransactionCase): # Verify template renders all platform copy in the body template = self.env.ref('itsulu_blog_publisher.email_template_blog_published') - rendered = template.generate_email([log.id], fields=['body_html']) + rendered = template._generate_template([log.id], fields=['body_html']) body = rendered[log.id].get('body_html', '') self.assertIn('Twitter A copy', body, "Body must contain Twitter copy") self.assertIn('LinkedIn copy', body, "Body must contain LinkedIn copy") @@ -319,7 +319,7 @@ class TestNotificationEmail(TransactionCase): # ASSERT — render the template synchronously to check the URL appears in the body template = self.env.ref('itsulu_blog_publisher.email_template_blog_published') - rendered = template.generate_email([log.id], fields=['body_html']) + rendered = template._generate_template([log.id], fields=['body_html']) body = rendered[log.id].get('body_html', '') self.assertIn('itsulu.com', body, "Body must contain itsulu.com URL")