diff options
| author | Odoo's Mergebot <xmo+roboto@odoo.com> | 2019-11-07 08:37:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-07 08:37:12 +0100 |
| commit | cfc65bd1b72b6fb7833f67fa580fa9fdac28b1f5 (patch) | |
| tree | c1aa353aa7e29d0ed918911dbdce456ed957b72e /addons/website | |
| parent | a3f5afdd53f5f0d8d76427fe14dce6f02e064a75 (diff) | |
| parent | bc8fe668495a1d080ff883d5e61e961a128669de (diff) | |
[MERGE] various: Make the test suite demo data independant
Purpose
=======
This is the first huge step to improve the test suite in several ways:
- Make them demo data independent, allowing to modify the demo data without having to adapt the tests depending on it. It also allows to have a beautiful + convenient demo dataset to make a demonstration, and to configure complex data in the tests to manage the corner cases.
- Improve the test performances by converting them into SavepointCase. Each test will be rollbacked to it's initial state, after the setUpClass call. That way the different data are not re-created at each test for nothing.
- Introduce several test classes in base/tests/common.py to launch a TransactionCase, HttpCase or SavepointCase test with an available demo user, portal user or a large set of partners.
- This is the first step to tend to a rolling release process, allowing to execute the tests (or a subset of the tests) on a migrated base, for example.
closes odoo/odoo#39868
Taskid: 2075739
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/website')
| -rw-r--r-- | addons/website/static/src/js/tours/banner.js | 1 | ||||
| -rw-r--r-- | addons/website/static/tests/tours/reset_password.js | 10 | ||||
| -rw-r--r-- | addons/website/tests/test_crawl.py | 22 | ||||
| -rw-r--r-- | addons/website/tests/test_get_current_website.py | 12 | ||||
| -rw-r--r-- | addons/website/tests/test_lang_url.py | 2 | ||||
| -rw-r--r-- | addons/website/tests/test_page.py | 5 | ||||
| -rw-r--r-- | addons/website/tests/test_qweb.py | 7 | ||||
| -rw-r--r-- | addons/website/tests/test_ui.py | 2 |
8 files changed, 44 insertions, 17 deletions
diff --git a/addons/website/static/src/js/tours/banner.js b/addons/website/static/src/js/tours/banner.js index f4ddc040c69..04311eeecaf 100644 --- a/addons/website/static/src/js/tours/banner.js +++ b/addons/website/static/src/js/tours/banner.js @@ -15,6 +15,7 @@ tour.register("banner", { position: "bottom", }, { trigger: "#snippet_structure .oe_snippet:eq(1) .oe_snippet_thumbnail", + extra_trigger: "body.editor_enable.editor_has_snippets", content: _t("Drag the <i>Cover</i> block and drop it in your page."), position: "bottom", run: "drag_and_drop #wrap", diff --git a/addons/website/static/tests/tours/reset_password.js b/addons/website/static/tests/tours/reset_password.js index 9484a4c039f..98ce641373f 100644 --- a/addons/website/static/tests/tours/reset_password.js +++ b/addons/website/static/tests/tours/reset_password.js @@ -44,14 +44,14 @@ tour.register('website_reset_password', { }); // Set a website on "Admin" partner to test the URL of the website. var def3 = rpc.query({ - model: 'res.partner', - method: 'name_search', - kwargs: {'name': 'Mitchell Admin', 'args': [['company_id', '=', 1]]}, - }).then(function (res) { + model: 'ir.model.data', + method: 'xmlid_to_res_id', + args: ['base.partner_admin'], + }).then(function (res_id) { return rpc.query({ 'model': 'res.partner', 'method': 'write', - 'args': [[res[0][0]], { + 'args': [[res_id], { 'website_id': 1, }], }); diff --git a/addons/website/tests/test_crawl.py b/addons/website/tests/test_crawl.py index 81907aa3a16..62df28c0f38 100644 --- a/addons/website/tests/test_crawl.py +++ b/addons/website/tests/test_crawl.py @@ -10,12 +10,13 @@ from werkzeug import urls import odoo import re +from odoo.addons.base.tests.common import HttpCaseWithUserDemo _logger = logging.getLogger(__name__) -@odoo.tests.common.tagged('post_install', '-at_install') -class Crawler(odoo.tests.HttpCase): +@odoo.tests.common.tagged('post_install', '-at_install', 'crawl') +class Crawler(HttpCaseWithUserDemo): """ Test suite crawling an Odoo CMS instance and checking that all internal links lead to a 200 response. @@ -23,6 +24,23 @@ class Crawler(odoo.tests.HttpCase): starting the crawl """ + def setUp(self): + super(Crawler, self).setUp() + + if hasattr(self.env['res.partner'], 'grade_id'): + # Create at least one published parter, so that /partners doesn't + # return a 404 + grade = self.env['res.partner.grade'].create({ + 'name': 'A test grade', + 'website_published': True, + }) + self.env['res.partner'].create({ + 'name': 'A Company for /partners', + 'is_company': True, + 'grade_id': grade.id, + 'website_published': True, + }) + def crawl(self, url, seen=None, msg=''): if seen is None: seen = set() diff --git a/addons/website/tests/test_get_current_website.py b/addons/website/tests/test_get_current_website.py index ee02a4d5ff8..da36762acee 100644 --- a/addons/website/tests/test_get_current_website.py +++ b/addons/website/tests/test_get_current_website.py @@ -14,13 +14,15 @@ class TestGetCurrentWebsite(TransactionCase): Website = self.env['website'] # clean initial state - website1 = Website.browse(1) + website1 = self.env.ref('website.default_website') website1.domain = '' website1.country_group_ids = False - website2 = Website.browse(2) - website2.domain = '' - website2.country_group_ids = False + website2 = Website.create({ + 'name': 'My Website 2', + 'domain': '', + 'country_group_ids': False, + }) country1 = self.env['res.country'].create({'name': "My Country 1"}) country2 = self.env['res.country'].create({'name': "My Country 2"}) @@ -114,7 +116,7 @@ class TestGetCurrentWebsite(TransactionCase): self.assertEqual(Website._get_current_website_id('site-1.com', False), website1.id) def test_02_signup_user_website_id(self): - website = self.env['website'].browse(1) + website = self.env.ref('website.default_website') website.specific_user_account = True user = self.env['res.users'].create({'website_id': website.id, 'login': 'sad@mail.com', 'name': 'Hope Fully'}) diff --git a/addons/website/tests/test_lang_url.py b/addons/website/tests/test_lang_url.py index 871248c2778..1c08b866fa4 100644 --- a/addons/website/tests/test_lang_url.py +++ b/addons/website/tests/test_lang_url.py @@ -12,7 +12,7 @@ class TestLangUrl(HttpCase): super(TestLangUrl, self).setUp() # Simulate multi lang without loading translations - self.website = self.env['website'].browse(1) + self.website = self.env.ref('website.default_website') lang_fr = self.env.ref('base.lang_fr') lang_fr.write({'active': True, 'url_code': 'fr'}) self.website.language_ids = self.env.ref('base.lang_en') + lang_fr diff --git a/addons/website/tests/test_page.py b/addons/website/tests/test_page.py index 3c0b294b606..09f39074c89 100644 --- a/addons/website/tests/test_page.py +++ b/addons/website/tests/test_page.py @@ -167,6 +167,11 @@ class TestPage(common.TransactionCase): View = self.env['ir.ui.view'] Website = self.env['website'] + website2 = self.env['website'].create({ + 'name': 'My Second Website', + 'domain': '', + }) + # currently the view unlink of website.page can't handle views with inherited views self.extension_view.unlink() diff --git a/addons/website/tests/test_qweb.py b/addons/website/tests/test_qweb.py index 9cc199291a9..1c2c1dbe573 100644 --- a/addons/website/tests/test_qweb.py +++ b/addons/website/tests/test_qweb.py @@ -4,12 +4,13 @@ import re from odoo import tools +from odoo.addons.base.tests.common import TransactionCaseWithUserDemo from odoo.addons.website.tools import MockRequest from odoo.modules.module import get_module_resource from odoo.tests.common import TransactionCase -class TestQweb(TransactionCase): +class TestQweb(TransactionCaseWithUserDemo): def _load(self, module, *args): tools.convert_file(self.cr, 'website', get_module_resource(module, *args), @@ -18,7 +19,7 @@ class TestQweb(TransactionCase): def test_qweb_cdn(self): self._load('website', 'tests', 'template_qweb_test.xml') - website = self.env['website'].browse(1) + website = self.env.ref('website.default_website') website.write({ "cdn_activated": True, "cdn_url": "http://test.cdn" @@ -71,7 +72,7 @@ class TestQweb(TransactionCase): class TestQwebProcessAtt(TransactionCase): def setUp(self): super(TestQwebProcessAtt, self).setUp() - self.website = self.env['website'].browse(1) + self.website = self.env.ref('website.default_website') self.env.ref('base.lang_fr').active = True self.website.language_ids = self.env.ref('base.lang_en') + self.env.ref('base.lang_fr') self.website.default_lang_id = self.env.ref('base.lang_en') diff --git a/addons/website/tests/test_ui.py b/addons/website/tests/test_ui.py index 2ce007ab381..98e06dc7924 100644 --- a/addons/website/tests/test_ui.py +++ b/addons/website/tests/test_ui.py @@ -96,7 +96,7 @@ class TestUi(odoo.tests.HttpCase): self.browser_js("/", "console.log('test successful')", "'website.content.snippets.animation' in odoo.__DEBUG__.services") def test_02_admin_tour_banner(self): - self.start_tour("/", 'banner', login='admin') + self.start_tour("/", 'banner', login='admin', step_delay=100) def test_03_restricted_editor(self): self.restricted_editor = self.env['res.users'].create({ |
