|
@ -51,13 +51,14 @@ _logger = logging.getLogger(__name__) |
|
|
# Decorators |
|
|
# Decorators |
|
|
#---------------------------------------------------------- |
|
|
#---------------------------------------------------------- |
|
|
|
|
|
|
|
|
def multi_users(users=[['base.user_root', True], ['base.user_admin', True]], raise_exception=True): |
|
|
|
|
|
|
|
|
def multi_users(users=[['base.user_root', True], ['base.user_admin', True]], reset=True, raise_exception=True): |
|
|
def decorator(func): |
|
|
def decorator(func): |
|
|
@functools.wraps(func) |
|
|
@functools.wraps(func) |
|
|
def wrapper(self, *args, **kwargs): |
|
|
def wrapper(self, *args, **kwargs): |
|
|
user_list = users(self) if callable(users) else users |
|
|
user_list = users(self) if callable(users) else users |
|
|
test_results = [] |
|
|
test_results = [] |
|
|
for user in user_list: |
|
|
for user in user_list: |
|
|
|
|
|
self.cr.execute('SAVEPOINT test_multi_users') |
|
|
try: |
|
|
try: |
|
|
if not isinstance(user[0], int): |
|
|
if not isinstance(user[0], int): |
|
|
self.uid = self.ref(user[0]) |
|
|
self.uid = self.ref(user[0]) |
|
@ -78,6 +79,11 @@ def multi_users(users=[['base.user_root', True], ['base.user_admin', True]], rai |
|
|
'result': True, |
|
|
'result': True, |
|
|
'error': None, |
|
|
'error': None, |
|
|
}) |
|
|
}) |
|
|
|
|
|
if reset: |
|
|
|
|
|
self.cr.execute('ROLLBACK TO SAVEPOINT test_multi_users') |
|
|
|
|
|
self.registry.reset_changes() |
|
|
|
|
|
else: |
|
|
|
|
|
self._cr.execute('RELEASE SAVEPOINT test_multi_users') |
|
|
test_fails = [] |
|
|
test_fails = [] |
|
|
for result in test_results: |
|
|
for result in test_results: |
|
|
if result['expect'] != result['result']: |
|
|
if result['expect'] != result['result']: |
|
|