Skip to content

Commit 1afcf80

Browse files
committed
Return override list in the right order
The overrides are visited in this order: - inline overrides - category overrides - certification status overrides They should be returned in the same order (not sorted), so that they are applied in the same order (meaning certifiaction status overrides should overwrite any inline overrides). Fix #1492
1 parent c28f192 commit 1afcf80

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

checkbox-ng/plainbox/impl/unit/test_testplan.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,21 @@ def setUp(self):
578578
)
579579
self.tp2 = TestPlanUnit(
580580
{
581-
"id": "tp1",
581+
"id": "tp2",
582582
"unit": "test plan",
583583
"name": "An example test plan 2",
584584
"include": "job1 certification_status=blocker",
585585
}
586586
)
587+
self.tp3 = TestPlanUnit(
588+
{
589+
"id": "tp3",
590+
"unit": "test plan",
591+
"name": "An example test plan 3",
592+
"include": "job1 certification_status=non-blocker",
593+
"certification_status_overrides": "apply blocker to .*",
594+
}
595+
)
587596

588597
def test_inline_override(self):
589598
support_tp1 = TestPlanUnitSupport(self.tp1)
@@ -592,8 +601,8 @@ def test_inline_override(self):
592601
support_tp1.override_list,
593602
[
594603
("^bootstrap_job$", [("certification_status", "blocker")]),
595-
("^job1$", [("certification_status", "non-blocker")]),
596604
("^mandatory_job$", [("certification_status", "blocker")]),
605+
("^job1$", [("certification_status", "non-blocker")]),
597606
],
598607
)
599608
self.assertEqual(
@@ -602,3 +611,18 @@ def test_inline_override(self):
602611
("^job1$", [("certification_status", "blocker")]),
603612
],
604613
)
614+
615+
def test_certification_status_overrides(self):
616+
"""
617+
Make sure certification_status_overrides is last in the override list
618+
(so that it's applied last and overwrites other certification status
619+
definitions)
620+
"""
621+
support_tp3 = TestPlanUnitSupport(self.tp3)
622+
self.assertEqual(
623+
support_tp3.override_list,
624+
[
625+
("^job1$", [("certification_status", "non-blocker")]),
626+
("^.*$", [("certification_status", "blocker")]),
627+
],
628+
)

checkbox-ng/plainbox/impl/unit/testplan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,10 @@ def _get_override_list(
800800
testplan
801801
):
802802
override_map[pattern].append((field, value))
803-
return sorted(
803+
return [
804804
(key, field_value_list)
805805
for key, field_value_list in override_map.items()
806-
)
806+
]
807807

808808
def _get_category_overrides(
809809
self, testplan: TestPlanUnit

0 commit comments

Comments
 (0)