Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take inline overrides into account in mandatory_include and bootstrap_include sections of a test plan (BugFix) #1079

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 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,40 @@ 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.tp1 = TestPlanUnit({
"id": "tp1",
"unit": "test plan",
"name": "An example test plan 1",
"bootstrap_include": "bootstrap_job certification_status=blocker",
"mandatory_include": "mandatory_job certification_status=blocker",
"include": "job1 certification_status=non-blocker",
})
self.tp2 = TestPlanUnit({
"id": "tp1",
"unit": "test plan",
"name": "An example test plan 2",
"include": "job1 certification_status=blocker",
})

def test_inline_override(self):
support_tp1 = TestPlanUnitSupport(self.tp1)
support_tp2 = TestPlanUnitSupport(self.tp2)
self.assertEqual(
support_tp1.override_list,
[
("^bootstrap_job$", [("certification_status", "blocker")]),
("^job1$", [("certification_status", "non-blocker")]),
("^mandatory_job$", [("certification_status", "blocker")]),
],
)
self.assertEqual(
support_tp2.override_list,
[
("^job1$", [("certification_status", "blocker")]),
],
)
36 changes: 20 additions & 16 deletions checkbox-ng/plainbox/impl/unit/testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,23 +826,27 @@ def _get_inline_overrides(
collected into a list of tuples ``(field, value)`` and this list is
subsequently packed into a tuple ``(pattern, field_value_list)``.
"""
override_list = []
if testplan.include is not None:

class V(Visitor):

def visit_IncludeStmt_node(self, node: IncludeStmt):
if not node.overrides:
return
pattern = r"^{}$".format(
testplan.qualify_id(node.pattern.text))
field_value_list = [
(override_exp.field.text.replace('-', '_'),
override_exp.value.text)
for override_exp in node.overrides]
override_list.append((pattern, field_value_list))
class V(Visitor):

V().visit(IncludeStmtList.parse(testplan.include))
def visit_IncludeStmt_node(self, node: IncludeStmt):
if not node.overrides:
return
pattern = r"^{}$".format(
testplan.qualify_id(node.pattern.text))
field_value_list = [
(override_exp.field.text.replace('-', '_'),
override_exp.value.text)
for override_exp in node.overrides]
override_list.append((pattern, field_value_list))
override_list = []
include_sections = (
testplan.bootstrap_include,
testplan.mandatory_include,
testplan.include,
)
for section in include_sections:
if section:
V().visit(IncludeStmtList.parse(section))
for tp_unit in testplan.get_nested_part():
override_list.extend(self._get_inline_overrides(tp_unit))
return override_list
Loading