mirror of
https://github.com/odoo/runbot.git
synced 2025-03-16 07:55:45 +07:00
[FIX] runbot: adapt build write method to api multi
And add tests to avoid regression.
This commit is contained in:
parent
534368b675
commit
b31735406d
@ -283,9 +283,11 @@ class runbot_build(models.Model):
|
||||
# some validation to ensure db consistency
|
||||
assert 'state' not in values
|
||||
local_result = values.get('local_result')
|
||||
assert not local_result or local_result == self._get_worst_result([self.local_result, local_result]) # dont write ok on a warn/error build
|
||||
for build in self:
|
||||
assert not local_result or local_result == self._get_worst_result([build.local_result, local_result]) # dont write ok on a warn/error build
|
||||
res = super(runbot_build, self).write(values)
|
||||
assert bool(not self.duplicate_id) ^ (self.local_state == 'duplicate') # don't change duplicate state without removing duplicate id.
|
||||
for build in self:
|
||||
assert bool(not build.duplicate_id) ^ (build.local_state == 'duplicate') # don't change duplicate state without removing duplicate id.
|
||||
return res
|
||||
|
||||
def _end_test(self):
|
||||
|
@ -46,6 +46,22 @@ class Test_Build(common.TransactionCase):
|
||||
build._compute_domain()
|
||||
self.assertEqual(build.domain, 'runbot99.example.org:1234')
|
||||
|
||||
other = self.Build.create({
|
||||
'branch_id': self.branch.id,
|
||||
'name': 'd0d0caca0000ffffffffffffffffffffffffffff',
|
||||
'port': '5678',
|
||||
'local_result': 'ko'
|
||||
})
|
||||
|
||||
# test a bulk write, that one cannot change from 'ko' to 'ok'
|
||||
builds = self.Build.browse([build.id, other.id])
|
||||
with self.assertRaises(AssertionError):
|
||||
builds.write({'local_result': 'ok'})
|
||||
|
||||
# test that a build cannot have local state 'duplicate' without a duplicate_id
|
||||
with self.assertRaises(AssertionError):
|
||||
builds.write({'local_state': 'duplicate'})
|
||||
|
||||
@patch('odoo.addons.runbot.models.build.os.mkdir')
|
||||
@patch('odoo.addons.runbot.models.build.grep')
|
||||
def test_build_cmd_log_db(self, mock_grep, mock_mkdir):
|
||||
|
Loading…
Reference in New Issue
Block a user