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 <noreply@anthropic.com>
This commit is contained in:
parent
b4d5502d9f
commit
e83df03bd0
2 changed files with 5 additions and 5 deletions
|
|
@ -24,9 +24,9 @@ scenarios('../features/notification_email.feature')
|
||||||
# ================================================================= #
|
# ================================================================= #
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def odoo_env(env):
|
def odoo_env(request):
|
||||||
"""pytest-odoo's env fixture, re-exported for BDD step access."""
|
"""pytest-odoo's env fixture, re-exported for BDD step access."""
|
||||||
return env
|
return request.getfixturevalue('env')
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ class TestNotificationEmail(TransactionCase):
|
||||||
|
|
||||||
# ACT — render the template synchronously to check the subject
|
# ACT — render the template synchronously to check the subject
|
||||||
template = self.env.ref('itsulu_blog_publisher.email_template_blog_published')
|
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
|
# ASSERT
|
||||||
subject = rendered[log.id].get('subject', '')
|
subject = rendered[log.id].get('subject', '')
|
||||||
|
|
@ -300,7 +300,7 @@ class TestNotificationEmail(TransactionCase):
|
||||||
|
|
||||||
# Verify template renders all platform copy in the body
|
# Verify template renders all platform copy in the body
|
||||||
template = self.env.ref('itsulu_blog_publisher.email_template_blog_published')
|
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', '')
|
body = rendered[log.id].get('body_html', '')
|
||||||
self.assertIn('Twitter A copy', body, "Body must contain Twitter copy")
|
self.assertIn('Twitter A copy', body, "Body must contain Twitter copy")
|
||||||
self.assertIn('LinkedIn copy', body, "Body must contain LinkedIn 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
|
# ASSERT — render the template synchronously to check the URL appears in the body
|
||||||
template = self.env.ref('itsulu_blog_publisher.email_template_blog_published')
|
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', '')
|
body = rendered[log.id].get('body_html', '')
|
||||||
self.assertIn('itsulu.com', body, "Body must contain itsulu.com URL")
|
self.assertIn('itsulu.com', body, "Body must contain itsulu.com URL")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue