mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[FIX] runbot: fix build_error test tags validation
When trying to remove test_tags on a build_error, the validation fails because it tries to iterate on False. Also, the ValidationError exception was not properly imported. With this commit, the validation is fixed and a test is added.
This commit is contained in:
parent
f4ef66e029
commit
926ab4a9d9
@ -5,6 +5,7 @@ import re
|
||||
|
||||
from collections import defaultdict
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@ -40,11 +41,10 @@ class RunbotBuildError(models.Model):
|
||||
last_seen_date = fields.Datetime(string='Last Seen Date', related='last_seen_build_id.create_date')
|
||||
test_tags = fields.Char(string='Test tags', help="Comma separated list of test_tags to use to reproduce/remove this error")
|
||||
|
||||
|
||||
@api.constrains('test_tags')
|
||||
def _check_test_tags(self):
|
||||
for step in self:
|
||||
if '-' in step.test_tags:
|
||||
for build_error in self:
|
||||
if build_error.test_tags and '-' in build_error.test_tags:
|
||||
raise ValidationError('Build error test_tags should not be negated')
|
||||
|
||||
@api.model
|
||||
|
@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from unittest.mock import patch
|
||||
from odoo.tests import common
|
||||
from odoo.exceptions import ValidationError
|
||||
from .common import RunbotCase
|
||||
|
||||
RTE_ERROR = """FAIL: TestUiTranslate.test_admin_tour_rte_translator
|
||||
@ -128,3 +129,36 @@ class TestBuildError(RunbotCase):
|
||||
self.assertIn(build_a, error_b.children_build_ids)
|
||||
self.assertEqual(error_a.build_count, 1)
|
||||
self.assertEqual(error_b.build_count, 2)
|
||||
|
||||
def test_build_error_test_tags(self):
|
||||
build_a = self.create_test_build({'local_result': 'ko'})
|
||||
build_b = self.create_test_build({'local_result': 'ko'})
|
||||
|
||||
error_a = self.BuildError.create({
|
||||
'content': 'foo',
|
||||
'build_ids': [(6, 0, [build_a.id])],
|
||||
'random': True,
|
||||
'active': True
|
||||
})
|
||||
|
||||
error_b = self.BuildError.create({
|
||||
'content': 'bar',
|
||||
'build_ids': [(6, 0, [build_b.id])],
|
||||
'random': True,
|
||||
'active': False
|
||||
})
|
||||
|
||||
# test that a test tag with a dash raise an Vamlidation error
|
||||
with self.assertRaises(ValidationError):
|
||||
error_a.test_tags = '-foo'
|
||||
|
||||
error_a.test_tags = 'foo,bar'
|
||||
error_b.test_tags = 'blah'
|
||||
self.assertIn('foo', self.BuildError.test_tags_list())
|
||||
self.assertIn('bar', self.BuildError.test_tags_list())
|
||||
self.assertIn('-foo', self.BuildError.disabling_tags())
|
||||
self.assertIn('-bar', self.BuildError.disabling_tags())
|
||||
|
||||
# test that test tags on fixed errors are not taken into account
|
||||
self.assertNotIn('blah', self.BuildError.test_tags_list())
|
||||
self.assertNotIn('-blah', self.BuildError.disabling_tags())
|
||||
|
Loading…
Reference in New Issue
Block a user