[FIX] crm: Make tests demo data independent

Part-of: odoo/odoo#146649
This commit is contained in:
Yannick Tivisse
2023-12-18 23:32:05 +00:00
parent 043a60b59f
commit 7d9824d3d6
6 changed files with 38 additions and 3 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ registry.category("web_tour.tours").add('crm_tour', {
run: "drag_and_drop_native .o_opportunity_kanban .o_kanban_group:eq(2) ",
}, {
// Choose the element that is not going to be moved by the previous step.
trigger: ".o_opportunity_kanban .o_kanban_group:nth-child(2) .o_kanban_record:not(.o_updating) .o-mail-ActivityButton",
trigger: ".o_opportunity_kanban .o_kanban_group:nth-child(2) .o_kanban_record .o-mail-ActivityButton",
extra_trigger: ".o_opportunity_kanban",
content: markup(_t("Looks like nothing is planned. :(<br><br><i>Tip: Schedule activities to keep track of everything you have to do!</i>")),
position: "bottom",
+1
View File
@@ -814,6 +814,7 @@ class TestCRMLead(TestCrmCommon):
class TestLeadFormTools(FormatAddressCase):
def test_address_view(self):
self.env.company.country_id = self.env.ref('base.us')
self.assertAddressView('crm.lead')
@@ -13,6 +13,9 @@ class TestCRMLead(TestCrmCommon):
def setUpClass(cls):
super().setUpClass()
# To avoid magic phone sanitization
cls.env.company.country_id = cls.env.ref('base.us')
cls.emails_provider_generic = {
('robert.poilvert@gmail.com', 'robert.poilvert@gmail.com'),
('fp@odoo.com', 'fp@odoo.com'),
+7 -2
View File
@@ -6,7 +6,7 @@ from datetime import timedelta
from odoo import tools
from odoo.addons.mail.tests.common import mail_new_test_user
from odoo.fields import Date
from odoo.tests import Form, tagged, users
from odoo.tests import Form, tagged, users, loaded_demo_data
from odoo.tests.common import TransactionCase
@@ -206,7 +206,12 @@ class TestCRMPLS(TransactionCase):
Lead._cron_update_automated_probabilities()
lead_13_no_team_proba = leads[13].automated_probability
self.assertTrue(lead_13_team_3_proba != leads[13].automated_probability, "Probability for leads with no team should be different than if they where in their own team.")
self.assertEqual(tools.float_compare(lead_13_no_team_proba, 36.65, 2), 0)
# Todo: Make this test fully independent from demo data
if not loaded_demo_data(self.env):
expected_proba = 35.19
else:
expected_proba = 36.65
self.assertAlmostEqual(lead_13_no_team_proba, expected_proba, places=2)
# Test frequencies
lead_4_stage_0_freq = LeadScoringFrequency.search([('team_id', '=', leads[4].team_id.id), ('variable', '=', 'stage_id'), ('value', '=', stage_ids[0])])
+22
View File
@@ -8,6 +8,28 @@ from odoo.tests.common import tagged
class TestUi(HttpCase):
def test_01_crm_tour(self):
# TODO: The tour is raising a JS error when selecting Brandon Freeman
# but with the demo data it succeeds to continue if there is already another lead
# in the pipe. Then the tour is using a record in the Qualified stage to create
# an activity, which is not existing without demo data as well
brandon = self.env["res.partner"].create({
'name': 'Brandon Freeman',
'email': 'brandon.freeman55@example.com',
'phone': '(355)-687-3262',
})
self.env['crm.lead'].create([{
'name': "Zizizbroken",
'type': 'opportunity',
'partner_id': brandon.id,
'stage_id': self.env.ref('crm.stage_lead1').id,
'user_id': self.env.ref('base.user_admin').id,
}, {
'name': "Zizizbroken 2",
'type': 'opportunity',
'partner_id': brandon.id,
'stage_id': self.env.ref('crm.stage_lead2').id,
'user_id': self.env.ref('base.user_admin').id,
}])
self.start_tour("/web", 'crm_tour', login="admin")
def test_02_crm_tour_rainbowman(self):
@@ -29,6 +29,10 @@ class TestWebsiteCrm(odoo.tests.HttpCase):
self.assertEqual(record.campaign_id.name, 'New campaign', 'Name of the "on the fly" created campaign is wrong')
def test_catch_logged_partner_info_tour(self):
self.env.ref('base.partner_admin').write({
'name': 'Mitchell Admin',
'company_name': 'YourCompany',
})
user_login = 'admin'
user_partner = self.env['res.users'].search([('login', '=', user_login)]).partner_id
partner_email = user_partner.email