diff options
| author | Odoo's Mergebot <xmo+roboto@odoo.com> | 2019-11-07 08:37:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-07 08:37:12 +0100 |
| commit | cfc65bd1b72b6fb7833f67fa580fa9fdac28b1f5 (patch) | |
| tree | c1aa353aa7e29d0ed918911dbdce456ed957b72e /addons/pos_restaurant/tests/test_frontend.py | |
| parent | a3f5afdd53f5f0d8d76427fe14dce6f02e064a75 (diff) | |
| parent | bc8fe668495a1d080ff883d5e61e961a128669de (diff) | |
[MERGE] various: Make the test suite demo data independant
Purpose
=======
This is the first huge step to improve the test suite in several ways:
- Make them demo data independent, allowing to modify the demo data without having to adapt the tests depending on it. It also allows to have a beautiful + convenient demo dataset to make a demonstration, and to configure complex data in the tests to manage the corner cases.
- Improve the test performances by converting them into SavepointCase. Each test will be rollbacked to it's initial state, after the setUpClass call. That way the different data are not re-created at each test for nothing.
- Introduce several test classes in base/tests/common.py to launch a TransactionCase, HttpCase or SavepointCase test with an available demo user, portal user or a large set of partners.
- This is the first step to tend to a rolling release process, allowing to execute the tests (or a subset of the tests) on a migrated base, for example.
closes odoo/odoo#39868
Taskid: 2075739
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/pos_restaurant/tests/test_frontend.py')
| -rw-r--r-- | addons/pos_restaurant/tests/test_frontend.py | 79 |
1 files changed, 71 insertions, 8 deletions
diff --git a/addons/pos_restaurant/tests/test_frontend.py b/addons/pos_restaurant/tests/test_frontend.py index f65150e647b..b4d5a8b3ed8 100644 --- a/addons/pos_restaurant/tests/test_frontend.py +++ b/addons/pos_restaurant/tests/test_frontend.py @@ -9,7 +9,47 @@ class TestFrontend(odoo.tests.HttpCase): env = self.env(user=self.env.ref('base.user_admin')) account_obj = env['account.account'] - pos_config = env.ref('pos_restaurant.pos_config_restaurant') + printer = self.env['restaurant.printer'].create({ + 'name': 'Kitchen Printer', + 'proxy_ip': 'localhost', + }) + drinks_category = self.env['pos.category'].create({'name': 'Drinks'}) + + pos_config = self.env['pos.config'].create({ + 'name': 'Bar', + 'barcode_nomenclature_id': self.env.ref('barcodes.default_barcode_nomenclature').id, + 'module_pos_restaurant': True, + 'is_table_management': True, + 'iface_splitbill': True, + 'iface_printbill': True, + 'iface_orderline_notes': True, + 'printer_ids': [(4, printer.id)], + 'iface_start_categ_id': drinks_category.id, + 'start_category': True, + 'pricelist_id': self.env.ref('product.list0').id, + }) + + main_floor = self.env['restaurant.floor'].create({ + 'name': 'Main Floor', + 'pos_config_id': pos_config.id, + }) + + table_05 = self.env['restaurant.table'].create({ + 'name': 'T5', + 'floor_id': main_floor.id, + 'seats': 4, + }) + table_04 = self.env['restaurant.table'].create({ + 'name': 'T4', + 'floor_id': main_floor.id, + 'seats': 4, + }) + table_02 = self.env['restaurant.table'].create({ + 'name': 'T2', + 'floor_id': main_floor.id, + 'seats': 4, + }) + main_company = env.ref('base.main_company') account_receivable = account_obj.create({'code': 'X1012', @@ -47,14 +87,37 @@ class TestFrontend(odoo.tests.HttpCase): })], }) - coke = self.env.ref('pos_restaurant.coke') - coke.write({'taxes_id': [(6, 0, [])]}) - water = self.env.ref('pos_restaurant.water') - water.write({'taxes_id': [(6, 0, [])]}) - minute_maid = self.env.ref('pos_restaurant.minute_maid') - minute_maid.write({'taxes_id': [(6, 0, [])]}) + coke = self.env['product.product'].create({ + 'available_in_pos': True, + 'list_price': 2.20, + 'name': 'Coca-Cola', + 'weight': 0.01, + 'pos_categ_id': drinks_category.id, + 'categ_id': self.env.ref('point_of_sale.product_category_pos').id, + 'taxes_id': [(6, 0, [])], + }) + + water = self.env['product.product'].create({ + 'available_in_pos': True, + 'list_price': 2.20, + 'name': 'Water', + 'weight': 0.01, + 'pos_categ_id': drinks_category.id, + 'categ_id': self.env.ref('point_of_sale.product_category_pos').id, + 'taxes_id': [(6, 0, [])], + }) + + minute_maid = self.env['product.product'].create({ + 'available_in_pos': True, + 'list_price': 2.20, + 'name': 'Minute Maid', + 'weight': 0.01, + 'pos_categ_id': drinks_category.id, + 'categ_id': self.env.ref('point_of_sale.product_category_pos').id, + 'taxes_id': [(6, 0, [])], + }) - pos_config.open_session_cb() + pos_config.with_user(self.env.ref('base.user_admin')).open_session_cb(check_coa=False) self.start_tour("/pos/web?config_id=%d" % pos_config.id, 'pos_restaurant_sync', login="admin") |
