Files
odoo_source/addons/website_links/tests/test_ui.py
T
std-odoo b7e5eb639a [FIX] link_tracker: clean code and fix add a constraint
Purpose
=======
Add a unicity constraint (on the url, UTM campaign, medium and source).
As we must care about null values, we can not implement it in SQL
(possible in pure SQL, but we will need to create an index on the
columns, which is not possible in Odoo if we want to customize the
error message).

Clean the code, before the "search or create" behavior was implemented
in the create, causing strange behavior (creating a link tracker with
the same values as an existing one didn't raise an error, but open
the form view of the existing link tracker).

Task-2090344

closes odoo/odoo#48845

Related: odoo/enterprise#9608
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-17 13:28:43 +00:00

29 lines
911 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'].search_or_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")