From 1d47f8ad5764537e7a811b816b48e0a8c0018edd Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 19 Jan 2024 23:45:59 +0100 Subject: [PATCH] [IMP] test_themes: add test for fix about primary template generation See previous commit. closes odoo/design-themes#761 X-original-commit: 14c3bbb9ff71c3763467777e52a9fcf2c4413180 Related: odoo/odoo#151375 Signed-off-by: Romain Derie (rde) --- test_themes/tests/__init__.py | 1 + test_themes/tests/test_theme_standalone.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/test_themes/tests/__init__.py b/test_themes/tests/__init__.py index b4c023770..9c8587923 100644 --- a/test_themes/tests/__init__.py +++ b/test_themes/tests/__init__.py @@ -3,4 +3,5 @@ from . import test_crawl from . import test_new_page_templates +from . import test_theme_standalone from . import test_theme_upgrade diff --git a/test_themes/tests/test_theme_standalone.py b/test_themes/tests/test_theme_standalone.py index 677433382..efaf66da4 100644 --- a/test_themes/tests/test_theme_standalone.py +++ b/test_themes/tests/test_theme_standalone.py @@ -1,9 +1,28 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from odoo.addons.website.tools import MockRequest from odoo.tests import standalone +@standalone('website_standalone') +def test_01_theme_install_generate_primary_templates(env): + """ This test ensures the theme `_generate_primary_snippet_templates()` + method is correctly called before xml views are generated. + """ + # 1. Setup + theme_buzzy = env.ref('base.module_theme_clean') + + if theme_buzzy.state == 'installed': + theme_buzzy.button_immediate_uninstall() + # Ensure those views are deleted to mimic the initial state of theme not installed. + # Because "theme_buzzy" was installed before through "test_themes" dependencies, removing + # those views is needed to replicate the bug: if the configurator views are not generated, + # the theme install will fail because some of the imported views inherit them. + env['ir.ui.view'].with_context(_force_unlink=True).search([('key', '=', 'website.configurator_s_banner')]).unlink() + env['ir.ui.view'].with_context(_force_unlink=True).search([('key', '=', 'website.configurator_s_cover')]).unlink() + theme_buzzy.button_immediate_install() + @standalone('website_standalone') def test_02_theme_default_generate_primary_templates(env): # Verify that theme default's configurator templates are created