-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] runbot: allow a runbot admin to create runbot batch log
When a runbot admin creates a cron for e.g. nightly builds, the cron may fails if a runbot.batch.log is written. With this commit, a runbot admin can create such a log.
- Loading branch information
Showing
3 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
from . import test_commit | ||
from . import test_upgrade | ||
from . import test_dockerfile | ||
from . import test_batch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from odoo.exceptions import AccessError | ||
from odoo.tests.common import new_test_user | ||
|
||
from .common import RunbotCase | ||
|
||
|
||
class TestBatchLog(RunbotCase): | ||
|
||
def test_batch_log_write(self): | ||
""" test that a runbot manager can write a batch log """ | ||
self.additionnal_setup() | ||
|
||
create_context = {'no_reset_password': True, 'mail_create_nolog': True, 'mail_create_nosubscribe': True, 'mail_notrack': True} | ||
simple_user = new_test_user(self.env, login='simple', name='simple', password='simple', context=create_context) | ||
runbot_admin = new_test_user(self.env, groups='runbot.group_runbot_admin,base.group_user', login='runbot_admin', name='runbot_admin', password='admin', context=create_context) | ||
|
||
# Ensure that a simple user cannot interfere in batch logs | ||
with self.assertRaises(AccessError): | ||
test_batch_log = self.env['runbot.batch.log'].with_user(simple_user).create({ | ||
'batch_id': self.branch_server.bundle_id.last_batch.id, | ||
'message': 'test_message', | ||
'level': 'INFO' | ||
}) | ||
|
||
test_batch_log = self.env['runbot.batch.log'].with_user(runbot_admin).create({ | ||
'batch_id': self.branch_server.bundle_id.last_batch.id, | ||
'message': 'test_message', | ||
'level': 'INFO' | ||
}) |