Files
odoo_source/addons/website_links/tests/test_ui.py
T
Benoit Socias 90a7072f93 [FIX] website_links: not perform a request during automated test
This commit fixes the step trigger:
'#o_website_links_link_tracker_form
 #generated_tracked_link:contains("/r/")' that was taking too long
because of a call to _get_title_from_url happening during the creation
of a 'link.tracker'.

Before this commit the automated tests of website_links did trigger an
http request on the 'contactus' page which sometimes took too long to
respond and reached the test failure timeout.

After this commit the information obtained from this request is
hard-coded to avoid the unpredictable timing of the test.

This commit is a manual port of #62479.

task-2397724

closes odoo/odoo#62582

X-original-commit: db3296c034fe4c82d19580418fd5cdecdf578395
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-11-30 09:28:17 +00:00

29 lines
901 B
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from unittest.mock import patch
import odoo.tests
@odoo.tests.common.tagged('post_install', '-at_install')
class TestUi(odoo.tests.HttpCase):
def setUp(self):
super(TestUi, self).setUp()
def _get_title_from_url(addr, **kw):
return 'Contact Us | My Website'
patcher = patch('odoo.addons.link_tracker.models.link_tracker.LinkTracker._get_title_from_url', wraps=_get_title_from_url)
patcher.start()
self.addCleanup(patcher.stop)
def test_01_test_ui(self):
self.env['link.tracker'].create({
'campaign_id': 2,
'medium_id': 2,
'source_id': 2,
'url': self.env["ir.config_parameter"].sudo().get_param("web.base.url") + '/contactus',
})
self.start_tour("/", 'website_links_tour', login="admin")