diff --git a/addons/itsulu_blog_publisher/tests/test_bdd_steps.py b/addons/itsulu_blog_publisher/tests/test_bdd_steps.py index c7a7a7a..211fc02 100644 --- a/addons/itsulu_blog_publisher/tests/test_bdd_steps.py +++ b/addons/itsulu_blog_publisher/tests/test_bdd_steps.py @@ -8,6 +8,8 @@ Links: blog_generation.feature, blog_scheduling.feature, RED PHASE — all scenarios FAIL until implementation exists. """ import pytest +import odoo +from odoo.api import Environment from unittest.mock import patch, MagicMock from pytest_bdd import scenarios, given, when, then, parsers @@ -25,8 +27,18 @@ scenarios('../features/notification_email.feature') @pytest.fixture def odoo_env(request): - """pytest-odoo's env fixture, re-exported for BDD step access.""" - return request.getfixturevalue('env') + """Odoo environment for BDD step definitions. + + pytest-odoo 2.x does not expose an 'env' pytest fixture — env only + exists as self.env inside TransactionCase subclasses. We build one + directly from the registry and roll back after each scenario. + """ + db = request.config.getoption('--odoo-database') + registry = odoo.registry(db) + with registry.cursor() as cr: + env = Environment(cr, odoo.SUPERUSER_ID, {}) + yield env + cr.rollback() @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 24f0ffd..20913da 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_template([log.id], fields=['subject']) + rendered = template._generate_template([log.id], ['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_template([log.id], fields=['body_html']) + rendered = template._generate_template([log.id], ['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_template([log.id], fields=['body_html']) + rendered = template._generate_template([log.id], ['body_html']) body = rendered[log.id].get('body_html', '') self.assertIn('itsulu.com', body, "Body must contain itsulu.com URL")