December 2018
Beginner to intermediate
404 pages
10h 14m
English
We should begin by preparing the data to be used in the tests, in the setUp method. Here, we need to create a checkout record to be used in the wizard.
It is convenient to perform the test actions under a specific user in order to also test that access control is properly configured. This is achieved using the sudo(<user>) model method. Recordsets carry that information with them, so after being created using sudo(), later operations in the same recordset will be performed using that same context.
This is the code for the setUp method:
from odoo.tests.common import TransactionCase
class TestWizard(TransactionCase):
def setUp(self, *args, **kwargs): super().setUp(*args, **kwargs) # Setup test data admin_user = self.env.ref('base.user_admin') ...Read now
Unlock full access