[IMP] website: Adapt tests to work with/without demo data
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
}],
|
||||
});
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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'})
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user