Debian Codegraph @

addons/point_of_sale/tests/test_performances.py

raw
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
3 import logging
4
5 from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon
6
7 from odoo.cli.populate import Populate
8 from odoo.tests.common import tagged
9 from odoo.tools import mute_logger
10
11 _logger = logging.getLogger(__name__)
12
13
14 @tagged('-standard', 'pos_performance', '-at_install', 'post_install')
15 class TestPosPerformance(TestPointOfSaleHttpCommon):
16 """
17 These tests are designed for local performance testing only and will be skipped
18 unless the 'pos_performance' tag is explicitly included in the test tags.
19
20 To execute these tests locally, use the 'pos_performance' tag before the test name.
21 Example:
22 --test-tags pos_performance.test_pos_session_open_product_performance
23 """
24
25 def __populate_model(self, model_name, total_count):
26 before_count = self.env[model_name].search_count([])
27 if not before_count:
28 return False
29 populate_count = round(total_count / before_count) - 1
30 Populate.populate(self.env, {model_name: populate_count}, 1)
31
32 after_count = self.env[model_name].search_count([])
33 _logger.info("\n\nBefore %s Count: %s\nAfter %s Count: %s\n\n", model_name, before_count, model_name, after_count)
34 return True
35
36 @mute_logger('odoo.models.unlink', 'odoo.cli.populate', 'odoo.tools.populate', 'odoo.tests.common', 'werkzeug')
37 def test_pos_session_open_product_performance(self):
38 self.env['ir.config_parameter'].sudo().set_param('point_of_sale.limited_product_count', 20000)
39 if not self.__populate_model('product.template', 20000):
40 _logger.warning("The product.template model must contain at least one record before it can be populated.")
41 return
42 self.main_pos_config.with_user(self.pos_user).open_ui()
43 self.start_pos_tour('tourSessionOpenProductPerformance', timeout=2000)