Skip to content

Commit

Permalink
Take inline overrides into account in mandatory_include section of a …
Browse files Browse the repository at this point in the history
…test plan

Although inline overrides were taking into account in the `include`
section of a test plan, it was not the case for the `mandatory_include`
section.

So a test plan like this:

unit: test plan
id: test-plan
name: My test plan
mandatory_include:
    mandatory-cert-blocker-job  certification_status=blocker
include:
    regular-cert-blocker-job    certification_status=blocker

would only make "regular-cert-blocker-job" a cert-blocker, not
"mandatory-cert-blocker-job".
  • Loading branch information
pieqq committed Mar 18, 2024
1 parent 44498aa commit bf2716c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions checkbox-ng/plainbox/impl/unit/test_testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,30 @@ def test_nested_tesplan__multiple_namespaces(self):
self.assertIsInstance(qual_list[1].matcher, OperatorMatcher)
self.assertEqual(qual_list[1].matcher.value, 'ns2::Bar')
self.assertEqual(qual_list[1].inclusive, True)


class TestTestPlanUnitSupport(TestCase):

def setUp(self):
self.provider1 = mock.Mock(name='provider1', spec_set=IProvider1)
self.provider1.namespace = 'ns1'
self.tp1 = TestPlanUnit({
"id": "tp1",
"unit": "test plan",
"name": "An example test plan 1",
"mandatory_include": "mandatory_job certification_status=blocker",
"include": "job1 certification_status=non-blocker",
}, provider=self.provider1)
self.provider1.unit_list = []
self.tp1.provider_list = [self.provider1,]
self.provider1.unit_list.append(self.tp1)

def test_inline_override(self):
support = TestPlanUnitSupport(self.tp1)
self.assertEqual(
support.override_list,
[
("^ns1::job1$", [("certification_status", "non-blocker")]),
("^ns1::mandatory_job$", [("certification_status", "blocker")])
]
)
2 changes: 2 additions & 0 deletions checkbox-ng/plainbox/impl/unit/testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,8 @@ def visit_IncludeStmt_node(self, node: IncludeStmt):
override_list.append((pattern, field_value_list))

V().visit(IncludeStmtList.parse(testplan.include))
if testplan.mandatory_include:
V().visit(IncludeStmtList.parse(testplan.mandatory_include))
for tp_unit in testplan.get_nested_part():
override_list.extend(self._get_inline_overrides(tp_unit))
return override_list

0 comments on commit bf2716c

Please sign in to comment.