From 0ba65e908aa334ee2511f767fcef6684b36fd0e6 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Tue, 5 Dec 2023 14:15:56 +0100 Subject: [PATCH] [FIX] event: Make tests demo data independent Part-of: odoo/odoo#146649 --- .../event/tests/test_event_mail_schedule.py | 4 +++ addons/event_booth_sale/tests/common.py | 4 +++ .../tests/test_event_booth_sale.py | 7 +++-- .../tests/tours/event_configurator_ui.js | 2 +- addons/event_sale/tests/test_event_sale.py | 6 +++- .../tests/test_wevent_register.py | 1 + .../website_event/tests/test_website_event.py | 4 +-- .../tests/test_wevent_booth_exhibitor.py | 30 +++++++++++++++++++ .../tests/test_event_booth_sale.py | 21 +++++++++++-- addons/website_event_sale/tests/common.py | 1 + 10 files changed, 71 insertions(+), 9 deletions(-) diff --git a/addons/event/tests/test_event_mail_schedule.py b/addons/event/tests/test_event_mail_schedule.py index d34a540ba4f..580fd376ff5 100644 --- a/addons/event/tests/test_event_mail_schedule.py +++ b/addons/event/tests/test_event_mail_schedule.py @@ -16,6 +16,10 @@ class TestMailSchedule(EventCase, MockEmail): @mute_logger('odoo.addons.base.models.ir_model', 'odoo.models') def test_event_mail_schedule(self): """ Test mail scheduling for events """ + self.env.company.write({ + 'name': 'YourCompany', + 'email': 'info@yourcompany.example.com', + }) event_cron_id = self.env.ref('event.event_mail_scheduler') # deactivate other schedulers to avoid messing with crons diff --git a/addons/event_booth_sale/tests/common.py b/addons/event_booth_sale/tests/common.py index 7c055c0ffcc..f866084f2cb 100644 --- a/addons/event_booth_sale/tests/common.py +++ b/addons/event_booth_sale/tests/common.py @@ -11,6 +11,10 @@ class TestEventBoothSaleCommon(TestEventBoothCommon): def setUpClass(cls): super(TestEventBoothSaleCommon, cls).setUpClass() + cls.env['account.tax.group'].create( + {'name': 'Test Account Tax Group', 'company_id': cls.env.company.id} + ) + cls.event_booth_product = cls.env['product.product'].create({ 'name': 'Test Booth Product', 'description_sale': 'Mighty Booth Description', diff --git a/addons/event_booth_sale/tests/test_event_booth_sale.py b/addons/event_booth_sale/tests/test_event_booth_sale.py index 5e9bea1befd..85341cbfa32 100644 --- a/addons/event_booth_sale/tests/test_event_booth_sale.py +++ b/addons/event_booth_sale/tests/test_event_booth_sale.py @@ -6,6 +6,7 @@ from datetime import datetime, timedelta from odoo import Command, fields from odoo.addons.event_booth_sale.tests.common import TestEventBoothSaleCommon from odoo.addons.sales_team.tests.common import TestSalesCommon +from odoo.addons.account.tests.common import AccountTestInvoicingCommon from odoo.tests.common import tagged, users from odoo.tools import float_compare @@ -114,11 +115,11 @@ class TestEventBoothSale(TestEventBoothSaleWData): @tagged('post_install', '-at_install') -class TestEventBoothSaleInvoice(TestEventBoothSaleWData): +class TestEventBoothSaleInvoice(AccountTestInvoicingCommon, TestEventBoothSaleWData): @classmethod - def setUpClass(cls): - super(TestEventBoothSaleInvoice, cls).setUpClass() + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) # Add group `group_account_invoice` to user_sales_salesman to allow to pay the invoice cls.user_sales_salesman.groups_id += cls.env.ref('account.group_account_invoice') diff --git a/addons/event_sale/static/tests/tours/event_configurator_ui.js b/addons/event_sale/static/tests/tours/event_configurator_ui.js index 7c3b5487cf5..efeb1eabb6c 100644 --- a/addons/event_sale/static/tests/tours/event_configurator_ui.js +++ b/addons/event_sale/static/tests/tours/event_configurator_ui.js @@ -23,7 +23,7 @@ registry.category("web_tour.tours").add('event_configurator_tour', { actions.text('Event Registration'); } }, { - trigger: 'ul.ui-autocomplete a:contains("Event")', + trigger: 'ul.ui-autocomplete a:contains("Event Registration")', run: 'click' }, { trigger: 'div[name="event_id"] input', diff --git a/addons/event_sale/tests/test_event_sale.py b/addons/event_sale/tests/test_event_sale.py index aae39e9cae2..4fd177dc438 100644 --- a/addons/event_sale/tests/test_event_sale.py +++ b/addons/event_sale/tests/test_event_sale.py @@ -40,7 +40,7 @@ class TestEventSale(TestEventSaleCommon): }) cls.sale_order = cls.env['sale.order'].create({ - 'partner_id': cls.env.ref('base.res_partner_2').id, + 'partner_id': cls.env['res.partner'].create({'name': 'Test Partner'}).id, 'note': 'Invoice after delivery', 'payment_term_id': cls.env.ref('account.account_payment_term_end_following_month').id }) @@ -69,6 +69,10 @@ class TestEventSale(TestEventSaleCommon): 'partner_id': cls.event_customer.id, }) + cls.env['account.tax.group'].create( + {'name': 'Test Account Tax Group', 'company_id': cls.env.company.id} + ) + @users('user_sales_salesman') def test_event_crm_sale(self): TICKET1_COUNT, TICKET2_COUNT = 3, 1 diff --git a/addons/test_event_full/tests/test_wevent_register.py b/addons/test_event_full/tests/test_wevent_register.py index a247acb97a8..73f2e2b3c9a 100644 --- a/addons/test_event_full/tests/test_wevent_register.py +++ b/addons/test_event_full/tests/test_wevent_register.py @@ -11,6 +11,7 @@ from odoo.addons.test_event_full.tests.common import TestWEventCommon class TestWEventRegister(TestWEventCommon): def test_register(self): + self.env.company.country_id = self.env.ref('base.us') with freeze_time(self.reference_now, tick=True): self.start_tour('/event', 'wevent_register', login=None) new_registrations = self.event.registration_ids diff --git a/addons/website_event/tests/test_website_event.py b/addons/website_event/tests/test_website_event.py index 67011045e11..6513a2892d9 100644 --- a/addons/website_event/tests/test_website_event.py +++ b/addons/website_event/tests/test_website_event.py @@ -5,7 +5,7 @@ from datetime import datetime, timedelta from dateutil.relativedelta import relativedelta from odoo import fields -from odoo.addons.base.tests.common import HttpCaseWithUserDemo +from odoo.addons.base.tests.common import HttpCaseWithUserDemo, HttpCaseWithUserPortal from odoo.addons.mail.tests.common import mail_new_test_user from odoo.addons.website.tests.test_base_url import TestUrlCommon from odoo.addons.website_event.tests.common import OnlineEventCase @@ -15,7 +15,7 @@ from odoo.tools import mute_logger from odoo.tests.common import users @tagged('post_install', '-at_install') -class TestUi(HttpCaseWithUserDemo): +class TestUi(HttpCaseWithUserDemo, HttpCaseWithUserPortal): def test_website_event_tour_admin(self): self.start_tour(self.env['website'].get_client_action_url('/'), 'website_event_tour', login='admin', step_delay=100) diff --git a/addons/website_event_booth_exhibitor/tests/test_wevent_booth_exhibitor.py b/addons/website_event_booth_exhibitor/tests/test_wevent_booth_exhibitor.py index 79784bedf10..0b3fabcf2be 100644 --- a/addons/website_event_booth_exhibitor/tests/test_wevent_booth_exhibitor.py +++ b/addons/website_event_booth_exhibitor/tests/test_wevent_booth_exhibitor.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from datetime import datetime +from dateutil.relativedelta import relativedelta from odoo.addons.base.tests.common import HttpCaseWithUserDemo, HttpCaseWithUserPortal from odoo.tests import tagged @@ -19,4 +21,32 @@ class TestWEventBoothExhibitorCommon(HttpCaseWithUserDemo, HttpCaseWithUserPorta }) transfer_provider._transfer_ensure_pending_msg_is_set() + self.env.ref('base.user_admin').write({ + 'name': 'Mitchell Admin', + 'street': '215 Vine St', + 'phone': '+1 555-555-5555', + 'city': 'Scranton', + 'zip': '18503', + 'country_id': self.env.ref('base.us').id, + 'state_id': self.env.ref('base.state_us_39').id, + }) + + self.env['event.event'].create({ + 'name': 'Test Online Reveal', + 'date_tz': 'Europe/Brussels', + 'stage_id': self.env.ref('event.event_stage_booked').id, + 'date_begin': datetime.now() + relativedelta(days=1, hour=5, minute=0, second=0), + 'date_end': datetime.now() + relativedelta(days=1, hour=5, minute=0, second=0), + 'is_published': True, + 'website_menu': True, + 'booth_menu': True, + 'exhibitor_menu': True, + 'event_booth_ids': [(0, 0, { + 'name': 'Standard Booth', + 'booth_category_id': self.env.ref('event_booth.event_booth_category_standard').id, + }), (0, 0, { + 'name': 'OpenWood Demonstrator 2', + 'booth_category_id': self.env.ref('event_booth.event_booth_category_premium').id, + })] + }) self.start_tour('/event', 'webooth_exhibitor_register', login='admin') diff --git a/addons/website_event_booth_sale/tests/test_event_booth_sale.py b/addons/website_event_booth_sale/tests/test_event_booth_sale.py index 9499d602db0..0771d9bfee8 100644 --- a/addons/website_event_booth_sale/tests/test_event_booth_sale.py +++ b/addons/website_event_booth_sale/tests/test_event_booth_sale.py @@ -5,13 +5,13 @@ from datetime import datetime, timedelta from odoo import Command, fields from odoo.addons.website_event_sale.tests.common import TestWebsiteEventSaleCommon -from odoo.tests import HttpCase +from odoo.addons.base.tests.common import HttpCaseWithUserPortal from odoo.tests.common import tagged @tagged('post_install', '-at_install') -class TestWebsiteEventBoothSale(HttpCase, TestWebsiteEventSaleCommon): +class TestWebsiteEventBoothSale(HttpCaseWithUserPortal, TestWebsiteEventSaleCommon): @classmethod def setUpClass(cls): @@ -64,7 +64,24 @@ class TestWebsiteEventBoothSale(HttpCase, TestWebsiteEventSaleCommon): def test_tour(self): self.env['product.pricelist'].sudo().search([]).action_archive() + self.partner_portal.write({ + 'street': '858 Lynn Street', + 'city': 'Bayonne', + 'country_id': self.env.ref('base.state_us_25').id, + 'zip': '07002', + 'phone': '(683)-556-5104', + }) self.start_tour('/event', 'website_event_booth_tour', login='portal') def test_booth_pricelists_different_currencies(self): + self.env.ref('base.user_admin').partner_id.write({ + 'email': 'mitchell.stephen@example.com', + 'name': 'Mitchell Admin', + 'street': '215 Vine St', + 'city': 'Scranton', + 'zip': '18503', + 'country_id': self.env.ref('base.us').id, + 'state_id': self.env.ref('base.state_us_39').id, + 'phone': '+1 555-555-5555', + }) self.start_tour("/web", 'event_booth_sale_pricelists_different_currencies', login='admin') diff --git a/addons/website_event_sale/tests/common.py b/addons/website_event_sale/tests/common.py index 59c9cb39d62..2a0a060b983 100644 --- a/addons/website_event_sale/tests/common.py +++ b/addons/website_event_sale/tests/common.py @@ -13,6 +13,7 @@ class TestWebsiteEventSaleCommon(TransactionCase): def setUpClass(cls): super(TestWebsiteEventSaleCommon, cls).setUpClass() + cls.env.company.country_id = cls.env.ref('base.us') cls.currency_test = cls.env['res.currency'].create({ 'name': 'eventX', 'rounding': 0.01,