December 2018
Beginner to intermediate
404 pages
10h 14m
English
Access security can also be checked to confirm that users have the correct privileges granted.
By default, tests are executed with the Odoo internal user, __system__, which bypasses access security. So we need to change the user running the tests, to check whether the right access security has been given to them. This is done by modifying the execution environment, in self.env, by setting the user attribute to the user we want to run the tests with.
We can modify our tests to take this into account. Edit the tests/test_book.py file to add a setUp method:
def setUp(self, *args, **kwargs):
result = super().setUp(*args, **kwargs)
user_admin = self.env.ref('base.user_admin')
self.env= self.env(user=user_admin) self.Book ...Read now
Unlock full access