Stop metajob application of undefined attributes
Previously, metajobs set defaults for boolean attributes that were not
defined, and copied to them to matched jobs. This could result in a
metajob that did not define a voting attribute unintentially
overriding a matched job with the default voting value (True). This
change ensures that metajobs set values only for explicitly supplied
boolean attributes.
Change-Id: I99dc3a58c63946ddb54849b1629101b062159a69
Closes-Bug: #2000166
diff --git a/tests/test_model.py b/tests/test_model.py
index a97f0a0..2711618 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -43,3 +43,22 @@
job = model.Job('job')
job.copy(self.job)
self.assertTrue(job.skip_if_matcher)
+
+ def _assert_job_booleans_are_not_none(self, job):
+ self.assertIsNotNone(job.voting)
+ self.assertIsNotNone(job.hold_following_changes)
+
+ def test_job_sets_defaults_for_boolean_attributes(self):
+ job = model.Job('job')
+ self._assert_job_booleans_are_not_none(job)
+
+ def test_metajob_does_not_set_defaults_for_boolean_attributes(self):
+ job = model.Job('^job')
+ self.assertIsNone(job.voting)
+ self.assertIsNone(job.hold_following_changes)
+
+ def test_metajob_copy_does_not_set_undefined_boolean_attributes(self):
+ job = model.Job('job')
+ metajob = model.Job('^job')
+ job.copy(metajob)
+ self._assert_job_booleans_are_not_none(job)