[FIX] test_themes: run configurator standalone test under mocked request

Commit [1] copies configurator pages during the flow. When the
standalone test leaves website_id in the context, that copy now tries
to create generic views with a website-scoped environment and hits the
ir.ui.view guard. Running the configurator inside MockRequest mimics the
real HTTP context (request-driven website, no forced id on the ORM), so
the copy succeeds and the test passes again.

[1]: https://github.com/odoo/odoo/commit/4231c9e545fdebdad034a4418f2a11e6691bac61

runbot-232963

closes odoo/design-themes#1160

X-original-commit: 501f57e840
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
Serge Bayet (seba)
2025-09-29 12:11:55 +00:00
parent 12243da5ce
commit 23c7f7c1da
+14 -9
View File
@@ -1,6 +1,8 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details. # Part of Odoo. See LICENSE file for full copyright and licensing details.
from unittest.mock import patch from unittest.mock import patch
from odoo.addons.http_routing.tests.common import MockRequest
from odoo.tests import standalone from odoo.tests import standalone
@@ -63,12 +65,15 @@ def test_02_theme_default_generate_primary_templates(env):
template_key = f'website.configurator_{page}_{snippet}' template_key = f'website.configurator_{page}_{snippet}'
assert template_key in template_keys, f"{template_key} should exist" assert template_key in template_keys, f"{template_key} should exist"
env['website'].with_context(website_id=1).configurator_apply( website = env['website'].search([], limit=1)
selected_features=[1, 2, 3, 4], website.ensure_one()
industry_id=2836, with MockRequest(env, website=website):
industry_name='private university', website.configurator_apply(
selected_palette='default-15', selected_features=[1, 2, 3, 4],
theme_name='theme_bewise', industry_id=2836,
website_purpose='get_leads', industry_name='private university',
website_type='business', selected_palette='default-15',
) theme_name='theme_bewise',
website_purpose='get_leads',
website_type='business',
)