* commons & setup refactoring: * convert setUp to setUpClass * move setups where needed (stock/mrp commons or specific test classes) * create test data in batch (faster, less sql queries & batched operations) * move most tests post-install to allow runbot splits * by default, run tests without mail logic * by default, run tests in a consistent environment (fixed currency imposed in the BaseCommon) * refactor existing tests to use new commons data (while trying to keep diff reduced) * add dedicated test file to test the common data * use mute_logger to reduce useless test logs (less spam to scroll in logs, less data on runbot builds, ...) Part-of: odoo/odoo#96791
32 lines
1.3 KiB
Python
32 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo.tests import tagged, TransactionCase
|
|
|
|
|
|
@tagged('post_install', '-at_install')
|
|
class TestName(TransactionCase):
|
|
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super().setUpClass()
|
|
cls.product_name = 'Product Test Name'
|
|
cls.product_code = 'PTN'
|
|
cls.product = cls.env['product.product'].create({
|
|
'name': cls.product_name,
|
|
'default_code': cls.product_code,
|
|
})
|
|
|
|
def test_10_product_name(self):
|
|
display_name = self.product.display_name
|
|
self.assertEqual(display_name, "[%s] %s" % (self.product_code, self.product_name),
|
|
"Code should be preprended the the name as the context is not preventing it.")
|
|
display_name = self.product.with_context(display_default_code=False).display_name
|
|
self.assertEqual(display_name, self.product_name,
|
|
"Code should not be preprended to the name as context should prevent it.")
|
|
|
|
def test_default_code_and_negative_operator(self):
|
|
res = self.env['product.template'].name_search(name='PTN', operator='not ilike')
|
|
res_ids = [r[0] for r in res]
|
|
self.assertNotIn(self.product.id, res_ids)
|